-
Notifications
You must be signed in to change notification settings - Fork 37
/
pyproject.toml
181 lines (167 loc) · 7.71 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
[tool.black]
target-version = ["py310"]
[tool.codespell]
ignore-words-list = "buildd,crate,keyserver,comandos,ro,dedent,dedented"
skip = ".tox,.git,build,.*_cache,__pycache__,*.tar,*.snap,*.png,./node_modules,./docs/_build,.direnv,.venv,venv,.vscode"
quiet-level = 3
check-filenames = true
[tool.mypy]
python_version = "3.10"
exclude = [
"build",
"results",
"venv",
".venv"
]
plugins = [
"pydantic.mypy"
]
warn_unused_configs = true
warn_redundant_casts = true
strict_equality = true
strict_concatenate = true
warn_return_any = true
disallow_subclassing_any = true
#disallow_untyped_decorators = true
#disallow_any_generics = true
[[tool.mypy.overrides]]
module = ["craft-parts"]
#disallow_untyped_defs = true
no_implicit_optional = true
[[tool.mypy.overrides]]
module = ["tests.*"]
strict = false
[tool.ruff]
line-length = 88
target-version = "py310"
src = ["craft-parts"]
extend-exclude = [
"docs",
"__pycache__",
]
# Follow ST063 - Maintaining and updating linting specifications for updating these.
lint.select = [ # Base linting rule selections.
# See the internal document for discussion:
# https://docs.google.com/document/d/1i1n8pDmFmWi4wTDpk-JfnWCVUThPJiggyPi2DYwBBu4/edit
# All sections here are stable in ruff and shouldn't randomly introduce
# failures with ruff updates.
"F", # The rules built into Flake8
"E", "W", # pycodestyle errors and warnings
"I", # isort checking
"N", # PEP8 naming
"D", # Implement pydocstyle checking as well.
"UP", # Pyupgrade - note that some of are excluded below due to Python versions
"YTT", # flake8-2020: Misuse of `sys.version` and `sys.version_info`
"ANN", # Type annotations.
"ASYNC", # Catching blocking calls in async functions
# flake8-bandit: security testing. https://docs.astral.sh/ruff/rules/#flake8-bandit-s
# https://bandit.readthedocs.io/en/latest/plugins/index.html#complete-test-plugin-listing
"S101", "S102", # assert or exec
"S103", "S108", # File permissions and tempfiles - use #noqa to silence when appropriate.
"S104", # Network binds
"S105", "S106", "S107", # Hardcoded passwords
"S110", # try-except-pass (use contextlib.suppress instead)
"S113", # Requests calls without timeouts
"S3", # Serialising, deserialising, hashing, crypto, etc.
"S5", # Unsafe cryptography or YAML loading.
"S602", # Subprocess call with shell=true
"S701", # jinja2 templates without autoescape
"BLE", # Do not catch blind exceptions
"FBT", # Disallow boolean positional arguments (make them keyword-only)
"B0", # Common mistakes and typos.
"A", # Shadowing built-ins.
"COM", # Trailing commas
"C4", # Encourage comprehensions, which tend to be faster than alternatives.
"T10", # Don't call the debugger in production code
"ISC", # Implicit string concatenation that can cause subtle issues
"ICN", # Only use common conventions for import aliases.
"INP", # Implicit namespace packages
# flake8-pie: miscellaneous linters (enabled individually because they're not really related)
"PIE790", # Unnecessary pass statement
"PIE794", # Multiple definitions of class field
"PIE796", # Duplicate value in an enum (reasonable to noqa for backwards compatibility)
"PIE804", # Don't use a dict with unnecessary kwargs
"PIE807", # prefer `list` over `lambda: []`
"PIE810", # Use a tuple rather than multiple calls. E.g. `mystr.startswith(("Hi", "Hello"))`
"PYI", # Linting for type stubs.
"PT", # Pytest
"Q", # Consistent quotations
"RSE", # Errors on pytest raises.
"RET", # Simpler logic after return, raise, continue or break
"SLF", # Error when accessing private members
"SIM", # Code simplification
"TID", # Tidy imports
# The team have chosen to only use type-checking blocks when necessary to prevent circular imports.
# As such, the only enabled type-checking checks are those that warn of an import that needs to be
# removed from a type-checking block.
"TCH004", # Remove imports from type-checking guard blocks if used at runtime
"TCH005", # Delete empty type-checking blocks
"ARG", # Unused arguments
"PTH", # Migrate to pathlib
#"FIX", # All TODOs, FIXMEs, etc. should be turned into issues instead.
"ERA", # Don't check in commented out code
"PGH", # Pygrep hooks
"PL", # Pylint
"TRY", # Cleaner try/except,
"FLY", # Detect things that would be better as f-strings.
"PERF", # Catch things that can slow down the application like unnecessary casts to list.
"RUF001", "RUF002", "RUF003", # Ambiguous unicode characters
"RUF005", # Encourages unpacking rather than concatenation
"RUF008", # Do not use mutable default values for dataclass attributes
#"RUF012", # Mutable class attributes should be annotated with typing.ClassVar
"RUF013", # Prohibit implicit Optionals (PEP 484)
"RUF100", # #noqa directive that doesn't flag anything
"RUF200", # If ruff fails to parse pyproject.toml...
]
lint.ignore = [
"ANN10", # Type annotations for `self` and `cls`
#"E203", # Whitespace before ":" -- Commented because ruff doesn't currently check E203
"E501", # Line too long (reason: black will automatically fix this for us)
"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)
"A003", # Class attribute shadowing built-in (reason: Class attributes don't often get bare references)
"SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements
# (reason: this creates long lines that get wrapped and reduces readability)
# Ignored due to common usage in current code
"TRY003", # Avoid specifying long messages outside the exception class
# Temporary ignored due to API change
"PTH", # Use pathlib.Path
"N818", # Allow Exception name without an Error suffix
"COM812", # Trailing comma missing
]
[tool.ruff.lint.flake8-annotations]
allow-star-arg-any = true
[tool.ruff.lint.pylint]
max-args = 8
max-branches = 16
max-locals = 18
# max-attributes = 16
[tool.ruff.lint.pep8-naming]
# Allow Pydantic's `@validator` decorator to trigger class method treatment.
classmethod-decorators = ["pydantic.validator", "pydantic.root_validator"]
[tool.ruff.lint.per-file-ignores]
"tests/**.py" = [ # Some things we want for the moin project are unnecessary in tests.
"D", # Ignore docstring rules in tests
"ANN", # Ignore type annotations in tests
"ARG", # Allow unused arguments in tests (e.g. for fake functions/methods/classes)
"S101", # Allow assertions in tests
"S103", # Allow `os.chmod` setting a permissive mask `0o555` on file or directory
"S108", # Allow Probable insecure usage of temporary file or directory
"PLR0913", # Allow many arguments for test functions (useful if we need many fixtures)
"PLR2004", # Allow magic values in tests
"PT004", # Allow fixture no return in tests
"SLF", # Allow accessing private members from tests.
"INP001", # Allow implicit namespace package
"RUF012", # Allow mutable class attributes without `typing.ClassVar`
]
"__init__.py" = [
"I001", # isort leaves init files alone by default, this makes ruff ignore them too.
"F401", # Allows unused imports in __init__ files.
]
[tool.ruff.format]
quote-style = "double"
docstring-code-format = true
skip-magic-trailing-comma = false