-
Notifications
You must be signed in to change notification settings - Fork 457
/
Copy pathpyproject.toml
358 lines (332 loc) · 10.4 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
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
[project]
name = "snapcraft"
description = "Create snaps"
readme = "README.md"
dynamic = ["version"]
dependencies = [
"attrs",
"catkin-pkg==1.0.0 ; sys_platform == 'linux'",
"click==8.1.8",
"craft-application[remote]~=4.9",
"craft-archives~=2.1",
"craft-cli~=2.15.0",
"craft-grammar>=2.0.1,<3.0.0",
"craft-parts==2.4.1",
"craft-platforms~=0.6",
"craft-providers~=2.1",
"craft-store>=3.0.2,<4.0.0",
"cryptography",
"gnupg",
"jsonschema==2.5.1",
"launchpadlib",
"lazr.restfulclient",
"lxml",
"macaroonbakery",
"mypy-extensions",
"overrides",
"packaging",
"progressbar",
"pydantic~=2.8",
"pyelftools",
# Pygit2 and libgit2 need to match versions.
# Further info: https://www.pygit2.org/install.html#version-numbers
"pygit2~=1.13.0",
"pylxd ; sys_platform == 'linux'",
"pymacaroons",
"python-debian ; sys_platform == 'linux'",
"pyxdg",
"pyyaml",
"raven",
"requests-toolbelt",
"requests-unixsocket2",
"requests",
"simplejson",
"snap-helpers",
"tabulate",
"toml",
"tinydb",
"typing-extensions",
"validators>=0.28.3",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Operating System :: POSIX :: Linux",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Natural Language :: English",
"Topic :: Software Development :: Build Tools",
"Topic :: System :: Software Distribution",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.12"
[dependency-groups]
dev = [
"coverage[toml]",
"pyflakes",
"fixtures",
# For Tiobe TiCS
"flake8",
"mccabe",
"testscenarios",
"pexpect",
"pip",
"pycodestyle",
"pyftpdlib",
"pyinstaller ; sys_platform == 'win32'",
# For Tiobe TiCS
"pylint",
"pyramid",
"pytest",
"pytest-cov",
"pytest-check",
"pytest-mock",
"pytest-subprocess",
]
docs = [
"canonical-sphinx[full]>=0.2.0",
"docutils<0.20", # Frozen until we can update sphinx dependencies.
"sphinx-autobuild",
"sphinx-autodoc-typehints",
"sphinxcontrib-details-directive",
"sphinx-lint",
"sphinx-toolbox",
"sphinxext-rediraffe==0.2.7",
"pyspelling",
]
lint = [
"yamllint~=1.34",
"codespell[toml]",
{ include-group = "types" },
]
types = [
"mypy",
"types-PyYAML",
# Pinned because any higher requires urllib3>=2
"types-requests==2.31.0.6",
"types-setuptools",
"types-simplejson",
"types-tabulate",
"types-toml",
]
dev-jammy = [
# Stay on 2.4 for Jammy
"python-apt~=2.4.0;sys_platform=='linux'",
]
dev-noble = [
# 2.7 for Noble
"python-apt~=2.7.0;sys_platform=='linux'",
]
dev-oracular = [
# 2.9 for Oracular+
"python-apt>=2.9.0;sys_platform=='linux'",
]
dev-plucky = [
# 2.9 for Oracular+
"python-apt>=2.9.0;sys_platform=='linux'",
]
[tool.uv]
conflicts = [
[
{ group = "dev-jammy" },
{ group = "dev-noble" },
{ group = "dev-oracular" },
{ group = "dev-plucky" },
]
]
[[tool.uv.index]]
name = "python-apt-wheels"
url = "https://people.canonical.com/~lengau/python-apt-ubuntu-wheels/" # workaround to get python-apt to install across multiple platforms
explicit = true
[tool.uv.sources]
python-apt = { index = "python-apt-wheels" }
[project.scripts]
snapcraft = "snapcraft.application:main"
snapcraft_legacy = "snapcraft_legacy.cli.__main__:run"
[build-system]
requires = [
"setuptools>=69.0",
"setuptools_scm[toml]>=7.1",
]
build-backend = "setuptools.build_meta"
[tool.setuptools]
script-files = ["bin/snapcraftctl", "bin/snapcraftctl-compat"]
[tool.setuptools_scm]
write_to = "snapcraft/_version.py"
# the version comes from the latest annotated git tag formatted as 'X.Y.Z'
# version scheme:
# - X.Y.Z.post<commits since tag>+g<hash>.d<%Y%m%d>
# parts of scheme:
# - X.Y.Z - most recent git tag
# - post<commits since tag>+g<hash> - present when current commit is not tagged
# - +dirty - present when working dir is dirty
# version scheme when no tags exist:
# - 0.0.post<total commits>+g<hash>
version_scheme = "post-release"
# deviations from the default 'git describe' command:
# - only match annotated tags
# - only match tags formatted as 'X.Y.Z'
git_describe_command = [
"git",
"describe",
"--dirty",
"--long",
"--match",
"[0-9]*.[0-9]*.[0-9]*",
"--exclude",
"*[^0-9.]*",
]
# Appends "+dirty" to the version when working dir is dirty
# Necessary to avoid version numbers being too long
local_scheme = "dirty-tag"
[tool.setuptools.packages.find]
include = ["snapcraft", "extensions", "keyrings", "schema", "snapcraft_legacy"]
namespaces = true
[tool.setuptools.package-data]
snapcraft = ["templates/*"]
[tool.mypy]
python_version = "3.12"
ignore_missing_imports = true
follow_imports = "silent"
exclude = [
"build",
"snapcraft_legacy",
"tests/spread",
"tests/legacy",
"tools",
"venv",
]
plugins = [
"pydantic.mypy",
]
[tool.pyright]
include = ["snapcraft", "tests"]
exclude = ["build", "tests/legacy", "tests/spread"]
pythonVersion = "3.12"
# Most of this ruff configuration comes from craft-parts
[tool.ruff]
target-version = "py312"
line-length = 88
extend-exclude = [
"docs",
"__pycache__",
"legacy",
"tests/legacy",
"snapcraft/_version.py", # setuptools_scm generates old-style type annotations and single quotes
]
lint.select = [
"E", "F", # The rules built into Flake8
"I", # isort checking
"PLC", "PLE", "PLR", "PLW", # Pylint
# Additional stricter checking than previously enabled:
"A", # Shadowing built-ins.
"W", # PyCodeStyle warnings.
"N", # Pep8 naming
"YTT", # flake8-2020: Misuse of `sys.version` and `sys.version_info`
"ANN", # Annotations
"S", # Checks for common security issues
"BLE", # Blind exception
"B", # Opinionated bugbear linting
"C4", # better comprehensions
"T10", # Ensure we don't leave code that starts the debugger in
"ICN", # Unconventional import aliases.
"Q", # Consistent quotations
"RET", # Return values
]
lint.ignore = [
# These following copy the flake8 configuration
#"E203", # Whitespace before ":" -- Commented because ruff doesn't currently check E203
"E501", # Line too long
# The following copy our pydocstyle configuration
"D105", # Missing docstring in magic method (reason: magic methods already have definitions)
"D107", # Missing docstring in __init__ (reason: documented in class docstring)
"D203", # 1 blank line required before class docstring (reason: pep257 default)
"D213", # Multi-line docstring summary should start at the second line (reason: pep257 default)
"D215", # Section underline is over-indented (reason: pep257 default)
# Stricter type checking rules that that are disabled.
"A003", # Class attribute shadowing a python built-in (class attributes are seldom if ever referred to bare)
"N818", # Exception names ending with suffix `Error`
"ANN002", "ANN003", # Missing type annotation for *args and **kwargs
"ANN204", # Missing type annotations for magic methods
"ANN401", # Disallowing `typing.Any`
"B904", # Within an except clause, always explicitly `raise` an exception `from` something.
"B905", # Zip without explicit `strict=` parameter - this only exists in 3.10+
# Disabled because the current code breaks these rules without "noqa" comments
# Most of these are probably worth enabling eventually.
# Annotation issues appear to be mostly in older code, so could be eventually enabled.
# 39 instances of ANN001.
"ANN001", # Missing type annotation for function argument
# 5 instances of ANN201, 10 instances of ANN202
"ANN201", "ANN202", # Missing return type annotation for public/private function
# 13 instances of ANN206 - probably mostly :noqa-able
"ANN206",
# 4 instances - would break if run with optimization
"S101", # Use of assert detected
# Comprehensions - IDK, these ones flagged and they really could go either way.
"C405", "C408", "C414",
"RET504", "RET506", # Return value related.
"PLR2004", # Magic values - widely used
"S603", # Untrusted input for subprocess calls
"S604", # shell=True parameter to a function
"S607", # Partial executable path for subprocess calls
]
[tool.ruff.lint.pylint]
max-args = 6
max-branches = 16
[tool.ruff.lint.per-file-ignores]
"tests/**.py" = [
"D", # Ignore docstring rules in tests
"ANN", # Ignore type annotations in tests
"S101", # Yeah of course we assert in tests
"B009", # Allow calling `getattr` in tests since it can be used to make the test clearer.
"S103", # Allow `os.chmod` setting a permissive mask `0o555` on file or directory
"S105", # Allow Possible hardcoded password.
"S106", # Allow Possible hardcoded password.
"S108", # Allow Probable insecure usage of temporary file or directory.
"PLR0913", # Allow many arguments to tests
]
"tests/unit/parts/plugins/test_kernel.py" = [
"E101", # Mixed tabs and spaces. Ruff gets confused by tabs in multiline strings
]
"__init__.py" = ["I001"] # Imports in __init__ filesare allowed to be out of order
[tool.ruff.lint.pydocstyle]
ignore-decorators = [ # Functions with these decorators don't have to have docstrings.
"typing.overload", # Default configuration
# The next four are all variations on override, so child classes don't have to repeat parent classes' docstrings.
"overrides.override",
"overrides.overrides",
"typing.override",
"typing_extensions.override",
]
[tool.ruff.lint.pep8-naming]
# Allow Pydantic's `@validator` decorator to trigger class method treatment.
classmethod-decorators = ["pydantic.validator", "pydantic.root_validator"]
[tool.pytest.ini_options]
minversion = "7.0"
testpaths = "tests"
xfail_strict = true
markers = ["slow: slow tests"]
[tool.coverage.run]
branch = true
omit = ["test/**"]
[tool.coverage.report]
skip_empty = true
exclude_also = [
"if (typing\\.)?TYPE_CHECKING:",
]
[tool.codespell]
ignore-words-list = [
"buildd",
"crate",
"assertIn",
"socio-economic",
]
skip = [
# Keyrings aren't code
"*.asc",
# These tests include some non-English text
"*/test_appstream.py",
"*/test_update_metadata.py",
]