forked from canonical/rockcraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyproject.toml
179 lines (163 loc) · 6.81 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
[build-system]
requires = [
"setuptools~=70.0.0",
"setuptools_scm[toml]>=7.1"
]
build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
write_to = "rockcraft/_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
# - .d<%Y%m%d> - 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.]*'"
[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 88
[tool.black]
# Use extend-exclude so that the default excludes (including those from .gitignore)
# are not overwritten.
extend-exclude = "docs/sphinx-starter-pack"
[tool.pyright]
ignore = [
"docs/sphinx-starter-pack",
"docs/how-to/code",
"docs/tutorial/code/flask",
"tests/spread/general/extension-django/example_django"
]
[tool.mypy]
python_version = "3.10"
exclude = [
"build",
"results",
"tests/spread"
]
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 = ["rockcraft"]
disallow_untyped_defs = true
no_implicit_optional = true
[[tool.mypy.overrides]]
module = ["tests.*"]
strict = false
[[tool.mypy.overrides]]
module = ["craft_archives"]
ignore_missing_imports = true
[tool.ruff]
line-length = 88
target-version = "py310"
src = ["rockcraft", "tests"]
extend-exclude = [
"docs",
"__pycache__",
"rockcraft/_version.py"
]
# 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
"D", # Implement pydocstyle checking as well.
"I", # isort checking
"PLC", "PLE", "PLR", "PLW", # Pylint
"N", # PEP8 naming
"YTT", # flake8-2020: Misuse of `sys.version` and `sys.version_info`
"BLE", # Do not catch blind exceptions
"FBT", # Disallow boolean positional arguments (make them keyword-only)
"A", # Shadowing built-ins.
"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.
"Q", # Consistent quotations
"RET", # Simpler logic after return, raise, continue or break
"UP018", "C408", # Convert type calls to literals. The latest pylint enforces this, but ruff has auto-fixes.
]
lint.extend-select = [
# These sets are still frequently getting new rules.
# Therefore, they're getting frozen with the current rules so we can
# upgrade ruff without breaking linting.
# Pyupgrade: https://github.com/charliermarsh/ruff#pyupgrade-up
"UP00", "UP01", "UP02", "UP030", "UP032", "UP033",
# "UP034", # Very new, not yet enabled in ruff 0.0.227
# Annotations: https://github.com/charliermarsh/ruff#flake8-annotations-ann
"ANN0", # Type annotations for arguments other than `self` and `cls`
"ANN2", # Return type annotations
# flake8-bandit: security testing. https://github.com/charliermarsh/ruff#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
"S113", # Requests calls without timeouts
"S506", # Unsafe YAML load
"S508", "S509", # Insecure SNMP
"S701", # jinja2 templates without autoescape
"B0", # Common mistakes and typos.
"RUF001", "RUF002", "RUF003", # Ambiguous unicode characters
"B026", # Keyword arguments must come after starred arguments
"RUF005", # Encourages unpacking rather than concatenation
"RUF100", # #noqa directive that doesn't flag anything.
]
lint.ignore = [
#"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)
]
[tool.ruff.lint.flake8-annotations]
allow-star-arg-any = true
[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.pylint]
max-args = 8
[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
"S101", # Allow assertions in tests
"S103", # Allow `os.chmod` setting a permissive mask `0o555` on file or directory
"S105", # Allow (fake) secrets in tests.
"S108", # Allow Probable insecure usage of temporary file or directory
"PLR0913", # Allow many arguments for test functions
"PLR2004", # Allow magic values in tests
]
# isort leaves init files alone by default, this makes ruff ignore them too.
"__init__.py" = ["I001"]