-
Notifications
You must be signed in to change notification settings - Fork 2
/
ruff_defaults.toml
154 lines (131 loc) · 3.74 KB
/
ruff_defaults.toml
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
# Partly based on https://github.com/pypa/hatch/blob/master/ruff_defaults.toml
# Edit this file in the qpy-dev repository and sync it to other repositories using `poe config:ruff`.
# Common Ruff configurations are included here; project-specific configurations should be placed in `pyproject.toml`
# under `[tool.ruff]`.
target-version = "py311"
line-length = 120
output-format = "concise"
preview = true
[format]
docstring-code-format = true
docstring-code-line-length = 120
[lint]
# https://docs.astral.sh/ruff/rules/
extend-select = [
"F", # pyflakes
"E", # pycodestyle errors
"W", # pycodestyle warnings
"PL", # pylint
# flake8
"A", # -builtins
"ASYNC", # -async
"B", # -bugbear
"BLE", # -blind-except
"C4", # -comprehensions
"COM", # -commas
"DTZ", # -datetimez
"EM", # -errmsg
"EXE", # -executable
"FA", # -future-annotations
"FBT", # -boolean-trap
"G", # -logging-format
"ICN", # -import-conventions
"INP", # -no-pep420
"INT", # -gettext
"ISC", # -implicit-str-concat
"LOG", # -logging
"PIE", # -pie
"PT", # -pytest-style
"PYI", # -pyi
"Q", # --quotes
"RET", # -return
"RSE", # -raise
"S", # -bandit
"SIM", # -simplify
"SLOT", # -slots
"T10", # -debugger
"T20", # -print
"TCH", # -type-checking
"TD004", # -todos
"TD005",
"TD006",
"TD007",
"TID", # -tidy-imports
"YTT", # -2020
"C90", # mccabe
"D", # pydocstyle
"ERA", # eradicate
"FLY", # flynt
"FURB", # refurb
"I", # isort
"N", # pep8-naming
"PERF", # Perflint
"PGH", # pygrep-hooks
"RUF", # Ruff-specific rules
"TRY", # tryceratops
"UP", # pyupgrade
]
ignore = [
# builtin-module-shadowing (relative module names such as 'abc' or 'types' are pretty normal)
"A005",
# allow async functions with timeout parameter
"ASYNC109",
# Relax on missing docstrings
"D1",
# conflicting with formatter
"W191",
"E111",
"E114",
"E117",
"D206",
"D300",
"Q000",
"Q001",
"Q002",
"Q003",
"COM812",
"COM819",
"ISC001",
"ISC002",
# seems to produce a lot of false positives
"PLR6301",
# bandit
"S404", # allow `subprocess`
"S311", # don't flag `random.*`
"S320", # allow XML parsing using lxml
# ruff doesn't track inheritance across files, disabling to prevent false positives
# https://github.com/astral-sh/ruff/issues/5243#issuecomment-1860862939
"RUF012",
]
pydocstyle = { convention = "google" }
[lint.per-file-ignores]
"**/scripts/*" = ["INP001", "T201"]
"**/tests/**/*" = ["PLC1901", "PLC2701", "PLR2004", "S", "TID252", "FBT"]
[lint.flake8-builtins]
# help: (guess it's ok since built-in `help()` is for interactive use and no collisions are expected)
builtins-ignorelist = ["help"]
[lint.pyupgrade]
# Ensure we can still parse type hints at runtime.
# - https://docs.astral.sh/ruff/settings/#lint_pyupgrade_keep-runtime-typing
# - https://github.com/astral-sh/ruff/issues/6617
keep-runtime-typing = true
[lint.flake8-type-checking]
# Prevent from being moved into TYPE_CHECKING block as pydantic needs type hints at runtime
runtime-evaluated-decorators = ["pydantic.validate_call"]
runtime-evaluated-base-classes = ["pydantic.BaseModel"]
[lint.pep8-naming]
# Allow Pydantic's `@validator` decorator to trigger class method treatment.
classmethod-decorators = ["pydantic.validator"]
[lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false
[lint.flake8-tidy-imports]
ban-relative-imports = "parents"
[lint.isort]
known-first-party = ["questionpy", "questionpy_common", "questionpy_sdk", "questionpy_server"]
[lint.mccabe]
max-complexity = 10
[lint.pylint]
max-args = 10
max-branches = 15
max-nested-blocks = 10