Repository navigation
Expand file tree
/
Copy pathruff.toml
More file actions
187 lines (176 loc) · 8.08 KB
/
Copy pathruff.toml
File metadata and controls
187 lines (176 loc) · 8.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# ----------------------------------------------------> ruff.toml <----------------------------------------------------
# Ruff - An extremely fast Python linter and code formatter, written in Rust.
# https://docs.astral.sh/ruff/configuration
# Enforce a Ruff version requirement at runtime; if unmet, Ruff will exit with an error.
required-version = ">=0.13.3"
# Enable preview features.
preview = true
# Enumerate all fixed violations.
show-fixes = true
# Enable unsafe fixes; if omitted, show a hint when available; if false, hide the hint.
unsafe-fixes = false
# Keep file discovery identical whether you pass "." or not
respect-gitignore = true # default, shown for clarity
force-exclude = true # apply excludes even for explicit paths like "."
src = ["src"]
line-length = 120
indent-width = 4
# Exclude a variety of commonly ignored directories.
exclude = [
".git",
".github",
".pytest_cache",
".ruff_cache",
".venv",
".vscode",
".cursor",
".idea",
"__pypackages__",
"build",
"dist",
"site-packages",
"docs"
]
[format]
indent-style = "space" # match EditorConfig
line-ending = "lf" # enforce LF newlines
quote-style = "double"
# Docstring code formatting
docstring-code-format = true # format Python code blocks in docstrings
# tombi: lint.rules.type-mismatch.disabled = true
docstring-code-line-length = "dynamic" # int | "dynamic" (used only if above is true)
# Trailing-comma behavior (Black's “magic comma”)
skip-magic-trailing-comma = false # leave multi-line when trailing comma present
# Formatter-only file excludes (extra to top-level exclude/extend-exclude)
exclude = []
# Opt into preview (experimental) formatting style
preview = true
[lint]
# Opt into preview (experimental) linting style
preview = true
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []
select = [
# TODO -> Uncomment all commented prefix
# prefix
"ERA", # https://docs.astral.sh/ruff/rules/#eradicate-era
"FAST", # https://docs.astral.sh/ruff/rules/#fastapi-fast
"ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann
"ASYNC", # https://docs.astral.sh/ruff/rules/#flake8-async-async
# "S", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s
"BLE", # https://docs.astral.sh/ruff/rules/#flake8-blind-except-ble
"FBT", # https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbt
"B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
"EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
"EXE", # https://docs.astral.sh/ruff/rules/#flake8-executable-exe
# "FIX", # https://docs.astral.sh/ruff/rules/#flake8-fixme-fix
"FA", # https://docs.astral.sh/ruff/rules/#flake8-future-annotations-fa
"ISC", # https://docs.astral.sh/ruff/rules/#flake8-implicit-str-concat-isc
"ICN", # https://docs.astral.sh/ruff/rules/#flake8-import-conventions-icn
"INP", # https://docs.astral.sh/ruff/rules/#flake8-no-pep420-inp
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
"T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20
"PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
# "SLF", # https://docs.astral.sh/ruff/rules/#flake8-self-slf
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
# "SLOT", # https://docs.astral.sh/ruff/rules/#flake8-slots-slot
"TID", # https://docs.astral.sh/ruff/rules/#flake8-tidy-imports-tid
"TC", # https://docs.astral.sh/ruff/rules/#flake8-type-checking-tc
# "ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
"FLY", # https://docs.astral.sh/ruff/rules/#flynt-fly
"I", # https://docs.astral.sh/ruff/rules/#isort-i
"C90", # https://docs.astral.sh/ruff/rules/#mccabe-c90
"N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
"E", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
"W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
"DOC", # https://docs.astral.sh/ruff/rules/#pydoclint-doc
# "D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d
"F", # https://docs.astral.sh/ruff/rules/#pyflakes-f
"PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh
# "PL", # https://docs.astral.sh/ruff/rules/#pylint-pl
"PLC", # https://docs.astral.sh/ruff/rules/#convention-plc
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
"FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
"TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try
]
ignore = [
"D100", # ignore missing docstring in module
"D102", # ignore missing docstring in public method
"D104", # ignore missing docstring in public package
"D105", # ignore missing docstring in magic methods
"D107", # ignore missing docstring in __init__ methods
"D206", # docstring-tab-indentation (formatter handles indentation)
"D300", # triple-single-quotes (formatter enforces double quotes)
"DOC201", # type hints + summary lines suffice; Returns sections added only when they add info beyond the signature (#1078)
"ERA001", # commented-out code
"PLC0414", # keep explicit alias
# TODO -> Remove the rules below this line
"RUF029", # Function is declared `async`, but doesn't `await` or use `async` features.
"ANN401", # https://docs.astral.sh/ruff/rules/any-type
"N803", # Argument names must be lowercase (snake_case)
"N999", # Module (file) names must be snake_case
]
# Map file patterns to rule codes/prefixes to exclude for matching files; a leading '!' negates the file pattern.
[lint.per-file-ignores]
"examples/samples/**.py" = [
"F403", # https://docs.astral.sh/ruff/rules/undefined-local-with-import-star
"F405", # https://docs.astral.sh/ruff/rules/undefined-local-with-import-star-usage
"E501", # https://docs.astral.sh/ruff/rules/line-too-long
]
"examples/**.py" = [
"T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20
"A004", # https://docs.astral.sh/ruff/rules/builtin-import-shadowing/
]
"scripts/copy_src_example_to_callable.py" = ["C901"]
"scripts/missing_examples.py" = ["A004"]
"src/air/form/main.py" = ["A002"]
[lint.flake8-import-conventions]
# Declare the banned `from` imports.
banned-from = []
[lint.flake8-bugbear]
extend-immutable-calls = ["air.Query", "air.Depends", "air.Path", "air.Header", "air.Cookie", "air.Body"]
[lint.isort]
# group aliases coming from the same module
combine-as-imports = true
# keep the multi-line, parenthesized layout
force-wrap-aliases = true
# Help Ruff classify your own package as first-party (very important for stable sorting)
known-first-party = ["air"]
# Extra safety: mark imports from the same package as first-party when inside it
detect-same-package = true
# Keep the standard section order; set explicitly for clarity
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
# Keep type-based ordering (default, but set explicitly)
order-by-type = true
# Do NOT set these (formatter conflicts):
# force-single-line, lines-after-imports, lines-between-types, split-on-trailing-comma
[lint.pycodestyle]
ignore-overlong-task-comments = true
max-doc-length = 120
max-line-length = 120
[lint.pydocstyle]
convention = "google"
[lint.mccabe]
max-complexity = 10 # set the C901 threshold explicitly
[lint.flake8-type-checking]
# Do NOT auto-quote annotations; prefer normal annotations.
quote-annotations = false
# These must exist at runtime (annotations are read/used), so don't gate their imports
runtime-evaluated-base-classes = [
"pydantic.BaseModel",
]
runtime-evaluated-decorators = [
"dataclasses.dataclass",
"pydantic.validate_call",
"fastapi.FastAPI.get",
]
# Modules that are always safe to import (never gate)
exempt-modules = ["typing", "typing_extensions"]