forked from nextcord/nextcord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyproject.toml
233 lines (212 loc) · 8.45 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
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
[tool.poetry]
name = "nextcord"
# Placeholder, modified by dynamic-versioning.
version = "0.0.0"
homepage = "https://github.com/nextcord/nextcord"
documentation = "https://docs.nextcord.dev/"
description = "A Python wrapper for the Discord API forked from discord.py"
authors = ["Nextcord Developers <code@nextcord.dev>"]
license = "MIT"
readme = "README.rst"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Natural Language :: English",
"Operating System :: OS Independent",
"Framework :: AsyncIO",
"Framework :: aiohttp",
"Topic :: Internet",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
"Typing :: Typed",
] # License and Version are added automatically by Poetry
packages = [
{ include = "nextcord" },
{ include = "nextcord/types" },
{ include = "nextcord/ui" },
{ include = "nextcord/ui/select" },
{ include = "nextcord/webhook" },
{ include = "nextcord/ext/application_checks" },
{ include = "nextcord/ext/commands" },
{ include = "nextcord/ext/slash_utils" },
{ include = "nextcord/ext/tasks" },
]
[tool.poetry.dependencies]
python = "^3.8"
aiohttp = "^3.8.0"
typing_extensions = "^4.2.0"
PyNaCl = { version = ">=1.3.0,<1.5", optional = true }
orjson = { version = ">=3.5.4", optional = true }
# There is currently no way to express passthrough extras in Poetry.
# https://github.com/python-poetry/poetry/issues/834
# https://github.com/aio-libs/aiohttp/blob/d0f7b75c04c2257eaa86ac80f30ec3f7088088ea/setup.cfg#L61-L66
# speedups =
# # required c-ares (aiodns' backend) will not build on windows
# aiodns >= 1.1; sys_platform=="linux" or sys_platform=="darwin"
# Brotli; platform_python_implementation == 'CPython'
# brotlicffi; platform_python_implementation != 'CPython'
aiodns = { version = ">1.1", optional = true, markers = "sys_platform == 'linux' or sys_platform == 'darwin'" }
Brotli = { version = "*", optional = true, markers = "platform_python_implementation == 'CPython'" }
# If brotlicffi is unsupported by an older aiohttp version, it will simply be ignored.
brotlicffi = { version = "*", optional = true, markers = "platform_python_implementation != 'CPython'" }
[tool.poetry.group.dev.dependencies]
pre-commit = "3.5.0"
taskipy = "1.10.3"
slotscheck = "0.14.0"
python-dotenv = "0.20.0"
pyright = "1.1.317"
sphinx_autobuild = "2021.3.14"
[tool.poetry.group.docs.dependencies]
sphinx = "5.2.3"
sphinxcontrib-trio = "1.1.2"
sphinxcontrib-websupport = "^1.2.4"
[tool.poetry.urls]
"Documentation" = "https://docs.nextcord.dev/"
"Issue tracker" = "https://github.com/nextcord/nextcord/issues"
[tool.poetry.extras]
voice = ["PyNaCl"]
speed = ["orjson", "aiodns", "Brotli", "brotlicffi"]
[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
# If v2.6.0 tag -> 2.6.0
# If v2.6.0 tag and not at tag -> 2.6.0+g{hash}
# If v3.0.0a tag -> v3.0.0a0
# If v3.0.0a tag and not at tag -> 3.0.0a{distance}+g{hash}
format-jinja = """
{%- if distance == 0 -%}
{{ serialize_pep440(base, stage, revision) }}
{%- elif stage is none -%}
{{ serialize_pep440(base, stage, revision, metadata=["g"+commit]) }}
{%- else -%}
{{ serialize_pep440(base, stage, distance, metadata=["g"+commit]) }}
{%- endif -%}
"""
style = "pep440"
strict = true
[tool.poetry-dynamic-versioning.substitution]
patterns = [
{ value = "(^__version__\\s*(?::.*?)?=\\s*['\"])[^'\"]*(['\"])" },
{ value = "(^version_info\\s*(?::.*?)?=\\s*\\S*?\\()[^)]*(\\))", mode = "version_info" },
]
[build-system]
requires = [
"poetry-core>=1.0.0",
"poetry-dynamic-versioning @ https://github.com/ooliver1/poetry-dynamic-versioning/archive/f6952e5.zip",
]
build-backend = "poetry_dynamic_versioning.backend"
# credit to https://github.com/disnakeDev/disnake/blob/master/pyproject.toml for config
[tool.black]
line-length = 100
target-version = ["py38", "py39", "py310", "py311", "py312"]
[tool.taskipy.tasks]
black = { cmd = "task lint black", help = "Run black" }
docs = { cmd = "cd docs && sphinx-autobuild . _build/html --ignore _build --watch ../nextcord --port 8069", help = "Build the documentation on an autoreloading server." }
isort = { cmd = "task lint isort", help = "Run isort" }
lint = { cmd = "pre-commit run --all-files", help = "Check all files for linting errors" }
precommit = { cmd = "pre-commit install --install-hooks", help = "Install the precommit hook" }
pyright = { cmd = "dotenv -f task.env run -- python -m pyright", help = "Run pyright" }
slotscheck = { cmd = "python -m slotscheck --verbose -m nextcord", help = "Run slotscheck" }
autotyping = { cmd = "task lint autotyping", help = "Refactor code to add automatic type annotations" }
[tool.slotscheck]
strict-imports = true
require-superclass = true
require-subclass = false
exclude-modules = '''
(
^nextcord\.types\.
)
'''
[tool.pyright]
typeCheckingMode = "basic"
include = ["nextcord", "docs", "*.py"]
ignore = ["examples"]
pythonVersion = "3.8"
# https://github.com/microsoft/pyright/blob/main/docs/configuration.md
reportInvalidStringEscapeSequence = false
reportPropertyTypeMismatch = true
reportDuplicateImport = true
reportUntypedFunctionDecorator = true
reportUntypedClassDecorator = true
reportUntypedBaseClass = true
reportUntypedNamedTuple = true
reportUnknownLambdaType = true
reportInvalidTypeVarUse = true
reportUnnecessaryCast = true
reportSelfClsParameterName = true
reportUnsupportedDunderAll = true
reportUnusedVariable = true
reportUnnecessaryComparison = true
reportUnnecessaryTypeIgnoreComment = true
[tool.ruff]
line-length = 100
select = ["ALL"]
# TODO comments are for rules that should be enabled in the future (separate PRs)
ignore = [
"A", # TODO:
"ANN", # TODO:
"ANN101", # `self` does not need a type annotation
"ANN102", # `cls` does not need a type annotation
"ARG002", # TODO:
"ARG003", # TODO:
"B008", # SlashOption() as default, it is okay (Annotated is technically better but verbose)
"BLE", # TODO:
"C90", # TODO:
"COM", # black sorts out trailing commas
"D", # TODO:
"E", # TODO:
"E501", # black sorts out line length
"F403", # wildcard imports shouldn't be blasted
"F405", # pyright can detect undefined names anyway
"FA", # TODO:
"EM", # TODO:
"FBT", # TODO:
"FIX", # this can be removed on demand, todo comments are okay to be left in
"N", # TODO:
"PD", # all .values is mistaken for pandas
"PERF203", # TODO:
"PGH003", # pyright: ignore[rule] is too verbose (reportGeneralTypeIssues) unfortunately and makes a mess
"PLR2004", # TODO:
"PLW2901", # overriding loop var with a change (like anno = anno.type) is very common in this
"PTH", # TODO:
"PYI", # TODO:
"S101", # asserts are usually used for typing assertions - typing.cast would be better but it's fine
"S110", # TODO:
"S112", # TODO:
"S311", # "cryptographic purposes", this is a Discord bot library
"S603", # as this is a library, we do not need to check for untrusted input here
"S607", # or partial executable paths
"SLF", # pyright can detect private access, but internals rely on it too much right now
"TD002", # authors in TODO comments would be nice, but they don't exactly work retroactively (discord.py comments)
"TD003", # same with issue links, nice but not retroactive
"TCH", # TODO:
"TID", # TODO:
"TRY", # TODO:
"UP", # TODO:
]
exclude = [".github/*"]
target-version = "py38"
[tool.ruff.per-file-ignores]
"__init__.py" = [
"F401", # unused imports in __init__.py, "from . import abc, ..."
]
"scripts/autotyping.py" = ["INP"]
"examples/*" = [
"ARG001", # unused args in examples, not including _ prefixes to prevent confusion
"INP", # examples is an implicit namespace as it is just a directory
"S104", # all interfaces binding as an example
"SIM105", # not using contextlib.supress in examples, as comments denote "error handling here"
"T20", # print in examples is okay
"RET502", # return ... is used in commands, which is fine as an example
"RET503", # same as above
]
"__main__.py" = ["T20"]
"docs/*" = ["ERA001", "INP"]
[tool.ruff.pylint]
max-args = 40 # message args (send, execute_webhook) make this way too long usually
max-branches = 50 # these are quite big, but better than no linting for now
max-statements = 110
max-returns = 40
[tool.ruff.isort]
combine-as-imports = true