forked from ilius/pyglossary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyproject.toml
358 lines (339 loc) · 11.1 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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
[tool.ruff]
line-length = 88
target-version = "py310"
lint.select = [
"F", # Pyflakes
"E", # pycodestyle Error
"W", # pycodestyle Warning
# "C90", # mccabe: C901: {name} is too complex ({complexity})
"I", # isort: unsorted-imports, missing-required-import
# "N", # pep8-naming
"D", # pydocstyle
"B", # flake8-bugbear
"UP", # pyupgrade
"YTT", # flake8-2020
# "ANN", # flake8-annotationsq, still gives errors for `self`
# ASYNC, # flake8-async
"TRIO", # flake8-trio
# "S", # flake8-bandit
"BLE", # flake8-blind-except
# "FBT", # flake8-boolean-trap
# "B", flake8-bugbear
# "A", # flake8-builtins
"COM", # flake8-commas
# "CPY", # flake8-copyright --preview
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
"DJ", # flake8-django
# "EM", # flake8-errmsg, WTF?
"EXE", # flake8-executable
"FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"G", # flake8-logging-format
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"T20", # flake8-print
"PYI", # flake8-pyi
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RSE", # flake8-raise
"RET", # flake8-return
"SLF", # flake8-self
"SLOT", # flake8-slots
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"TCH", # flake8-type-checking
"INT", # flake8-gettext
"ARG", # flake8-unused-arguments
# "PTH", # flake8-use-pathlib
# "TD", # flake8-todos
# "FIX", # flake8-fixme: just shows me FIXMEs and TODOs
# "ERA", # eradicate
"PD", # pandas-vet
"PGH", # pygrep-hooks
# "PL", # Pylint
# "TRY", # tryceratops, they all sound BS
# "FLY", # flynt
"NPY", # NumPy-specific rules
"AIR", # Airflow
"PERF", # Perflint
# "FURB", # refurb --preview
"LOG", # flake8-logging
"RUF", # Ruff-specific rules
]
lint.ignore = [
"SLF", # Private member accessed
"PYI034", # py3.11: `__iadd__` methods in classes like `SqEntryList` usually return `self` at runtime
"DTZ001", # The use of `datetime.datetime()` without `tzinfo` argument is not allowed
"DTZ005", # The use of `datetime.datetime.now()` without `tz` argument is not allowed
"PGH003", # Use specific rule codes when ignoring type issues
"PT027", # Use `pytest.raises` instead of unittest-style `assertRaises`, why?
"PD011", # Use `.to_numpy()` instead of `.values`, WTF?
"ICN001", # `tkinter` should be imported as `tk`, WTF?
"RUF005", # Consider `[*_list, x]` instead of concatenation
"PT009", # Use a regular `assert` instead of unittest-style `assertEqual`, why?
"PLR0911", # Too many return statements (x > 6)
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"BLE001", # Do not catch blind exception: `Exception`
"G004", # Logging statement uses f-string, WTF?
"TRY400", # Use `logging.exception` instead of `logging.error`
"TRY003", # Avoid specifying long messages outside the exception class, ???
"RUF100", # Unused `noqa` directive (non-enabled: ...)
"FURB101", # `open` and `read` should be replaced by `Path(rootConfJsonFile).read_text()`
"B019", # Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
"D105", # Missing docstring in magic method
"D107", # Missing docstring in `__init__`
"D205", # 1 blank line required between summary line and description
"D206", # Docstring should be indented with spaces, not tabs
"D211", # (Do not enable) no-blank-line-before-class
"D212", # multi-line-summary-first-line, conflicts with D213:multi-line-summary-second-line
"D401", # First line of docstring should be in imperative mood
"D417", # Missing argument descriptions in the docstring
"E402", # Module level import not at top of file
"E721", # Do not compare types, use `isinstance()`
"SIM105", # Use contextlib.suppress({exception}) instead of try-except-pass
"SIM117", # Use a single with statement with multiple contexts...
"UP009", # UTF-8 encoding declaration is unnecessary
"UP037", # Remove quotes from type annotation
"W191", # Indentation contains tabs
"SIM110", # Use any(...)
"SIM115", # Use context handler for opening files
# "SIM111", # Use all(...): warning: `SIM111` has been remapped to `SIM110`.
# ERA, PD,
"TCH003", # Move standard library import `...` into a type-checking block
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in ...
]
# UP033: (Since Python 3.9) Use `@functools.cache`
# instead of `@functools.lru_cache(maxsize=None)`
# since which Python is comma after **kwargs allowd?
# Allow autofix for all enabled rules (when `--fix`) is provided.
lint.fixable = [
"RUF",
"Q",
"UP010", # Unnecessary `__future__`"
"SIM108", # Use ternary operator {contents} instead of if-else-block
"C408", # Unnecessary `dict` call (rewrite as a literal)
"F401",
"E", "F", "W",
"RET",
"I",
"COM",
"TCH",
"ANN",
"W291",
"W293",
"D",
"UP004",
"UP006",
"UP008",
"UP015",
"UP024",
"UP028",
"UP030",
"UP031",
"UP032",
"UP033",
"UP034",
"UP039",
"UP035", # Import from `collections.abc` instead: `Generator|Iterator`
# "TCH003", Move standard library import `...` into a type-checking block
]
lint.unfixable = []
# Exclude a variety of commonly ignored directories.
exclude = [
"setup.py",
"whitelist.py", # for vulture
# "pyglossary/ui/gtk4_utils/*",
# "pyglossary/ui/gtk3_utils/*",
"pyglossary/plugins/babylon_bgl/bgl_gzip.py",
"pyglossary/plugins/testformat.py",
# "pyglossary/plugin_lib/*",
"pyglossary/ui/gtk*_utils/__init__.py",
"pyglossary/ui/ui_qt.py",
"pyglossary/ui/progressbar/",
"pyglossary/reverse.py",
"wcwidth*",
".direnv",
".eggs",
".git",
".mypy_cache",
".nox",
".pants.d",
".ruff_cache",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"venv",
]
# Allow unused variables when underscore-prefixed.
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
[tool.ruff.lint.per-file-ignores]
"slob.py" = [
"PERF203", # `try`-`except` within a loop incurs performance overhead, FIXME
]
"html_dir.py" = [
"C901", # `...` is too complex
]
"zimfile.py" = [
"C901", # `...` is too complex
]
"iupac_goldbook.py" = [
"C901", # `...` is too complex
]
"pyglossary/plugins/babylon_bgl/*.py" = [
"C901", # `...` is too complex
]
"pyglossary/html_utils.py" = ["RUF003"]
"persian_utils.py" = ["RUF001"]
"ru.py" = ["RUF001", "RUF003"]
"pyglossary/plugins/dikt_json.py" = ["RUF003"]
"pyglossary/plugin_lib/*.py" = [
"ANN",
"PT018", # Assertion should be broken down into multiple parts
"D",
"RUF015", # Prefer `next(zip(*_list, strict=False))` over single element slice
]
"scripts/wiki-formats.py" = ["E501"]
"pyglossary/io_utils.py" = ["ANN"]
"pyglossary/plugins/babylon_bgl/bgl_reader_debug.py" = ["ANN", "FURB"]
"pyglossary/ui/*.py" = ["ANN", "T201", "PERF203"]
"pyglossary/ui/*/*.py" = ["ANN", "T201", "PERF203"]
"tests/*.py" = ["ANN", "T201"]
"*_test.py" = [
"ANN",
"T201",
"RUF001", # String contains ambiguous ... (ARABIC LETTER ...). Did you mean `l` ...
]
"test.py" = ["ANN", "T201"]
"scripts/*.py" = ["ANN", "T201", "INP001"]
"scripts/*/*.py" = ["ANN", "T201", "INP001"]
"doc/lib-examples/*.py" = ["ANN", "ERA", "INP"]
[tool.ruff.format]
quote-style = "double"
indent-style = "tab"
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 20
[tool.mypy]
exclude = [
# '.*/plugin_lib/.*',
]
[tool.refurb]
ignore = [
101, # Replace `with open(x, ...) as f: y = f.read()` with `y = Path(x).read_bytes()`
103, # Replace `with open(x, ...) as f: f.write(y)` with `Path(x).write_bytes(y)`
104, # Replace `os.getcwd()` with `Path.cwd()`
107, # Replace `try: ... except OSError: pass` with `with suppress(OSError): ...`
141, # Replace `os.path.exists(x)` with `Path(x).exists()`
144, # Replace `os.remove(x)` with `Path(x).unlink()`
146, # Replace `os.path.isfile(x)` with `Path(x).is_file()`
150, # Replace `os.makedirs(x)` with `Path(x).mkdir(parents=True)`
155, # Replace `os.path.getsize(x)` with `Path(x).stat().st_size`
]
# refurb has no exclude param!
#exclude = [
# "pyglossary/plugin_lib/readmdict.py",
#]
#load = ["some_module"]
#quiet = true
[tool.pylint.messages_control]
max-line-length = 88
disable = [
"no-member",
"no-name-in-module",
"missing-module-docstring",
"bad-indentation",
"invalid-name",
"logging-fstring-interpolation",
"too-many-arguments",
"broad-exception-caught",
"missing-function-docstring",
"unused-argument",
"import-outside-toplevel",
"missing-class-docstring",
"too-many-instance-attributes",
"fixme",
"redefined-builtin",
"pointless-statement",
"abstract-method",
"unidiomatic-typecheck",
"attribute-defined-outside-init",
"unspecified-encoding",
"super-init-not-called",
"redefined-slots-in-subclass",
"redefined-outer-name",
"wrong-import-position",
"too-few-public-methods",
"too-many-lines",
"too-many-public-methods",
"too-many-statements",
"too-many-locals",
"too-many-branches",
"too-many-return-statements",
"unused-import",
"import-error",
"protected-access",
"consider-using-with",
"disallowed-name",
"useless-return",
"method-cache-max-size-none",
"global-statement",
"R0801", # Similar lines in 2 files
"ungrouped-imports", # C0412: Imports from package pyglossary are not grouped
"inconsistent-return-statements", # R1710: Either all return statements in a function should return an expression, or none of them should
"too-many-ancestors", # R0901: Too many ancestors
]
[tool.pylint.master]
ignore-paths = [
"^pyglossary/reverse.py$",
"^pyglossary/ui/progressbar/.*",
"^pyglossary/ui/ui_qt.py$",
"^pyglossary/ui/wcwidth/",
]
[tool.vulture]
exclude = [
"build/",
"tests/",
"*_test.py",
"test.py",
"pyglossary/ui/",
"*_types.py",
"pyglossary/ui_type.py",
"pyglossary/reverse.py",
"doc/lib-examples/",
"pyglossary/plugin_lib/",
"pyglossary/text_utils_extra.py",
]
# ignore_decorators = ["@app.route", "@require_*"]
ignore_names = [
"_*",
"Generator",
"GLOSSARY_API_VERSION",
# "Iterable", "AnyStr",
# "RawEntryType",
# "EntryListType",
]
make_whitelist = true
min_confidence = 60
# paths = []
sort_by_size = false
verbose = false
[tool.import-analyzer]
exclude = [
"pyglossary/ui/wcwidth/",
]