Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
291 lines (257 loc) · 9.27 KB
/
Copy pathpyproject.toml
File metadata and controls
291 lines (257 loc) · 9.27 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
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
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
name = "mtgjson5"
version = "5.3.0"
description = "Magic: the Gathering compiled database generator"
readme = "README.md"
license = "MIT"
requires-python = ">=3.11"
authors = [
{ name = "Zach Halpern", email = "zach@mtgjson.com" },
]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"Natural Language :: English",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows :: Windows 10",
"Operating System :: Microsoft :: Windows :: Windows 11",
"Operating System :: Unix",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python",
"Topic :: Database",
"Topic :: Software Development :: Version Control :: Git",
]
keywords = [
"Big Data",
"Card Games",
"Collectible",
"Database",
"JSON",
"MTG",
"MTGJSON",
"Trading Cards",
"Magic: The Gathering",
]
dependencies = [
"mtg-sealed-choices @ https://github.com/mtgjson/mtg-sealed-content/archive/4b7cd71df0cd08a4f6aaf366a3169c662bea940c.tar.gz#subdirectory=compiler",
"aiohttp==3.14.5",
"beautifulsoup4==4.15.0",
"boto3==1.43.116",
"botocore==1.43.116",
"gevent==26.9.0",
"GitPython==3.2.1",
"ijson==3.6.0",
"mergedeep==1.3.4",
"mkmsdk==0.7.0",
"numpy==2.4.6",
"orjson==3.13.0",
"polars==1.44.2",
"polars-hash==0.9.3",
"pydantic==2.14.1",
"python-dateutil==2.9.0.post0",
"PyYAML==6.0.3",
"ratelimit==2.2.1",
"requests-cache[yaml]==1.3.3",
"psutil>=5.9",
"requests==2.34.2",
"singleton-decorator==1.0.0",
"typing_extensions==4.16.0",
"urllib3==2.8.0",
]
[project.optional-dependencies]
dev = [
"ruff==0.17.1",
"mypy==2.4.0",
"pylint==4.1.3",
"pytest==9.1.1",
"pytest-cov==7.1.0",
"pytest-mock==3.17.0",
"pytest-recording==0.14.0",
"tox==4.67.1",
"tox-uv==1.37.0",
"vcrpy==8.3.0",
"PyYAML==6.0.3",
"requests-cache[yaml]==1.3.3",
"types-PyYAML==6.0.12.20260906",
"types-python-dateutil==2.9.0.20261021",
"types-redis==4.6.0.20241004",
"types-requests==2.33.0.20261006",
"types-ujson==5.10.0.20250822",
]
[tool.uv]
environments = ["platform_python_implementation == 'CPython'"]
[tool.setuptools.packages.find]
include = ["mtgjson5*"]
[tool.setuptools.package-data]
mtgjson5 = ["resources/*"]
# --- Ruff (replaces black, isort, flake8) ---
[tool.ruff]
line-length = 120
target-version = "py311"
[tool.ruff.lint]
select = [
"E", # pycodestyle errors (indentation, whitespace, syntax)
"F", # pyflakes (unused imports, undefined names, redefined variables)
"W", # pycodestyle warnings (whitespace, line breaks)
"I", # isort (import sorting)
"UP", # pyupgrade (modern Python syntax)
"B", # flake8-bugbear (common bugs, mutable default args)
"SIM", # flake8-simplify (unnecessary complexity)
"C4", # flake8-comprehensions (optimize comprehensions)
"RUF", # ruff-specific rules (unused noqa, mutable class defaults)
"PIE", # flake8-pie (unnecessary pass, duplicate fields)
"T20", # flake8-print (no print() in production code)
"PT", # flake8-pytest-style (pytest best practices)
"PERF", # perflint (performance anti-patterns)
"TCH", # flake8-type-checking (TYPE_CHECKING imports)
"N", # pep8-naming (naming conventions)
]
ignore = [
"E402", # module level import not at top of file
"E501", # line too long (ruff format handles wrappable code; this only catches long strings/comments)
"E712", # allow == False comparisons (needed for Polars expressions)
"N815", # mixedCase variables (Pydantic model fields like setCode are intentional)
"RUF001", # ambiguous unicode characters (MTG card symbols are intentional)
"RUF012", # mutable class variable without ClassVar (Pydantic models handle this)
"B008", # function call in default args (singletons are intentional)
"B024", # abstract class without abstract methods (base class pattern)
"PERF401", # use list comprehension (often less readable for complex appends)
"SIM108", # use ternary operator (often less readable)
"SIM115", # use context manager for open (can't always apply across branches)
"TC001", # move import into TYPE_CHECKING (can break runtime)
"TC002", # move third-party import into TYPE_CHECKING
"TC003", # move stdlib import into TYPE_CHECKING
"TC004", # move import out of TYPE_CHECKING (false positives)
"TC010", # move typing import into TYPE_CHECKING
]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # imported but unused (re-exports in __init__ are intentional)
"scripts/*.py" = ["T201"] # print() is expected in CLI scripts
"mtgjson5/pipeline/stages/sealed.py" = ["N801", "N802"] # lowercase class/method names match reference product_classes.py
# --- mypy ---
[tool.mypy]
python_version = "3.11"
exclude = "(cache|pipeline)\\.py$"
check_untyped_defs = true
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_subclassing_any = true
follow_imports = "normal"
incremental = true
ignore_missing_imports = true
strict_optional = true
warn_no_return = true
warn_redundant_casts = true
warn_return_any = true
warn_unused_ignores = true
[[tool.mypy.overrides]]
module = "pkg.generated_code.*"
ignore_errors = true
[[tool.mypy.overrides]]
module = "concurrent.futures"
ignore_errors = true
[[tool.mypy.overrides]]
module = "mtgjson5.models.submodels"
disable_error_code = ["misc"]
[[tool.mypy.overrides]]
module = "mtgjson5.models.utils"
disable_error_code = ["union-attr", "operator", "arg-type"]
[[tool.mypy.overrides]]
module = "mtgjson5.models.sealed"
disable_error_code = ["typeddict-item", "no-any-return"]
[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_defs = false
disallow_untyped_calls = false
disable_error_code = ["arg-type", "call-arg", "index", "operator", "no-any-return", "dict-item", "attr-defined"]
# --- pytest ---
[tool.pytest.ini_options]
# -q (quiet mode): reduces output verbosity to show only test results, keeping CI logs clean
addopts = "-q --import-mode=importlib"
# VCR cassette recording modes:
# - Local development: use --record-mode=once to record new cassettes
# - CI/offline: use --record-mode=none to ensure no network access (enforced in tox config)
# The vcr_config fixture in tests/conftest.py also enforces 'none' mode when MTGJSON_OFFLINE_MODE is set
# --- pylint ---
[tool.pylint.master]
persistent = true
extension-pkg-allow-list = ["orjson", "numpy", "aiohttp"]
[tool.pylint."messages control"]
disable = [
"broad-except",
"cyclic-import",
"duplicate-code",
"global-statement",
"import-outside-toplevel",
"invalid-name",
"line-too-long",
"logging-format-interpolation",
"logging-fstring-interpolation",
"no-else-return",
"no-name-in-module",
"protected-access",
"redefined-builtin",
"redefined-outer-name",
"singleton-comparison",
"too-few-public-methods",
"too-many-arguments",
"too-many-branches",
"too-many-instance-attributes",
"too-many-lines",
"too-many-locals",
"too-many-nested-blocks",
"too-many-public-methods",
"too-many-return-statements",
"too-many-statements",
"unspecified-encoding",
"unsubscriptable-object",
"unused-argument",
"used-before-assignment",
"wrong-import-order",
"wrong-import-position",
"too-many-positional-arguments",
"unidiomatic-typecheck",
"missing-class-docstring",
"missing-function-docstring",
"import-error",
]
[tool.pylint.reports]
output-format = "colorized"
[tool.pylint.basic]
good-names = ["f", "i", "j", "k", "_"]
no-docstring-rgx = "__.*__|test_.*"
[tool.pylint.miscellaneous]
notes = ["FIXME", "TODO"]
[tool.pylint.variables]
dummy-variables-rgx = "_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)"
# --- tox ---
[tool.tox]
env_list = ["format-check", "lint", "mypy", "unit"] # default (CI)
labels = { dev = ["format", "lint", "mypy", "unit"] } # local development
[tool.tox.env_run_base]
set_env = { PYTHONPATH = "{toxinidir}" }
extras = ["dev"]
[tool.tox.env.format]
description = "Format code and sort imports (auto-fix)"
commands = [["ruff", "format", "mtgjson5/", "tests/"], ["ruff", "check", "--fix", "--select", "I", "mtgjson5/", "tests/"]]
[tool.tox.env.format-check]
description = "Check formatting and import sorting (fails if unformatted)"
commands = [["ruff", "format", "--check", "mtgjson5/", "tests/"], ["ruff", "check", "--select", "I", "mtgjson5/", "tests/"]]
[tool.tox.env.mypy]
description = "mypy static type checking only"
commands = [["mypy", "{posargs:mtgjson5/}", "--explicit-package-bases"], ["mypy", "tests/", "--explicit-package-bases"]]
[tool.tox.env.lint]
description = "Run linting tools"
commands = [["ruff", "check", "mtgjson5/", "tests/"], ["pylint", "mtgjson5/"], ["pylint", "tests/"]]
[tool.tox.env.unit]
description = "Run unit tests with coverage and mypy type checking"
set_env = { PYTHONPATH = "{toxinidir}", MTGJSON_OFFLINE_MODE = "1" }
commands = [["pytest", "tests/", "--record-mode=none"]]