-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpyproject.toml
More file actions
309 lines (279 loc) · 9.75 KB
/
pyproject.toml
File metadata and controls
309 lines (279 loc) · 9.75 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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
[build-system]
requires = ["uv_build>=0.10.11,<0.11.0"]
build-backend = "uv_build"
[project]
name = "modmail.py"
description = "A Discord Modmail bot."
version = "5.0a1"
authors = [
{name = "Taaku18", email = "taku@modmail.dev"},
]
readme = "README.md"
requires-python = "==3.14.*"
license = "AGPL-3.0-or-later"
license-files = ["LICEN[CS]E*"]
keywords = ["discord", "discord-bot", "modmail", "python", "discord.py", "discord-modmail"]
classifiers = [
"Development Status :: 3 - Alpha",
"Framework :: AsyncIO",
"Environment :: Console",
"Natural Language :: English",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.14",
"Topic :: Communications :: Chat",
"Topic :: Communications :: Conferencing",
"Typing :: Typed",
]
dependencies = [
"discord.py==2.7.1", # Ensure to keep in sync with [project.optional-dependencies.speed]
"rich~=14.3.0",
"pydantic~=2.12.0",
"pydantic-settings~=2.13.0",
"python-dotenv~=1.2.2",
"packaging", # For version parsing, should be installed by default but just in case
"pyyaml~=6.0.3",
"fluent-runtime~=0.4.0",
]
[project.optional-dependencies]
speed = [
"discord.py[speed]==2.7.1",
"uvloop>=0.22.1; platform_system != \"Windows\"", # NOTE: uvloop 0.22.1 has known issues on Python 3.14 (debug mode crash), fallback to asyncio is handled in bot.py
]
sqlite = [
"sqlalchemy[asyncio,aiosqlite]~=2.0.49",
"alembic~=1.18.0",
]
postgresql = [
"sqlalchemy[asyncio,postgresql-asyncpg]~=2.0.49",
"alembic~=1.18.0",
]
mysql = [
"sqlalchemy[asyncio,asyncmy]~=2.0.49",
"alembic~=1.18.0",
]
mariadb = [
"sqlalchemy[asyncio,asyncmy]~=2.0.49",
"alembic~=1.18.0",
]
mongodb = [
"beanie[zstd]~=2.0.1",
]
[dependency-groups]
dev = [
"ruff==0.15.9", # When updating ruff version, update it in .pre-commit-config.yaml too
"pyright==1.1.408",
"pre-commit<5,>=4.5.1", # When updating pre-commit version, update it in the tox "lint" section too
"python-dotenv>=1.2.2", # TODO: .env isn't supported/tested yet
# When updating pytest plugins, update it below in the pytest "required_plugins" section too
# TODO: unit testing and tox are currently disabled
"tox<5,>=4.52.0", # When updating tox version, update it below in the [tool.tox] section too
"pytest==9.0.2",
"pytest-mock==3.15.1",
"pytest-asyncio==1.3.0",
"pytest-cov==7.1.0",
"pip", # For IDE detecting installed packages
]
docs = [
"zensical==0.0.31",
"mkdocstrings[python]==1.0.3",
"griffe-pydantic==1.3.1",
]
debug = [
"jishaku~=2.6.3",
]
packaging = [
"pyinstaller~=6.19.0",
]
# TODO: set up git hooks and configure pyinstaller
# this command kind of works: uv run pyinstaller --onefile --nowindow --clean --name modmail --copy-metadata modmail.py --collect-all modmail --hidden-import=logging.config start.py
[project.urls]
Documentation = "https://docs.modmail.dev"
Repository = "https://github.com/modmail-dev/modmail"
Issues = "https://github.com/modmail-dev/modmail/issues"
Changelog = "https://github.com/modmail-dev/Modmail/blob/master/CHANGELOG.md"
Funding = "https://buymeacoffee.com/modmaildev"
[tool.uv]
default-groups = [] # Don't install any optional dependencies by default
[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true
[tool.uv.build-backend]
module-name = "modmail"
module-root = "" # default expects src/, we have everything in the root
[tool.ruff]
line-length = 115
preview = true
namespace-packages = ["modmail", "modmail/cogs"]
[tool.ruff.format]
docstring-code-format = true
docstring-code-line-length = 105
line-ending = "lf"
[tool.ruff.lint]
select = [
"E", "W", # pycodestyle
"F", # pyflakes
"ANN", # flake8-annotations
"ASYNC", # flake8-async
"S", # flake8-bandit
"B", # flake8-bugbear
"A", # flake8-builtins
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"G", # flake8-logging-format
"PIE", # flake8-pie
"T20", # flake8-print
"PT", # flake8-pytest-style
"RSE", # flake8-raise
"RET", # flake8-return
"SIM", # flake8-simplify
"TC", # flake8-type-checking
"PTH", # flake8-use-pathlib
"I", # isort
"N", # pep8-naming
"PERF", # Perflint
"DOC", # pydoclint (preview)
"D", # pydocstyle
"PGH", # pygrep-hooks
"PL", # pylint
"UP", # pyupgrade
"FURB", # refurb (preview)
"RUF", # Ruff-specific rules
]
ignore = [
# The following 6 rules conflicts with ruff formatter: https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"W191",
"E111",
"E114",
"E117",
"D206",
"D300",
"ANN401", # Disallow `Any` type
"S101", # Use of assert detected
"SIM102", # Single `if` instead of nested `if`
"SIM108", # Use of ternary instead of `if`-`else`
"DOC502", # Raised exception is not explicitly raised (preview)
"PLC0415", # `import` should be at the top-level of a file (preview)
"PLR0915", # Too many statements in function
"PLR0913", # Too many arguments
"PLR0912", # Too many branches
"PLR0911", # Too many return statements
"PLR0904", # Too many public methods
"PLR1702", # Too many nested blocks (preview)
"PLR5501", # Use `elif` instead of `else` then `if`
"PLW2901", # `for` loop variable `value` overwritten by assignment target
"PLR6301", # Method could be a function, class method, or static method (preview)
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF067", # `__init__` module should only contain docstrings and re-exports
]
[tool.ruff.lint.flake8-type-checking]
# These base classes evaluate annotations at runtime (via Pydantic model construction /
# SQLAlchemy mapper configuration), so imports used only in their subclasses' field
# annotations must remain as runtime imports, not be moved to TYPE_CHECKING blocks.
runtime-evaluated-base-classes = [
"pydantic.BaseModel",
"pydantic_settings.BaseSettings",
"beanie.Document",
"sqlalchemy.orm.DeclarativeBase",
"modmail.backends.sql.models.base.SQLBase",
]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F403"] # F403: 'from module import *' used; unable to detect undefined names
"ftl_finder.py" = ["T201"] # T201: Use of print
"tests/*" = ["D107", "D101", "D100", "D105", "D202", "D102", "D104", "D103", "PLR2004", "PLR0917", "PLC2701"] # D*: Missing doc strings, PLR2004: Compare magic number, PLC2701: Private name import from external module
"modmail/backends/sql/migrations/versions/*" = ["D415", "UP"] # D415: First line should end with a period, question mark, or exclamation point
"modmail/cogs/*/commands/*.py" = ["TC002"] # discord and commands are always kept as runtime imports in cogs
"modmail/cogs/*/listeners/*.py" = ["TC002"] # discord and commands are always kept as runtime imports in cogs
"scripts/*.py" = ["S404", "S603", "S607"] # Scripts intentionally use subprocess to invoke CLI tools
[tool.ruff.lint.isort]
required-imports = ["from __future__ import annotations"]
combine-as-imports = true
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.pycodestyle]
max-doc-length = 105
max-line-length = 115
[tool.ruff.lint.pylint]
allow-dunder-method-names = ["__locale_str__"]
[tool.pyright]
exclude = [
"**/__pycache__",
"**/.tox",
"**/venv",
"**/env",
"**/.venv",
"**/.env",
"dist",
"docs",
"tests", # Tests are disabled for now
]
reportUnnecessaryTypeIgnoreComment = "warning"
reportPropertyTypeMismatch = "error"
pythonVersion = "3.14"
pythonPlatform = "All"
typeCheckingMode = "strict"
executionEnvironments = [
{ root = "tests", reportPrivateUsage = "none", reportFunctionMemberAccess = "none", reportWildcardImportFromLibrary = "none" },
]
venvPath = "."
venv = ".venv"
[tool.pytest.ini_options]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "module"
asyncio_default_test_loop_scope = "module"
addopts = "--cov=modmail --cov=modmail/cogs --cov-report html"
testpaths = ["tests"]
required_plugins = ["pytest-mock==3.15.1", "pytest-asyncio==1.3.0", "pytest-cov==7.0.0"]
filterwarnings = [
"ignore:.*'audioop' is deprecated.*:DeprecationWarning", # discord.py uses audioop, which is deprecated
]
[tool.coverage.run]
omit = [
"*/migrations/*",
]
[tool.coverage.report]
exclude_also = [ # Exclude files from coverage report, regex patterns
"if TYPE_CHECKING:",
"if os\\.environ\\.get\\(\"PYTEST_VERSION\"\\) is None:",
"if __name__ == \"__main__\":",
"raise NotImplementedError",
"raise AssertionError",
]
[tool.tox]
requires = ["tox<5,>=4.52.0"]
envlist = ["3.14", "lint", "type"]
[tool.tox.env_run_base]
description = "Run test under {base_python}"
groups = ["all", "dev"]
commands = [["pytest"]]
[tool.tox.env.lint]
description = "run linters (pre-commit)"
skip_install = true
deps = ["pre-commit<5,>=4.5.1"]
commands = [["pre-commit", { replace = "posargs", default = ["run", "--all-files"], extend = true} ]]
[tool.tox.env.type]
description = "run type check (pyright)"
groups = ["all"]
commands = [
["pyright", { replace = "posargs", extend = true}],
]
[tool.alembic]
script_location = "modmail/backends/sql/migrations"
prepend_sys_path = ["."]
[[tool.alembic.post_write_hooks]]
name = "ruff-format"
type = "module"
module = "ruff"
options = "format REVISION_SCRIPT_FILENAME"
[[tool.alembic.post_write_hooks]]
name = "ruff-check"
type = "module"
module = "ruff"
options = "check --fix REVISION_SCRIPT_FILENAME"