Skip to content

Commit 2a2f543

Browse files
committed
chore(linting): import rules from other PR
1 parent bd39e9b commit 2a2f543

File tree

1 file changed

+159
-0
lines changed

1 file changed

+159
-0
lines changed

pyproject.toml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,168 @@ skip = ["__init__.py"] # TODO: Remove after this is fixed: https://github.com/a
103103

104104
[tool.ruff]
105105
exclude = ["__init__.py"] # TODO: Remove after this is fixed: https://github.com/airbytehq/airbyte-python-cdk/issues/12
106+
include = ["airbyte_cdk/**/*.py"] # Ignore test and script folders
106107

107108
target-version = "py310"
108109
line-length = 100
110+
preview = true
111+
112+
[tool.ruff.lint]
113+
select = [
114+
# For rules reference, see https://docs.astral.sh/ruff/rules/
115+
"A", # flake8-builtins
116+
"ANN", # flake8-annotations
117+
"ARG", # flake8-unused-arguments
118+
"ASYNC", # flake8-async
119+
"B", # flake8-bugbear
120+
"BLE", # Blind except
121+
"C4", # flake8-comprehensions
122+
"C90", # mccabe (complexity)
123+
"COM", # flake8-commas
124+
"CPY", # missing copyright notice
125+
"DTZ", # flake8-datetimez
126+
"E", # pycodestyle (errors)
127+
"ERA", # flake8-eradicate (commented out code)
128+
"EXE", # flake8-executable
129+
"F", # Pyflakes
130+
"FA", # flake8-future-annotations
131+
"FBT", # flake8-boolean-trap
132+
"FIX", # flake8-fixme
133+
"FLY", # flynt
134+
"FURB", # Refurb
135+
"I", # isort
136+
"ICN", # flake8-import-conventions
137+
"INP", # flake8-no-pep420
138+
"INT", # flake8-gettext
139+
"ISC", # flake8-implicit-str-concat
140+
"LOG", # flake8-logging
141+
"N", # pep8-naming
142+
"PERF", # Perflint
143+
"PGH", # pygrep-hooks
144+
"PIE", # flake8-pie
145+
"PL", # Pylint
146+
"PT", # flake8-pytest-style
147+
"PTH", # flake8-use-pathlib
148+
"PYI", # flake8-pyi
149+
"Q", # flake8-quotes
150+
"RET", # flake8-return
151+
"RSE", # flake8-raise
152+
"RUF", # Ruff-specific rules
153+
"SIM", # flake8-simplify
154+
"SLF", # flake8-self
155+
"SLOT", # flake8-slots
156+
"T10", # debugger calls
157+
"TCH", # flake8-type-checking
158+
"TD", # flake8-todos
159+
"TID", # flake8-tidy-imports
160+
"TRY", # tryceratops
161+
"TRY002", # Disallow raising vanilla Exception. Create or use a custom exception instead.
162+
"UP", # pyupgrade
163+
"W", # pycodestyle (warnings)
164+
"YTT", # flake8-2020
165+
]
166+
ignore = [
167+
# For rules reference, see https://docs.astral.sh/ruff/rules/
168+
169+
# Consider re-enabling these when we have time to address them:
170+
"A003", # Class attribute 'type' is shadowing a Python builtin
171+
"BLE001", # Do not catch blind exception: Exception
172+
"C416", # Allow unnecessary-comprehensions. Auto-fix sometimes unsafe if operating over a mapping.
173+
"DTZ005", # Allow use of 'datetime.datetime.now()' without timezone (we should fix these eventually)
174+
"DTZ007", # Allow use of 'strptime()' without timezone (we should fix these eventually)
175+
"D", # pydocstyle (Docstring conventions)
176+
"D102", # Missing docstring in public method
177+
"D103", # Missing docstring in public function
178+
"E501", # Line too long
179+
"ERA001", # Remove commented-out code
180+
"FIX002", # Allow "TODO:" comments
181+
"PGH003", # Allow non-specific "type: ignore" comments
182+
"PLW0108", # Lambda may be unnecessary; consider inlining inner function
183+
"PLW0603", # Using the global statement to update _cache is discouraged
184+
"T20", # flake8-print, consider re-enabling once we have logging
185+
"TD003", # Require issue links for TODOs
186+
187+
# These we don't agree with or don't want to prioritize to enforce:
188+
"ANN003", # kwargs missing type annotations
189+
"ANN101", # Type annotations for 'self' args
190+
"ANN102", # Type annotations for 'cls' args
191+
"ASYNC1", # flake8-trio (opinionated, noisy)
192+
"COM812", # Because it conflicts with ruff auto-format
193+
"DJ", # Django linting
194+
"EM", # flake8-errmsgs (may reconsider later)
195+
"FURB189", # Subclassing safety at the cost if isinstance() instability
196+
"G", # flake8-logging-format
197+
"INP001", # Dir 'examples' is part of an implicit namespace package. Add an __init__.py.
198+
"ISC001", # Conflicts with ruff auto-format
199+
"N818", # Custom exception names should use the suffix "Error"
200+
"NPY", # NumPy-specific rules
201+
"N805", # Enforce first-arg is 'self' (false positive for class methods in Pydantic)
202+
"PD", # pandas-vet
203+
"PERF203", # exception handling in loop
204+
"PIE790", # Allow unnecssary 'pass' (sometimes useful for readability)
205+
"PLR6201", # Allow membership checks in lists (set-based check is unsafe when values are unhashable)
206+
"PLR6301", # Allow class methods that don't use 'self' (otherwise noisy)
207+
"RET504", # Ignore unnecessary assign before return
208+
"RUF022", # Allow unsorted __all__ (sometimes useful for grouping by type with pdoc)
209+
"S", # flake8-bandit (noisy, security related)
210+
"SIM910", # Allow "None" as second argument to Dict.get(). "Explicit is better than implicit."
211+
"TCH003", # Moving standard library imports under `TYPE_CHECKING` blocks is unsafe with Pydantic and Serpyco models
212+
"TD002", # Require author for TODOs
213+
"TRY003", # Allow string passing to exception constructor.
214+
"TRY400", # Ignore for now: prefer logging.exception over logging.error
215+
]
216+
fixable = ["ALL"]
217+
unfixable = [
218+
"ERA001", # Commented-out code (avoid silent loss of code)
219+
"T201", # print() calls (avoid silent loss of code / log messages)
220+
"TCH001", # Moving application imports under `TYPE_CHECKING` blocks is unsafe with Pydantic and Serpyco models
221+
"TCH002", # Moving 3rd part imports under `TYPE_CHECKING` blocks is unsafe with Pydantic and Serpyco models
222+
]
223+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
224+
225+
[tool.ruff.lint.pylint]
226+
max-args = 8 # Relaxed from default of 5
227+
max-branches = 15 # Relaxed from default of 12
228+
229+
230+
[tool.ruff.lint.isort]
231+
force-sort-within-sections = false
232+
lines-after-imports = 2
233+
known-first-party = [
234+
"airbyte_protocol",
235+
"airbyte_protocol_dataclasses",
236+
]
237+
known-local-folder = ["airbyte_cdk"]
238+
required-imports = ["from __future__ import annotations"]
239+
known-third-party = []
240+
section-order = [
241+
"future",
242+
"standard-library",
243+
"third-party",
244+
"first-party",
245+
"local-folder",
246+
]
247+
248+
[tool.ruff.lint.mccabe]
249+
max-complexity = 24
250+
251+
[tool.ruff.lint.pycodestyle]
252+
ignore-overlong-task-comments = true
253+
254+
[tool.ruff.lint.pydocstyle]
255+
convention = "google"
256+
257+
[tool.ruff.lint.flake8-annotations]
258+
allow-star-arg-any = false
259+
ignore-fully-untyped = false
260+
261+
[tool.ruff.format]
262+
quote-style = "double"
263+
indent-style = "space"
264+
skip-magic-trailing-comma = false
265+
line-ending = "auto"
266+
preview = false
267+
docstring-code-format = true
109268

110269
[tool.poe.tasks]
111270
# Build tasks

0 commit comments

Comments
 (0)