-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
145 lines (129 loc) · 4.85 KB
/
Copy pathpyproject.toml
File metadata and controls
145 lines (129 loc) · 4.85 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
[project]
name = "ronin"
version = "0.4.0"
requires-python = ">=3.14"
dependencies = [
"starlette>=0.52.1",
"uvicorn[standard]>=0.40.0",
"pydantic>=2.12.5",
"pydantic-settings>=2.0",
"httpx>=0.28.1",
"pyyaml>=6.0.0",
"mahjong==2.0.0.dev1",
"msgpack>=1.1.2",
"xiangting>=5.0.0",
"jinja2>=3.1.6",
"python-multipart>=0.0.20",
"bcrypt>=5.0.0",
"anyio>=4.0.0",
"structlog>=24.4.0",
]
[dependency-groups]
dev = [
"pytest>=9.0.2",
"pytest-asyncio>=1.3.0",
"pytest-cov>=7.0.0",
"pytest-timeout>=2.4.0",
"ruff>=0.15.1",
"ty>=0.0.17",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["backend/lobby", "backend/game", "backend/shared"]
[tool.pytest.ini_options]
testpaths = ["backend"]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
python_files = "test_*.py"
addopts = "-p no:warnings --no-header --tb=short -qq --cov --cov-report=term:skip-covered"
timeout = 10
[tool.ruff]
src = ["backend"]
target-version = "py314"
line-length = 120
[tool.ruff.lint]
select = ["ALL"]
ignore = [
"D", # Dockstring styles
"EM101", # Exception must not use a string literal
"EM102", # Exception must not use an f-string literal
"TRY003", # Avoid specifying long messages outside exception class
"G004", # Convert to lazy `%` formatting
"TD", # TODO comments
"FIX002",# Line contains TODO
]
[tool.ruff.lint.per-file-ignores]
"{test_*.py,conftest.py,**/tests/**/helpers.py,**/tests/**/helpers/*.py,**/tests/**/mocks/*.py}" = [
"ANN", # Missing type annotation
"ARG", # Unused function arguments
"PLR0913", # Too many arguments (test factories)
"PLR0915", # Too many statements
"PLR2004", # Magic value used in comparison
"S101", # Use of `assert` detected
"S105", # Possible hardcoded password
"S106", # Possible hardcoded password assigned to argument
"SLF001", # Private member accessed
]
# Base class methods define the interface contract; parameters are unused in the default implementation
"backend/scripts/*.py" = ["T201", "PLR2004", "S106"]
"backend/game/logic/ai_player.py" = ["ARG002"]
"backend/game/logic/shanten.py" = ["TID251"]
[tool.ruff.lint.flake8-type-checking]
runtime-evaluated-base-classes = ["pydantic.BaseModel", "pydantic_settings.BaseSettings"]
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"mahjong.shanten".msg = "Use game.logic.shanten instead of mahjong.shanten directly."
[tool.ty.environment]
python-version = "3.14"
[tool.ty.src]
include = ["backend"]
[tool.ty.rules]
# Promote all non-error default rules to error for stricter checking
division-by-zero = "error" # default: ignore
possibly-unresolved-reference = "error" # default: warn
possibly-missing-attribute = "error" # default: warn
possibly-missing-import = "error" # default: warn
possibly-missing-implicit-call = "error" # default: warn
deprecated = "error" # default: warn
redundant-cast = "error" # default: warn
ineffective-final = "error" # default: warn
ambiguous-protocol-member = "error" # default: warn
invalid-ignore-comment = "error" # default: warn
ignore-comment-unknown-rule = "error" # default: warn
invalid-legacy-positional-parameter = "error" # default: warn
unused-ignore-comment = "error" # default: warn
unused-type-ignore-comment = "error" # default: warn
[[tool.ty.overrides]]
include = ["**/test_*.py", "**/conftest.py"]
[tool.ty.overrides.rules]
# relax rules for test files - tests often use dynamic fixtures, mocks,
# and untyped external libraries (mahjong) that produce Unknown types
# Note: invalid-argument-type is ignored because Pydantic validators coerce
# list -> tuple at runtime, making tests functionally correct
# Note: possibly-missing-attribute and unresolved-attribute are ignored because
# tests often access union type members after type-narrowing assertions that ty doesn't track
# Note: missing-argument is ignored because pydantic-settings classes read
# required fields from environment variables at runtime
possibly-unresolved-reference = "warn"
possibly-missing-attribute = "ignore"
unresolved-attribute = "ignore"
invalid-argument-type = "ignore"
missing-argument = "ignore"
invalid-parameter-default = "warn"
unused-ignore-comment = "ignore"
[tool.coverage.run]
source = ["backend"]
omit = ["**/tests/*", "**/test_*", "backend/scripts/*", "backend/game/logic/ai_player.py", "backend/game/logic/ai_player_controller.py", "backend/debug.py", "backend/shared/logging.py", "backend/game/replay/external/tenhou.py"]
[tool.coverage.report]
show_missing = true
skip_covered = true
exclude_lines = [
"pragma: no cover",
"if __name__ == .__main__.",
"if TYPE_CHECKING:",
'^\\s*\\.\\.\\.\\s*$',
'^\\s*pass\\s*$',
"@(abc\\.)?abstractmethod",
]
fail_under = 100