disnake

Форк
0
/
pyproject.toml 
398 строк · 10.9 Кб
1
# SPDX-License-Identifier: MIT
2

3
[build-system]
4
requires = ["setuptools>=61"]
5
build-backend = "setuptools.build_meta"
6

7
[project]
8
name = "disnake"
9
description = "A Python wrapper for the Discord API"
10
readme = "README.md"
11
authors = [
12
  { name = "Disnake Development" }
13
]
14
requires-python = ">=3.8"
15
keywords = ["disnake", "discord", "discord api"]
16
license = { text = "MIT" }
17
dependencies = [
18
    "aiohttp>=3.7.0,<4.0",
19
]
20
classifiers = [
21
    "Development Status :: 5 - Production/Stable",
22
    "License :: OSI Approved :: MIT License",
23
    "Intended Audience :: Developers",
24
    "Natural Language :: English",
25
    "Operating System :: OS Independent",
26
    "Programming Language :: Python :: 3.8",
27
    "Programming Language :: Python :: 3.9",
28
    "Programming Language :: Python :: 3.10",
29
    "Programming Language :: Python :: 3.11",
30
    "Programming Language :: Python :: 3.12",
31
    "Topic :: Internet",
32
    "Topic :: Software Development :: Libraries",
33
    "Topic :: Software Development :: Libraries :: Python Modules",
34
    "Topic :: Utilities",
35
    "Typing :: Typed",
36
]
37
dynamic = ["version"]
38

39
[project.urls]
40
Changelog = "https://docs.disnake.dev/page/whats_new.html"
41
Documentation = "https://docs.disnake.dev/"
42
Repository = "https://github.com/DisnakeDev/disnake"
43

44
[project.optional-dependencies]
45
speed = [
46
    "orjson~=3.6",
47
    # taken from aiohttp[speedups]
48
    "aiodns>=1.1",
49
    "Brotli",
50
    'cchardet; python_version < "3.10"',
51
]
52
voice = [
53
    "PyNaCl>=1.3.0,<1.6",
54
]
55
docs = [
56
    "sphinx==7.0.1",
57
    "sphinxcontrib-trio~=1.1.2",
58
    "sphinx-hoverxref==1.3.0",
59
    "sphinx-autobuild~=2021.3",
60
    "sphinxcontrib-towncrier==0.3.2a0",
61
    "towncrier==23.6.0",
62
    "sphinx-notfound-page==0.8.3",
63
]
64
discord = ["discord-disnake"]
65

66
[tool.pdm.dev-dependencies]
67
nox = [
68
    "nox==2022.11.21",
69
]
70
tools = [
71
    "pre-commit~=3.0",
72
    "slotscheck~=0.16.4",
73
    "python-dotenv~=1.0.0",
74
    "check-manifest==0.49",
75
    "ruff==0.0.292",
76
]
77
changelog = [
78
    "towncrier==23.6.0",
79
]
80
codemod = [
81
    # run codemods on the respository (mostly automated typing)
82
    "libcst~=1.1.0",
83
    "black==23.9.1",
84
    "autotyping==23.2.0",
85
]
86
typing = [
87
    # this is not pyright itself, but the python wrapper
88
    "pyright==1.1.336",
89
    "typing-extensions~=4.8.0",
90
    # only used for type-checking, version does not matter
91
    "pytz",
92
]
93
test = [
94
    "pytest~=7.4.2",
95
    "pytest-cov~=4.0.0",
96
    "pytest-asyncio~=0.20.3",
97
    "looptime~=0.2",
98
    "coverage[toml]~=6.5.0",
99
]
100
build = [
101
    "wheel~=0.40.0",
102
    "build~=0.10.0",
103
    "twine~=4.0.2",
104
]
105

106
[tool.pdm.scripts]
107
black = { composite = ["lint black"], help = "Run black" }
108
docs = { cmd = "nox -Rs docs --", help = "Build the documentation for development" }
109
isort = { composite = ["lint isort"], help = "Run isort" }
110
lint = { cmd = "nox -Rs lint --", help = "Check all files for linting errors" }
111
pyright = { cmd = "nox -Rs pyright --", help = "Run pyright" }
112
setup_env = { cmd = "pdm install -d -G speed -G docs -G voice", help = "Set up the local environment and all dependencies" }
113
post_setup_env = { composite = ["python -m ensurepip --default-pip", "pre-commit install --install-hooks"] }
114
test = { cmd = "nox -Rs test --", help = "Run pytest" }
115

116
# legacy tasks for those who still type `task`
117
[tool.taskipy.tasks]
118
black = { cmd = "black", help = "Run black" }
119
docs = { cmd = "docs", help = "Build the documentation for development" }
120
isort = { cmd = "isort", help = "Run isort" }
121
lint = { cmd = "lint", help = "Check all files for linting errors" }
122
pyright = { cmd = "pyright", help = "Run pyright" }
123
setup_env = { cmd = "setup_env", help = "Setup the local environment and set up all dependencies" }
124
test = { cmd = "test", help = "Run pytest" }
125

