-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyproject.toml
139 lines (130 loc) · 4.6 KB
/
pyproject.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
# https://beta.ruff.rs/docs/configuration
[tool.ruff]
target-version = "py39"
line-length = 120
select = ["ALL"]
# https://beta.ruff.rs/docs/rules
ignore = [
###
# Not needed or wanted
###
"D1", # pydocstyle Missing doctring
"ISC003", # flake8-implicit-str-concat: explicit-string-concatenation
"INP", # flake8-no-pep420
"EM", # flake8-errmsg
# contextlib.suppress is roughly 3x slower than try/except
"SIM105", # flake8-simplify: use-contextlib-suppress
# Checked by type-checker (pyright)
"ANN", # flake-annotations
"TCH003", # flake8-type-checking: typing-only-standard-library-import
###
# Specific to this project
###
# Print are used as debug logs
"T20", # flake8-print
# Third-party type-checking is installed on runtime
"TCH002", # flake8-type-checking: typing-only-third-party-import
# Allow imports at the bottom of file
"E402",
# Let's use datetime.utcnow()
"DTZ003", # flake8-datetimez: call-datetime-utcnow
# datetime.strptime
"DTZ007", # flake8-datetimez: call-datetime-strptime-without-zone
# TODO: check for later
"FBT", # flake8-boolean-trap
"D", # pydocstyle
### FIXME (no warnings in Ruff yet: https://github.com/charliermarsh/ruff/issues/1256):
"PLR2004", # Pylint Refactor: magic-value-comparison
"BLE001", # flake8-blind-except: blind-except
"ERA001", # eradicate: commented-out-code
# TODO: Disabled until using *proper* class based logic
"TRY", # tryceratops
"N801", # pep8-naming: invalid-class-name
"SLF001", # flake8-self: private-member-access
]
# https://beta.ruff.rs/docs/settings/#flake8-implicit-str-concat
[tool.ruff.flake8-implicit-str-concat]
allow-multiline = false
# https://beta.ruff.rs/docs/settings/#isort
[tool.ruff.isort]
combine-as-imports = true
split-on-trailing-comma = false
required-imports = ["from __future__ import annotations"]
[tool.ruff.per-file-ignores]
"*.pyi" = ["I002"]
# https://beta.ruff.rs/docs/settings/#mccabe
[tool.ruff.mccabe]
# Hard limit, arbitrary to 4 bytes
max-complexity = 31
# Arbitrary to 2 bytes, same as SonarLint
# max-complexity = 15
[tool.ruff.pylint]
# Arbitrary to 1 byte, same as SonarLint
max-args = 7
# At least same as max-complexity
max-branches = 15
### Possible future ruff.pylint configurations
# https://github.com/charliermarsh/ruff/issues/970
# # Dynamic/Generated members from SQLAlchemy
# ignored-classes = ["scoped_session"]
# # Arbitrary to 2 bytes
# max-attributes = 15
# max-locals = 15
# disable = [
# # No need to mention the fixmes
# "fixme",
# "missing-docstring",
# # Already taken care of and grayed out. Also conflicts with Pylance reportIncompatibleMethodOverride
# "unused-argument",
# # Only reports a single instance. Pyright does a better job anyway
# "cyclic-import",
# # Strings are ok. Pylance also doesn't seem to see our overriden Exception classes (TODO: Make it better?)
# "invalid-sequence-index",
# # Happens too often with Flask, child classes should not be affected by this rule
# # See: https://github.com/PyCQA/pylint/issues/4352
# "too-few-public-methods",
# # Similar lines in 2 files, doesn't really work
# "R0801",
# ]
# https://github.com/hhatto/autopep8#usage
# https://github.com/hhatto/autopep8#more-advanced-usage
[tool.autopep8]
max_line_length = 120
recursive = true
aggressive = 3
ignore = [
# TODO Suggest "multi-line method invocation style" to Ruff. and/or change to Black
"E124", # Closing bracket may not match multi-line method invocation style (enforced by add-trailing-comma)
"E70", # Allow ... on same line as def
"W503", # Linebreak before binary operator
"E402", # Allow imports at the bottom of file
]
# https://github.com/microsoft/pyright/blob/main/docs/configuration.md#sample-pyprojecttoml-file
[tool.pyright]
# Minimal python version supported
pythonVersion = "3.9"
# Ignore must be specified for Pylance to stop displaying errors
ignore = [
# We expect stub files to be incomplete or contain useless statements
"**/*.pyi",
]
# TODO: Fix everything and set to strict
typeCheckingMode = "basic"
# Extra strict
reportShadowedImports = "error"
reportImplicitStringConcatenation = "error"
reportCallInDefaultInitializer = "error"
reportPropertyTypeMismatch = "error"
reportUninitializedInstanceVariable = "error"
reportUnnecessaryTypeIgnoreComment = "error"
# Use `pyright: ignore`, not `type: ignore`
enableTypeIgnoreComments = false
# Type stubs may not be completable
reportMissingTypeStubs = "warning"
# False positives with TYPE_CHECKING
reportImportCycles = "information"
# Extra runtime safety
reportUnnecessaryComparison = "warning"
# Too strict
reportUnusedCallResult = "none"
reportMissingSuperCall = "none"