-
Notifications
You must be signed in to change notification settings - Fork 63
/
pyproject.toml
191 lines (168 loc) · 5.44 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
[tool.pyright]
include = [
"src/",
"hammeraddons/src/",
]
exclude = [
"**/__pycache__"
]
venv = "BEE2-12"
stubPath = "src/" # Use our module for stubs.
# We want to do conversions when setting.
reportPropertyTypeMismatch = false
pythonVersion = "3.8"
strictParameterNoneValue = false
[tool.isort]
sections=["FUTURE", "TYPING", "FRAMEWORK", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
known_framework = ["tkinter", "tkinter.ttk", "tkinter.messagebox"]
extra_standard_library = ["importlib_resources", "exceptiongroup"]
known_typing = ["typing", "typing_extensions"]
no_lines_before = ["TYPING", "FRAMEWORK", "STDLIB"]
known_third_party = ["hammeraddons"]
multi_line_output = 5 # hanging grid grouped
line_length = 80
lines_after_imports = 2
use_parentheses = true
order_by_type = true
include_trailing_comma = true
from_first = true
combine_as_imports = true
src_paths = ["src"]
[tool.ruff]
line-length = 127
target-version = "py38"
exclude = [
"src/perlin.py",
"src/precomp/conditions/cutoutTile.py",
]
[tool.ruff.lint]
select = [
"E", "UP", "F", "C4", "ANN", "B", "PIE", "RUF",
"PLC", "PLE", "PLW", # Pylint.
"TRIO",
"TCH005", # Empty type-checking block.
]
allowed-confusables = [
"×", # Multiplication sign
]
extend-ignore = [
"E201", "E202", "E203", "E221", "E222", "E241", # Allow extra whitespace.
"E226", # Allow 4*6 + 8
"E402", # Allow module level import later in the file.
"E721", # Allow using type(x) is Class
"E731", # Lambda assignment used intentionally for callbacks.
"F403", # Allow *-imports,
"F405", # name may be undefined, or defined from star imports: module
# Flake8-annotations.
# Type annotations for self & cls are not important.
"ANN101",
"ANN102",
"ANN401", # Allow typing.Any
# Ruff:
"RUF022", # Sorting __all__
"RUF023", # Sorting __slots__
"RUF005", # Unpack instead of concat triggers on Vec.
"RUF100", # Sometimes use # noqa for other linters
"RUF027", # Catches TransToken using {}-formatting without an f-string.
# PyLint:
"PLW0603", # Allow use of global statement.
"PLC0414", # import x as x is used for type checking.
"PLE1205", # Too many arguments for logging, doesn't handle our format
"PLC0415", # Imports not at top level are used for specific reasons
"PLW2901", # Allow redefining loop var inside the loop.
"PLW0120", # for-else with return/break inside is just stylistic, exactly equivalent.
# Flake8-Trio:
"TRIO115", # Stick with sleep(0) instead of lowlevel.checkpoint(), for now?
# Pyupgrade:
# Keep using typing's types even with __future__.annotations.
"UP006", "UP007", "UP035",
# Flake8-bugbear:
# Loop control var not used, triggers on unpackings.
"B007",
# Flake8-pie:
# Prefer to use pass in empty functions, even if docstring is present
"PIE790",
# Allow aliases for enum values, used often.
"PIE796",
# Start arg for range is sometimes clearer
"PIE808",
]
[tool.ruff.lint.flake8-bugbear]
extend-immutable-calls = [
# Objects which are immutable, or close enough that it's fine to be in func defaults.
"srctools.math.FrozenVec", "srctools.math.FrozenAngle", "srctools.math.FrozenMatrix",
# Image handle variants, all publically frozen.
"app.img.Handle.background", "app.img.Handle.blank", "app.img.Handle.builtin",
"app.img.Handle.color", "app.img.Handle.composite", "app.img.Handle.crop",
"app.img.Handle.error", "app.img.Handle.file", "app.img.Handle.ico_loading",
"app.img.Handle.ico_none", "app.img.Handle.overlay_text", "app.img.Handle.parse",
"app.img.Handle.parse_uri", "app.img.Handle.resize", "app.img.Handle.sprite", "app.img.Handle.with_alpha_stripped",
# Translation token variants.
"transtoken.TransToken.parse", "transtoken.TransToken.ui", "transtoken.TransToken.ui_plural",
"transtoken.TransToken.join", "transtoken.TransToken.from_valve",
"transtoken.TransToken.untranslated",
"transtoken.TransToken.list_and", "transtoken.TransToken.list_or",
"tkMarkdown.MarkdownData.text",
# Cast is not really a function call, just returns the arg.
"typing.cast",
"srctools.logger.get_logger",
]
[tool.mypy]
mypy_path = "$MYPY_CONFIG_FILE_DIR/hammeraddons/src/"
allow_redefinition = true
check_untyped_defs = true
extra_checks = true
strict_equality = true
strict_optional = true
local_partial_types = true
implicit_reexport = false
# strict = true # Only when overrides is gone.
warn_unused_ignores = true
warn_redundant_casts = true
warn_return_any = true
warn_no_return = true
# warn_unreachable = true # TODO: Bunch of errors still
disallow_incomplete_defs = true
disallow_untyped_defs = true
disallow_untyped_decorators = true
disallow_untyped_calls = true
disallow_any_generics = false
enable_error_code = [
'mutable-override',
'narrowed-type-not-subtype',
'redundant-expr',
'redundant-self',
'truthy-bool',
'truthy-iterable',
'unimported-reveal',
'unreachable',
'unused-awaitable',
'comparison-overlap',
]
[[tool.mypy.overrides]]
# TODO: make these pass strict checks.
module = [
'app.gameMan',
'app.backup',
'app.contextWin',
'app.UI',
'precomp.conditions._scaffold_compat',
'precomp.bottomlessPit',
'precomp.fizzler',
'precomp.tiling',
'ui_tk.check_table',
'FakeZip',
]
strict_optional = false
disallow_incomplete_defs = false
disallow_untyped_defs = false
disallow_untyped_decorators = false
disallow_untyped_calls = false
[[tool.mypy.overrides]]
# No stubs yet.
module = ['pyglet.*', 'mistletoe.*']
ignore_missing_imports = true
# Dead code, needs to be rewritten.
[[tool.mypy.overrides]]
module = 'precomp.conditions.cutoutTile'
ignore_errors = true