126
[tool.taskipy.settings]
127
runner = "pdm run"
128

129
[tool.black]
130
line-length = 100
131
target-version = ["py38", "py39", "py310", "py311", "py312"]
132

133
[tool.isort]
134
profile = "black"
135
py_version = 38
136
line_length = 100
137
combine_as_imports = true
138
filter_files = true
139

140
[tool.ruff]
141
line-length = 100
142
target-version = "py38"
143
select = [
144
    # commented out codes are intended to be enabled in future prs
145
    "F", # pyflakes
146
    "E", "W", # pycodestyle
147
    # "D", # pydocstyle
148
    "D2",  # pydocstyle, docstring formatting
149
    "D4",  # pydocstyle, docstring structure/content
150
    # "ANN", # flake8-annotations
151
    "S", # flake8-bandit
152
    "B", # flake8-bugbear
153
    "C4", # flake8-comprehensions
154
    "DTZ", # flake8-datetimez
155
    # "EM", # flake8-errmsg
156
    "G", # flake8-logging-format
157
    # "RET", # flake8-return
158
    # "SIM", # flake8-simplify
159
    "TID251", # flake8-tidy-imports, replaces S404
160
    "TCH",    # flake8-type-checking
161
    "RUF",    # ruff specific exceptions
162
    "PT",     # flake8-pytest-style
163
    "Q",      # flake8-quotes
164
    "RSE",    # flake8-raise
165
    "T20",    # flake8-print
166
    "PGH",    # pygrep-hooks
167
    "PLC",    # pylint convention
168
    "PLE",    # pylint error
169
    # "PLR",    # pylint refactor
170
    "PLW",    # pylint warnings
171
    "TRY002", "TRY004", "TRY201", # tryceratops
172
]
173
ignore = [
174
    # star imports
175
    "F403",
176

177
    # pydocstyle
178
    "D203", # incompat with D211
179
    "D213", # multiline docstring should start on second line, incompatiable with D212
180
    "D400", # first line ends in period, does not work with `|coro|` etc.
181
    "D415", # same thing but punctuation in general
182
    "D416", # section name should end with a colon, incompatible with D406
183

184
    # unknown if this is actually an issue
185
    "RUF005", # might not be actually faster
186
    "RUF006", # might not be an issue/very extreme cases
187

188
    # calling subprocess with dynamic arguments is generally fine, the only way to avoid this is ignoring it
189
    "S603",
190

191
    # partial executable paths (i.e. "git" instead of "/usr/bin/git") are fine
192
    "S607",
193

194
    # ignore try-except-pass. Bare excepts are caught with E722
195
    "S110",
196

197
    # provide specific codes on type: ignore
198
    "PGH003",
199

200
    # typevar names don't match variance (we don't always want this)
201
    "PLC0105",
202

203
    # import aliases are fixed by isort
204
    "PLC0414",
205

206
    # outer loop variables are overwritten by inner assignment target, these are mostly intentional
207
    "PLW2901",
208

209
    # ignore imports that could be moved into type-checking blocks
210
    # (no real advantage other than possibly avoiding cycles,
211
    # but can be dangerous in places where we need to parse signatures)
212
    "TCH001",
213
    "TCH002",
214
    "TCH003",
215

216
    # temporary disables, to fix later
217
    "D205",   # blank line required between summary and description
218
    "D401",   # first line of docstring should be in imperative mood
219
    "D417",   # missing argument description in docstring
220
    "B904",   # within an except clause raise from error or from none
221
    "B026",   # backwards star-arg unpacking
222
    "E501",   # line too long
223
    "E731",   # assigning lambdas to variables
224
    "T201",   # print statements
225
]
226

227
[tool.ruff.per-file-ignores]
228
"disnake/__main__.py" = ["T201"] # print statements are okay in our simple cli
229
"disnake/i18n.py" = [
230
    "B027", # lib bug. Excluded here because ruff does not have a --disable-noqa flag yet
231
]
232
"disnake/ui/select/*.py" = [
233
    "F401", # unused imports. Excluded because there is a bug with ruff.
234
]
235
"disnake/**.py" = ["PT"] # this is not a module of pytest tests
236
"test_bot/*.py" = [
237
    "B008", # do not perform function calls in argument defaults
238
    "T201", # print found, printing is currently accepted in the test bot
239
    "PT",   # this is not a module of pytest tests
240
]
241
"tests/*.py" = ["S101"] # use of assert is okay in test files
242
"scripts/*.py" = ["S101"] # use of assert is okay in scripts
243
# we are not using noqa in the example files themselves
244
"examples/*.py" = [
245
    "B008", # do not perform function calls in argument defaults, this is how most commands work
246
    "PT",   # this is not a module of pytest tests
247
    "S311", # pseudo-random generators aren't suitable for cryptographic purposes
248
    "T201", # print found, printing is okay in examples
249
]
250
"examples/basic_voice.py" = ["S104"] # possible binding to all interfaces
251
"examples/views/tic_tac_toe.py" = ["E741"] # ambigious variable name: `O`
252

