This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
forked from canonical/snapcraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyproject.toml
167 lines (149 loc) · 5.87 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
[tool.black]
extend-exclude = '''
/(
| snapcraft_legacy
| tools
)/
'''
# Targeting future versions as well so we don't have black reformatting code
# en masse later.
target_version = ["py38", "py310", "py311"]
[tool.isort]
# black-compatible isort configuration
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 88
skip_gitignore = true
skip = ["tests/spread/tools/snapd-testing-tools"]
[tool.pylint.main]
ignore-paths = ["tests/legacy"]
[tool.pylint.messages_control]
# duplicate-code can't be disabled locally: https://github.com/PyCQA/pylint/issues/214
disable = "too-few-public-methods,fixme,use-implicit-booleaness-not-comparison,duplicate-code,unnecessary-lambda-assignment"
[tool.pylint.format]
max-attributes = 15
max-args = 6
max-locals = 20
max-branches = 16
good-names = "id"
[tool.pylint.MASTER]
extension-pkg-allow-list = [
"lxml.etree",
"pydantic",
"pytest",
]
load-plugins = "pylint_fixme_info,pylint_pytest"
[tool.pylint.SIMILARITIES]
min-similarity-lines=10
[tool.mypy]
python_version = 3.8
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 = ["tests/legacy", "tests/spread", "build"]
pythonVersion = "3.8"
[tool.pytest.ini_options]
minversion = 7.0
required_plugins = ["pytest-cov>=4.0", "pytest-mock>=3.10", "pytest-subprocess>=1.4"]
addopts = ["--cov=snapcraft"]
# Most of this ruff configuration comes from craft-parts
[tool.ruff]
line-length = 88
extend-exclude = [
"docs",
"__pycache__",
"legacy",
"tests/legacy",
]
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
]
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
"ANN101", "ANN102", # Type annotations for `self` and `cls` in methods
"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.
# 3 instances of breaking N802, all from overriding do_GET in http.server.BaseHTTPRequestHandler
# We can probably noqa these and enable the rule
"N802", # Function names should be lowercase.
# 3 instances of N805, all PyDantic validators (which are classmethods).
# These have pylint disablers, but ruff doesn't understand those (yet).
# https://github.com/charliermarsh/ruff/issues/1203
"N805", # First argument of a method should be named `self`
# 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
# 1 instance, disabled for pylint
"BLE001",
# Comprehensions - IDK, these ones flagged and they really could go either way.
"C405", "C408", "C414",
"Q000", # 2 single-quoted strings - probably accidental
"RET504", "RET506", # Return value related.
]
[tool.ruff.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.
]
"__init__.py" = ["I001"] # Imports in __init__ filesare allowed to be out of order
[tool.ruff.flake8-annotations]
suppress-none-returning = true # We don't need to explicitly point out that a function doesn't return anything