Skip to content

[tools] Ruff rules from pyairbyte #37508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 115 additions & 61 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ extend-ignore = [
"F811", # TODO: ella fix after pflake8 version update
]

# TODO: This will be removed in favor of the section below.
[tool.isort]
profile = "black"
color_output = false
Expand All @@ -69,95 +70,148 @@ skip_glob = [
# correctly handles first-party imports in subdirectories.
]

[tool.ruff.pylint]
max-args = 8 # Relaxed from default of 5
max-branches = 15 # Relaxed from default of 12

[tool.ruff]
target-version = "py38"
line-length = 140
exclude = [
# If any files should not be checked, add them here:
"setup.py", # These should be deprecated and will eventually replaced with pyproject.toml-based configuration.
]
ignore = [
# If any rules should be ignored, add them here:
"ANN101", # Missing type annotation for `self` in method
"ANN102", # Missing type annotation for `cls` in class method
"PT004", # Add leading underscore to fixtures that do not return anything
]
target-version = "py310"
select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"C90", # mccabe
"COM", # flake8-commas
"D", # pydocstyle/flake8-docstrings
"DTZ", # flake8-datetimezs
"E", # pycodestyle (error)
"EM", # flake8-errmsg
"ERA", # eradicate
# For rules reference, see https://docs.astral.sh/ruff/rules/
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"ASYNC", # flake8-async
"B", # flake8-bugbear
"FBT", # flake8-boolean-trap
"BLE", # Blind except
"C4", # flake8-comprehensions
"C90", # mccabe (complexity)
"COM", # flake8-commas
"CPY", # missing copyright notice
# "D", # pydocstyle # TODO: Re-enable when adding docstrings
"DTZ", # flake8-datetimez
"E", # pycodestyle (errors)
"ERA", # flake8-eradicate (commented out code)
"EXE", # flake8-executable
"F", # Pyflakes
"FA", # flake8-future-annotations
"FBT", # flake8-boolean-trap
"G", # flake8-logging-format
"FIX", # flake8-fixme
"FLY", # flynt
"FURB", # Refurb
"I", # isort
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"LOG", # flake8-logging
"N", # pep8-naming
"PERF", # perflint
"PGH", # pygrep-hooks
"PD", # pandas-vet
"PERF", # Perflint
"PIE", # flake8-pie
"PLC", # pylint (convention)
"PLE", # pylint (error)
"PLR", # pylint (refactor)
"PLW", # pylint (warning)
"PGH", # pygrep-hooks
"PL", # Pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"PYI", # flake8-pyi
"Q", # flake8-quotes
"RET", # flake8-return
"RSE", # flake8-raise
"RUF", # ruff
"S", # flake8-bandit
"RUF", # Ruff-specific rules
"SIM", # flake8-simplify
"T10", # flake8-debugger
"T20", # flake8-print
"TCH", # flake8-type-checking
"TID", # flake8-tidy-imports
"UP", # pyupgrade
"W", # pycodestyle (warning)
"YTT", # flake8-2020
"SLF", # flake8-self
"SLOT", # flake8-slots
"T10", # debugger calls
# "T20", # flake8-print # TODO: Re-enable once we have logging
"TCH", # flake8-type-checking
"TD", # flake8-todos
"TID", # flake8-tidy-imports
"TRY", # tryceratops
"TRY002", # Disallow raising vanilla Exception. Create or use a custom exception instead.
"TRY003", # Disallow vanilla string passing. Prefer kwargs to the exception constructur.
"UP", # pyupgrade
"W", # pycodestyle (warnings)
"YTT", # flake8-2020
]

[tool.ruff.per-file-ignores]
"__init__.py" = [
"F401", # Permit unused imports in `__init__.py` files
ignore = [
# For rules reference, see https://docs.astral.sh/ruff/rules/

# These we don't agree with or don't want to prioritize to enforce:
"ANN003", # kwargs missing type annotations
"ANN101", # Type annotations for 'self' args
"ANN102", # Type annotations for 'cls' args
"COM812", # Because it conflicts with ruff auto-format
"EM", # flake8-errmsgs (may reconsider later)
"DJ", # Django linting
"G", # flake8-logging-format
"ISC001", # Conflicts with ruff auto-format
"NPY", # NumPy-specific rules
"PIE790", # Allow unnecssary 'pass' (sometimes useful for readability)
"PERF203", # exception handling in loop
"S", # flake8-bandit (noisy, security related)
"SIM910", # Allow "None" as second argument to Dict.get(). "Explicit is better than implicit."
"TD002", # Require author for TODOs
"TRIO", # flake8-trio (opinionated, noisy)
"INP001", # Dir 'examples' is part of an implicit namespace package. Add an __init__.py.

# TODO: Consider re-enabling these before release:
"A003", # Class attribute 'type' is shadowing a Python builtin
"BLE001", # Do not catch blind exception: Exception
"ERA001", # Remove commented-out code
"FIX002", # Allow "TODO:" until release (then switch to requiring links via TDO003)
"PLW0603", # Using the global statement to update _cache is discouraged
"TD003", # Require links for TODOs # TODO: Re-enable when we disable FIX002

"UP007", # Allow legacy `Union[a, b]` and `Optional[a]` for Pydantic, until we drop Python 3.9 (Pydantic doesn't like it)
]
fixable = ["ALL"]
unfixable = [
"ERA001", # Commented-out code (avoid silent loss of code)
"T201", # print() calls (avoid silent loss of code / log messages)
]

[tool.ruff.flake8-annotations]
allow-star-arg-any = true
mypy-init-return = true
suppress-dummy-args = true

[tool.ruff.flake8-pytest-style]
parametrize-values-type = "tuple"
line-length = 140
extend-exclude = ["docs", "test", "tests"]
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.isort]
known-first-party = [
"airbyte",
"airbyte_cdk",
"airbyte_protocol",
"airbyte_api_client",
"connector_ops",
"pipelines",
force-sort-within-sections = false
lines-after-imports = 2
known-first-party = ["airbyte_cdk", "airbyte_protocol"]
known-local-folder = ["airbyte"]
required-imports = ["from __future__ import annotations"]
known-third-party = []
section-order = [
"future",
"standard-library",
"third-party",
"first-party",
"local-folder",
]
# No longer required with Python >=3.8
# required-imports = ["from __future__ import annotations"]

[tool.ruff.mccabe]
max-complexity = 24

[tool.ruff.pycodestyle]
ignore-overlong-task-comments = true

[tool.ruff.pydocstyle]
convention = "google"

[tool.ruff.flake8-annotations]
allow-star-arg-any = false
ignore-fully-untyped = false

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
preview = false
docstring-code-format = true

[tool.mypy]
platform = "linux"
exclude = "(build|integration_tests|unit_tests|generated)"
Expand Down
Loading