253
[tool.ruff.flake8-pytest-style]
254
fixture-parentheses = false
255
mark-parentheses = false
256

257
[tool.ruff.flake8-tidy-imports.banned-api]
258
"subprocess".msg = "Consider possible security implications associated with the subprocess module." # replaces S404
259

260
[tool.towncrier]
261
template = "changelog/_template.rst.jinja"
262
package = "disnake"
263
filename = "docs/whats_new.rst"
264
directory = "changelog/"
265
title_format = false
266
underlines = "-~"
267
issue_format = ":issue:`{issue}`"
268

269
    [[tool.towncrier.type]]
270
    directory = "breaking"
271
    name = "Breaking Changes"
272
    showcontent = true
273

274
    [[tool.towncrier.type]]
275
    directory = "deprecate"
276
    name = "Deprecations"
277
    showcontent = true
278

279
    [[tool.towncrier.type]]
280
    directory = "feature"
281
    name = "New Features"
282
    showcontent = true
283

284
    [[tool.towncrier.type]]
285
    directory = "bugfix"
286
    name = "Bug Fixes"
287
    showcontent = true
288

289
    [[tool.towncrier.type]]
290
    directory = "doc"
291
    name = "Documentation"
292
    showcontent = true
293

294
    [[tool.towncrier.type]]
295
    directory = "misc"
296
    name = "Miscellaneous"
297
    showcontent = true
298

299

300
[tool.slotscheck]
301
strict-imports = true
302
require-superclass = true
303
require-subclass = false
304
exclude-modules = '''
305
(
306
    ^disnake\.types\.
307
)
308
'''
309

310

311
[tool.pyright]
312
typeCheckingMode = "strict"
313
include = [
314
    "disnake",
315
    "docs",
316
    "examples",
317
    "test_bot",
318
    "tests",
319
    "*.py",
320
]
321
ignore = [
322
    "disnake/ext/mypy_plugin",
323
]
324

325
# this is one of the diagnostics that aren't enabled by default, even in strict mode
326
reportUnnecessaryTypeIgnoreComment = true
327

328
# it's unlikely that these will ever be enabled
329
reportOverlappingOverload = false
330
reportPrivateUsage = false
331
reportUnnecessaryIsInstance = false
332
reportFunctionMemberAccess = false
333
reportMissingTypeStubs = false
334
reportUnusedFunction = false
335
reportUnusedClass = false
336
reportConstantRedefinition = false
337
reportImportCycles = false
338
reportIncompatibleMethodOverride = false
339
reportIncompatibleVariableOverride = false
340

341
# these are largely due to missing type hints, and make up most of the error count
342
reportUnknownMemberType = false
343
reportUnknownParameterType = false
344
reportUnknownArgumentType = false
345
reportMissingParameterType = false
346
reportUnknownVariableType = false
347
reportMissingTypeArgument = false
348

349

350
[tool.pytest.ini_options]
351
testpaths = "tests"
352
addopts = "--strict-markers -Werror -s"
353
xfail_strict = true
354
asyncio_mode = "strict"
355

356
[tool.coverage.run]
357
branch = true
358
include = [
359
    "disnake/*",
360
    "tests/*",
361
]
362
omit = [
363
    "disnake/ext/mypy_plugin/*",
364
    "disnake/types/*",
365
    "disnake/__main__.py",
366
]
367

368
[tool.coverage.report]
369
precision = 1
370
exclude_lines = [
371
    "# pragma: no cov(er(age)?)?$",
372
    "^\\s*def __repr__",
373
    "^\\s*@overload",
374
    "^\\s*if TYPE_CHECKING",
375
    "^\\s*raise NotImplementedError$",
376
    "^\\s*\\.\\.\\.$",
377
]
378

379

380
[tool.check-manifest]
381
ignore = [
382
    # CI
383
    ".pre-commit-config.yaml",
384
    ".readthedocs.yml",
385
    ".libcst.codemod.yaml",
386
    "noxfile.py",
387
    # docs
388
    "CONTRIBUTING.md",
389
    "RELEASE.md",
390
    "assets/**",
391
    "changelog/**",
392
    "docs/**",
393
    "examples/**",
394
    # tests
395
    "test_bot/**",
396
    "tests/**",
397
    "scripts/**",
398
]
399

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.