-
Notifications
You must be signed in to change notification settings - Fork 448
/
pyproject.toml
134 lines (122 loc) · 4.93 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
[tool.black]
extend-exclude = '''
/(
| snapcraft_legacy
| tools
| docs/sphinx-resources
)/
'''
# Targeting future versions as well so we don't have black reformatting code
# en masse later.
target_version = ["py310", "py311"]
[tool.mypy]
python_version = "3.10"
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.10"
[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]
target-version = "py310"
line-length = 88
extend-exclude = [
"docs",
"__pycache__",
"legacy",
"tests/legacy",
]
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
"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.
# 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.flake8-annotations]
suppress-none-returning = true # We don't need to explicitly point out that a function doesn't return anything