Last active
January 14, 2024 22:51
-
-
Save kaparoo/f856d9ea5b62c5475772d82279b7d94b to your computer and use it in GitHub Desktop.
Common .gitignore, pyproject.toml and vscode configurations for python projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ========================== # | |
# Etc. # | |
# ========================== # | |
# python virtual environments | |
.venv* | |
# private stuffs | |
*/privates/ | |
*/private/ | |
privates/ | |
private/ | |
# temporary stuffs | |
*/temps/ | |
*/temp/ | |
temps/ | |
temp/ | |
# ========================== # | |
# Visual Studio Code # | |
# ========================== # | |
# .vscode/ stuffs | |
.vscode/* | |
!.vscode/settings.json | |
!.vscode/tasks.json | |
!.vscode/launch.json | |
!.vscode/extensions.json | |
!.vscode/*.code-snippets | |
# Local History for Visual Studio Code | |
.history/ | |
# Built Visual Studio Code Extensions | |
*.vsix | |
# ========================== # | |
# Python # | |
# ========================== # | |
# Byte-compiled / optimized / DLL files | |
__pycache__/ | |
*.py[cod] | |
*$py.class | |
# C extensions | |
*.so | |
# Distribution / packaging | |
.Python | |
build/ | |
develop-eggs/ | |
dist/ | |
downloads/ | |
eggs/ | |
.eggs/ | |
lib/ | |
lib64/ | |
parts/ | |
sdist/ | |
var/ | |
wheels/ | |
share/python-wheels/ | |
*.egg-info/ | |
.installed.cfg | |
*.egg | |
MANIFEST | |
# PyInstaller | |
# Usually these files are written by a python script from a template | |
# before PyInstaller builds the exe, so as to inject date/other infos into it. | |
*.manifest | |
*.spec | |
# Installer logs | |
pip-log.txt | |
pip-delete-this-directory.txt | |
# Unit test / coverage reports | |
htmlcov/ | |
.tox/ | |
.nox/ | |
.coverage | |
.coverage.* | |
.cache | |
nosetests.xml | |
coverage.xml | |
*.cover | |
*.py,cover | |
.hypothesis/ | |
.pytest_cache/ | |
cover/ | |
# Translations | |
*.mo | |
*.pot | |
# Django stuff: | |
*.log | |
local_settings.py | |
db.sqlite3 | |
db.sqlite3-journal | |
# Flask stuff: | |
instance/ | |
.webassets-cache | |
# Scrapy stuff: | |
.scrapy | |
# Sphinx documentation | |
docs/_build/ | |
# PyBuilder | |
.pybuilder/ | |
target/ | |
# Jupyter Notebook | |
.ipynb_checkpoints | |
# IPython | |
profile_default/ | |
ipython_config.py | |
# pyenv | |
# For a library or package, you might want to ignore these files since the code is | |
# intended to run in multiple environments; otherwise, check them in: | |
.python-version | |
# pipenv | |
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | |
# However, in case of collaboration, if having platform-specific dependencies or dependencies | |
# having no cross-platform support, pipenv may install dependencies that don't work, or not | |
# install all needed dependencies. | |
#Pipfile.lock | |
# poetry | |
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | |
# This is especially recommended for binary packages to ensure reproducibility, and is more | |
# commonly ignored for libraries. | |
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | |
#poetry.lock | |
# pdm | |
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | |
#pdm.lock | |
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | |
# in version control. | |
# https://pdm.fming.dev/#use-with-ide | |
.pdm.toml | |
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | |
__pypackages__/ | |
# Celery stuff | |
celerybeat-schedule | |
celerybeat.pid | |
# SageMath parsed files | |
*.sage.py | |
# Environments | |
.env | |
.venv | |
env/ | |
venv/ | |
ENV/ | |
env.bak/ | |
venv.bak/ | |
# Spyder project settings | |
.spyderproject | |
.spyproject | |
# Rope project settings | |
.ropeproject | |
# mkdocs documentation | |
/site | |
# mypy | |
.mypy_cache/ | |
.dmypy.json | |
dmypy.json | |
# Pyre type checker | |
.pyre/ | |
# pytype static type analyzer | |
.pytype/ | |
# Cython debug symbols | |
cython_debug/ | |
# PyCharm | |
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | |
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | |
# and can be added to the global gitignore or merged into this file. For a more nuclear | |
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | |
#.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"recommendations": [ | |
"ms-python.python", | |
"ms-python.vscode-pylance", | |
"charliermarsh.ruff", | |
"littlefoxteam.vscode-python-test-adapter", | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See the following PEPs for more information | |
# https://peps.python.org/pep-0517/ | |
# https://peps.python.org/pep-0518/ | |
# https://peps.python.org/pep-0621/ | |
# ========================== # | |
# Build System # | |
# ========================== # | |
[build-system] | |
requires = ["hatchling"] | |
build-backend = "hatchling.build" | |
# ========================== # | |
# Project Metadata # | |
# ========================== # | |
[project] | |
name = "YOUR_PROJECT_NAME" # FIX HERE | |
dynamic = ["version"] | |
description = "YOUR_PROJECT_DESCRIPTION" # FIX HERE | |
readme = "README.md" | |
requires-python = "PYTHON_VERSION_SPECIFIER" # FIX HERE | |
license = { file = "LICENSE" } | |
authors = [ | |
{ name = "AUTHOR_NAME", email = "AUTHOR@EMAIL" }, # FIX HERE | |
] | |
maintainers = [ | |
{ name = "MAINTAINER_NAME", email = "MAINTAINER@EMAIL"}, # FIX HERE | |
] | |
keywords = [ | |
"YOUR", # FIX HERE | |
"PROJECT", # FIX HERE | |
"KEYWORDS", # FIX HERE | |
] | |
classifiers = [ | |
"Development Status :: 4 - Beta", | |
"Intended Audience :: Developers", | |
"License :: OSI Approved :: MIT License", | |
"Operating System :: OS Independent", | |
"Programming Language :: Python", | |
"Programming Language :: Python :: 3", | |
"Programming Language :: Python :: 3 :: Only", | |
"Programming Language :: Python :: Implementation :: CPython", | |
"Typing :: Typed", | |
# See https://pypi.org/classifiers/ for more classifiers | |
] | |
dependencies = [ | |
"YOUR", # FIX HERE | |
"PROJECT", # FIX HERE | |
"DEPENDENCIES", # FIX HERE | |
] | |
[project.optional-dependencies] | |
dev = [ | |
"hatch", | |
"ruff", | |
"mypy", | |
"pytest", | |
] | |
# Reserved for future addition of --only-deps option to `pip install` | |
# See https://github.com/pypa/pip/issues/11440 for more information | |
[project.urls] | |
GitHub = "https://www.github.com/YOUR/REPOSITORY" # FIX HERE | |
# ========================== # | |
# [tool.*] Sections # | |
# ========================== # | |
[tool.hatch.build] | |
only-include = ["project"] # FIX HERE | |
# See the following documentation for more information | |
# https://hatch.pypa.io/latest/build/ | |
# https://hatch.pypa.io/latest/config/build/ | |
[tool.hatch.version] | |
path = "project/__about__.py" # FIX HERE | |
# See the following documentation for more information | |
# https://hatch.pypa.io/latest/version/ | |
[tool.mypy] | |
allow_redefinition = true | |
cache_dir = "./.cache/mypy" | |
exclude = ["tests/"] | |
pretty = true | |
show_error_codes = true | |
show_column_numbers = true | |
warn_redundant_casts = true | |
warn_return_any = true | |
warn_unused_configs = true | |
warn_unused_ignores = true | |
warn_unreachable = true | |
# See the following documentation for more information | |
# https://mypy.readthedocs.io/en/stable/config_file.html | |
# https://mypy.readthedocs.io/en/stable/config_file.html#example-pyproject-toml | |
[tool.pytest.ini_options] | |
cache_dir = "./.cache/pytest" | |
testpaths = ["tests/"] | |
# See the following documentation for more information | |
# https://docs.pytest.org/en/latest/reference/customize.html#pyproject-toml | |
# https://docs.pytest.org/en/latest/reference/reference.html#ini-options-ref | |
[tool.ruff] | |
cache-dir = "./.cache/ruff" | |
extend-exclude = [".cache", ".venv*", ".vscode", "tests"] | |
ignore-init-module-imports = true | |
# See the following documentation for more information | |
# https://docs.astral.sh/ruff/configuration/ | |
# https://docs.astral.sh/ruff/settings/ | |
# https://docs.astral.sh/ruff/rules/ | |
[tool.ruff.lint] | |
extend-select = [ | |
"I", # isort | |
"UP", # pyupgrade | |
"YTT", # flake8-2020 | |
"ANN", # flake8-annotations | |
"BLE", # flake8-blind-except | |
"FBT", # flake8-boolean-trap | |
"B", # flake8-bugbear | |
"A", # flake8-builtins | |
"C4", # flake8-comprehensions | |
"PIE", # flake8-pie | |
"RSE", # flake8-raise | |
"RET", # flake8-return | |
"SLOT", # flake8-slots | |
"SIM", # flake8-simplify | |
"TCH", # flake8-type-checking | |
"ARG", # flake8-unused-arguments | |
"PGH", # pygrep-hooks | |
"PL", # Pylint | |
"TRY", # tryceratops | |
"FLY", # flynt | |
"PERF", # Perflint | |
# "FURB", # refurb (in preview) | |
"RUF", # Ruff-specific rules | |
] | |
extend-ignore = [ | |
"PLR0904", # too-many-public-methods | |
"PLR0911", # too-many-return-statements | |
"PLR0912", # too-many-branches | |
"PLR0913", # too-many-arguments | |
"PLR0915", # too-many-statements | |
"PLR0916", # too-many-boolean-expressions | |
"PLR2004", # magic-value-comparison | |
] | |
[tool.ruff.lint.flake8-annotations] | |
allow-star-arg-any = true | |
ignore-fully-untyped = true | |
mypy-init-return = true | |
suppress-dummy-args = true | |
suppress-none-returning = true | |
[tool.ruff.lint.flake8-type-checking] | |
exempt-modules = ["typing", "typing_extensions"] | |
[tool.ruff.lint.flake8-unused-arguments] | |
ignore-variadic-names = true | |
[tool.ruff.lint.isort] | |
known-first-party = ["project"] # FIX HERE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// ==================== // | |
// PYTHONPATH // | |
// ==================== // | |
"terminal.integrated.env.windows": { | |
"PYTHONPATH": "${workspaceFolder}" | |
}, | |
"terminal.integrated.env.linux": { | |
"PYTHONPATH": "${workspaceFolder}" | |
}, | |
"terminal.integrated.env.osx": { | |
"PYTHONPATH": "${workspaceFolder}" | |
}, | |
// ==================== // | |
// Code Quality // | |
// ==================== // | |
"[python]": { | |
"editor.rulers": [ | |
72, // PEP 8 recommendation for docstrings or comments | |
88, // default max line-length in `black` | |
], | |
"editor.codeActionsOnSave": { | |
"source.fixAll": "explicit", | |
"source.organizeImports": "explicit", | |
}, | |
"editor.formatOnSave": true, | |
"editor.defaultFormatter": "charliermarsh.ruff" | |
}, | |
// ==================== // | |
// Testing // | |
// ==================== // | |
"python.testing.autoTestDiscoverOnSaveEnabled": true, | |
"python.testing.pytestEnabled": true, | |
} |
Last edited on Jan. 15th, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://www.github.com/kaparoo/python-project-template