Skip to content

Instantly share code, notes, and snippets.

@nilreml
Last active June 11, 2024 11:01
Show Gist options
  • Save nilreml/987dafe8ca35e1a39da4fecf074d18b6 to your computer and use it in GitHub Desktop.
Save nilreml/987dafe8ca35e1a39da4fecf074d18b6 to your computer and use it in GitHub Desktop.
# Best practice pyproject.toml:
# https://github.com/airbytehq/airbyte/blob/master/airbyte-lib/pyproject.toml
[tool.coverage.run]
include = ["src/*"]
parallel = true
branch = true
[tool.coverage.paths]
source = ["src/"]
[tool.coverage.report]
skip_covered = true
show_missing = true
exclude_lines = [
'^\s*@overload( |$)',
'^\s*assert False(,|$)',
'if TYPE_CHECKING:',
'if typing.TYPE_CHECKING:',
]
[tool.coverage.run]
relative_files = true
[tool.coverage.report]
exclude_lines = [
"@deprecated",
"def __repr__",
"if 0:",
"if TYPE_CHECKING:",
"if __name__ == .__main__.:",
"if self.debug:",
"if settings.DEBUG",
"input",
"pragma: no cover",
"raise AssertionError",
"raise NotImplementedError",
]
[tool.codespell]
ignore-words-list = "ot,atomate"
check-filenames = true
[tool.poetry.scripts]
generate-docs = "docs:run"
airbyte-lib-validate-source = "airbyte_lib.validate:run"
# Ruff documentation : https://docs.astral.sh/ruff/
# Extension for VS Code : https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff
# Extension for other IDEs : https://github.com/charliermarsh/ruff-lsp
# NOTE: disable pycodestyle, pydocstyle, bandit and flake8 linters in your IDE since ruff includes these
target-version = "py311"
line-length = 100
[lint]
# Rule documentation: https://docs.astral.sh/ruff/rules
pydocstyle.convention = "google"
mccabe.max-complexity = 10
flake8-unused-arguments.ignore-variadic-names = true # Ignore unused *args and **kwargs -> standard practice
select = [
"A", # flake8-builtins
"AIR", # Airflow
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"ASYNC", # flake8-async
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"C90", # mccabe
"COM", # flake8-commas
#"D", # pydocstyle
"DJ", # flake8-django
"DTZ", # flake8-datetimez
"E", # pycodestyle Error
"EM", # flake8-errmsg
"ERA", # eradicate
"EXE", # flake8-executable
"F", # Pyflakes
"FA", # flake8-future-annotations
"FBT", # flake8-boolean-trap
"FIX", # flake8-fixme
"FLY", # flynt
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"N", # pep8-naming
"NPY", # NumPy-specific rules
"PD", # pandas-vet
"PERF", # Perflint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # Pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"PYI", # flake8-pyi
"Q", # flake8-quotes
"RET", # flake8-return
"RSE", # flake8-raise
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLF", # flake8-self
"SLOT", # flake8-slots
"T10", # flake8-debugger
"T20", # flake8-print
"TCH", # flake8-type-checking
"TD", # flake8-todos
"TID", # flake8-tidy-imports
"TRIO", # flake8-trio
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle Warning
"YTT", # flake8-2020
# TODO: enable these once they're out of preview
# "CPY", # flake8-copyright
# "FURB", # refurb
]
ignore = [
"A001", # Allow shadowing built-in types like 'id'
"A002", # Allow shadowing built-in types like 'id'
"DTZ005", # Allow datetime.now() without specifiying timezone
"ANN101", # Type annotations for "self" args -> deprecated
"ANN102", # Type annotations for "cls" args -> deprecated
"DJ", # Disable Django linting -> unused
"E501", # Avoid linter errors for line length -> ruff-format handles line length as good as possible
"G004", # Allow logging statements using f-strings
"ISC001", # Conflicts with COM812 -> prefer trailing commas over implicit string concatenation to reduce diff noise
"TD002", # Don't require author for TODOs
"TRY002", # Allow descriptive exception messages without defining custom exception classes for now
"TRY003", # Allow descriptive exception messages without defining custom exception classes for now
#"D", # TODO: remove to enforce docstrings
]
unfixable = [
"B", # Autofixing bugbear findings is a bit too aggressive
"ERA001", # Don't remove commented-out code
"F841", # Autofixing unused variables conservatively leaves right-hand-side intact, which is almost always incorrect
"RUF", # Autofixes for ruff-specific rules possibly too aggressive
"SIM", # Autofixes for flake8-simplify possibly too aggressive
"TRY", # Autofixes for tryceratops possibly too aggressive
]
[lint.extend-per-file-ignores]
"tests/*" = [
"ANN201", # Allow missing return type annotation in unit tests -> standard practice
"D", # Allow missing docstrings in unit tests -> standard practice
"S101", # Allow using assert statements in unit tests -> best practice
]
[format]
# Documentation: https://docs.astral.sh/ruff/settings/#format
docstring-code-format = true
line-ending = "lf"
skip-magic-trailing-comma = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment