forked from aristanetworks/avd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
330 lines (310 loc) · 12.3 KB
/
pyproject.toml
File metadata and controls
330 lines (310 loc) · 12.3 KB
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
[dependency-groups]
# pyavd minimal requirements when running from source
# anta is set to latest version to make sure developers run with the latest version
# when generating molecule artifacts.
dev = [
"anta==1.7.0",
"cryptography>=43.0.0",
"deepmerge>=1.1.0",
"netaddr>=0.7.19",
"pyavd-utils==0.0.2",
"python-socks[asyncio]>=2.7.2",
"pyyaml>=6.0.0",
# dev requirements"
{include-group = "pytest"},
{include-group = "molecule"},
"ansible-doc-extractor>=0.1.10",
"ansible-lint>=25.1.3",
"aristaproto[compiler]==0.1.4",
"bump-my-version>=1.2.4",
"codespell>=2.2.6",
"docker>=7.1.0",
"identify>=1.4.20",
"jsonschema-rs>=0.24",
"pre-commit-hooks>=3.3.0",
"pre-commit>=3.2.0",
"pylint>=3.2.6",
"ruff==0.15.5",
"setuptools>=77.0", # for pyright check in CI
"tox>4",
"twine>=6.2.0",
"yamllint>=1.37.1",
]
coverage = [
"coverage[toml]==7.13.4",
]
doc = [
"mkdocs<2",
"mkdocs-material<10",
"mkdocs-material-extensions",
"mkdocs-same-dir",
"pymdown-extensions",
"mdx_truly_sane_lists",
"mike==1.1.2",
"mkdocs-git-revision-date-localized-plugin",
"mkdocs-git-revision-date-plugin",
"mkdocs-exclude",
"mkdocs-include-dir-to-nav",
"mkdocstrings[python]",
]
molecule = [
"molecule>=25.11.0",
"molecule-plugins[docker]>=25.8.12",
]
pytest = [
"ansible-core>=2.16.0,<2.21.0",
"anta>=1.7.0",
"pytest>=8.2.0",
"pytest-asyncio>=1.2.0",
"pydantic>=2.3.0",
"referencing>=0.35.0",
]
[tool.ruff]
line-length = 160
extend-exclude = [
"python-avd/pyavd/_cv/api/**/*",
"python-avd/tests/pyavd/schema/data_merging_schema_class.py", # File is generated during pytest
]
target-version = "py310"
[tool.ruff.lint]
# D213 is forced here since it will be removed by pydocstyle.convention = 'google' even when we have ALL here.
extend-select = ["ALL", "D213"]
ignore = [
"D203", # Ignoring conflicting D* warnings - one-blank-line-before-class
"D212", # Ignoring conflicting D* warnings - multi-line-summary-first-line
"COM812", # Ignoring conflicting rules that may cause conflicts when used with the formatter
"ISC001", # Ignoring conflicting rules that may cause conflicts when used with the formatter
"TD002", # We don't have require authors in TODO
"TD003", # We don't have an issue link for all TODOs today
"FIX002", # Line contains TODO - ignoring for ruff for now
"SLF001", # Accessing private members - TODO: Improve code
"D100", # Missing docstring in public module - TODO: Improve code
"D101", # Missing docstring in public class - TODO: Improve code
"D102", # Missing docstring in public method - TODO: Improve code
"D103", # Missing docstring in public function - TODO: Improve code
"D104", # Missing docstring in public package
"D105", # Missing docstring in magic method - TODO: Improve code
"D106", # Missing docstring in public nested class - TODO: Improve code
"D107", # Missing docstring in `__init__` - TODO: Improve code
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed - TODO: Improve code
"C901", # complex-structure - TODO: Improve code
"FBT001", # Boolean-typed positional argument in function definition - TODO: Improve code
"FBT002", # Boolean default positional argument in function definition - TODO: Improve code
"PD011", # Use numpy instead of .values - False positive
"BLE001", # Do not catch blind exception: `Exception - TODO: Improve code
"PLR2004", # Magic value used in comparison - TODO: Evaluate
"DTZ005", # `datetime.datetime.now()` called without a `tz` argument - TODO: Improve code
"ASYNC109", # async-function-with-timeout: Our async functions call several other async functions and we need each of those calls to be governed by the configurable timeout.
]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.per-file-ignores]
"ansible_collections/arista/avd/plugins/*/*.py" = [
"E402", # Ansible plugins require a layout with imports below the docs
"INP001", # implicit namespace package. Add an `__init__.py` - Ansible plugins are not in packages
]
"ansible_collections/arista/avd/extensions/molecule/eos_designs_unit_tests/custom_modules/*.py" = [
"INP001", # implicit namespace package. Add an `__init__.py` - TODO: Evaluate or see if it is a false positive
]
"python-avd/scripts/**/*.py" = [
"T201", # Interactive scripts can have print
"INP001", # implicit namespace package. Add an `__init__.py` - TODO: Evaluate or see if it is a false positive
]
"python-avd/pyavd/_cv/client/*.py" = [
"B904", # Within an `except` clause, raise exceptions with `raise - TODO: Improve code
]
"python-avd/pyavd/_eos_cli_config_gen/schema/__init__.py" = [
"A002", # Argument is shadowing a Python builtin - OK since these are data classes
"PLR0913", # Too many arguments in function definition - OK since these are data classes
"E501", # Line too long - OK since we may have some very long vars or deeply nested with a long one-line description.
"S107", # Possible hardcoded password assigned to function default - False positive.
"D205", # 1 blank line required between summary line and description - OK since descriptions are autogenerated and for data fields.
]
"python-avd/pyavd/_eos_designs/schema/__init__.py" = [
"A002", # Argument is shadowing a Python builtin - OK since these are data classes
"PLR0913", # Too many arguments in function definition - OK since these are data classes
"E501", # Line too long - OK since we may have some very long vars or deeply nested with a long one-line description.
"S107", # Possible hardcoded password assigned to function default - False positive.
"S104", # Possible binding to all interfaces - False positive.
"S108", # Probable insecure usage of temporary file or directory - False positive.
"D205", # 1 blank line required between summary line and description - OK since descriptions are autogenerated and for data fields.
]
"python-avd/pyavd/_eos_designs/eos_designs_facts/schema/protocol.py" = [
"A002", # Argument is shadowing a Python builtin - OK since these are data classes
"PLR0913", # Too many arguments in function definition - OK since these are data classes
"D205", # 1 blank line required between summary line and description - OK since descriptions are autogenerated and for data fields.
"E501", # Line too long - OK since we may have some very long vars or deeply nested with a long one-line description.
]
"**/tests/**/*" = [
"S101", # Accept 'assert' in pytest.
"INP001", # implicit namespace package. Add an `__init__.py` - Tests are not in packages
"PLC0415", # `import` should be at the top-level of a file
]
"python-avd/pyavd/_anta/index.py" = [
"F403", # Allow wildcard imports to avoid cluttering the index
"F405", # Allow names defined in via a wildcard import
]
[tool.ruff.lint.pylint]
max-args = 15
max-branches = 54
max-returns = 10
max-statements = 148
[tool.ruff.lint.isort]
known-first-party = ["pyavd", "schema_tools"]
[tool.ruff.format]
docstring-code-format = true
[tool.ruff.lint.flake8-type-checking]
# These classes require that type annotations be available at runtime
runtime-evaluated-base-classes = ["pydantic.BaseModel"]
[tool.pyright]
typeCheckingMode = "standard"
exclude = [
"ansible_collections/arista/avd", # TODO
"python-avd/pyavd/_cv", # TODO
"python-avd/pyavd/_schema/models", # TODO
"python-avd/schema_tools/generate_docs", # TODO
"python-avd/schema_tools/metaschema", # TODO
"python-avd/tests", # TODO
# Excluded
"python-avd/pyavd/_cv/api",
"python-avd/pyavd/_eos_cli_config_gen/j2templates/compiled_templates",
"python-avd/pyavd/_eos_cli_config_gen/schema/__init__.py",
"python-avd/pyavd/_eos_designs/eos_designs_facts/schema/protocol.py",
"python-avd/pyavd/_eos_designs/j2templates/compiled_templates",
"python-avd/pyavd/_eos_designs/schema/__init__.py",
".tox",
]
pythonVersion = "3.10"
# This is to direct pyright where to look for schema_tools
extraPaths = [
"python-avd",
]
reportMissingImports = "error"
[tool.pytest.ini_options]
testpaths = [
"python-avd/tests",
]
pythonpath = [
".", # This is needed to import from ansible_collections
"python-avd",
]
markers = [
"molecule_scenarios: Create test case fixtures 'molecule_host' or 'molecule_scenario' for the given molecule scenarios.",
"digital_twin_molecule_scenarios: Create test case fixtures 'molecule_host' or 'molecule_scenario' for the given molecule scenarios executed in digital_twin mode.",
]
asyncio_default_fixture_loop_scope = "function"
# log_file = "pytest.log"
# log_file_level = "DEBUG"
log_file_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
log_file_date_format = "%Y-%m-%d %H:%M:%S.%f"
[tool.coverage.run]
branch = true
parallel = true
source_pkgs = [
"pyavd",
"schema_tools",
]
source_dirs = [
# Adding compiled templates as source dir since they are not part of the pyavd package
"python-avd/pyavd/_eos_cli_config_gen/j2templates/compiled_templates",
"python-avd/pyavd/_eos_designs/j2templates/compiled_templates",
]
omit = [
"python-avd/pyavd/_cv/api/*"
]
[tool.coverage.report]
show_missing = true
fail_under = 85
# Regexes for lines to exclude from consideration
exclude_also = [
# Have to re-enable the standard pragma
"pragma: no cover",
# Don't complain about missing debug-only code:
"def __repr__",
"if self\\.debug",
# Don't complain if tests don't hit defensive assertion code:
"raise AssertionError",
"raise NotImplementedError",
# Don't complain if non-runnable code isn't run:
"if 0:",
"if __name__ == .__main__.:",
# Don't complain about abstract methods, they aren't run:
"@(abc\\.)?abstractmethod",
# Don't complain about TYPE_CHECKING blocks
"if TYPE_CHECKING:",
# Ignore typing overloads
"@overload",
# Don't complain about Jinja2 internalcode
# Note that except KeyError is a bit sad but this is the pattern
"except KeyError:",
"@internalcode",
"raise TemplateRuntimeError",
"^blocks = {}",
"^debug_info =.*",
]
[tool.bumpversion]
current_version = "6.1.0-dev1"
allow_dirty = true
commit = false
tag = false
parse = """(?x)
(?P<major>0|[1-9]\\d*)\\.
(?P<minor>0|[1-9]\\d*)\\.
(?P<patch>0|[1-9]\\d*)
(?:
- # dash separator for pre-release section
(?P<pre_l>[a-zA-Z-]+) # pre-release label
(?P<pre_n>0|[1-9]\\d*) # pre-release version number
)? # pre-release section is optional
"""
serialize = [
"{major}.{minor}.{patch}-{pre_l}{pre_n}",
"{major}.{minor}.{patch}",
]
[tool.bumpversion.parts.pre_l]
values = [
"dev",
"final",
]
optional_value = "final"
[[tool.bumpversion.files]]
filename = "ansible_collections/arista/avd/galaxy.yml"
search = "version: {current_version}"
replace = "version: {new_version}"
### Bumping version using PEP440 style like x.y.z.dev1
[[tool.bumpversion.files]]
filename = "python-avd/pyproject.toml"
search = 'pyavd=={current_version}'
replace = 'pyavd=={new_version}'
parse = """(?x)
(?P<major>0|[1-9]\\d*)\\.
(?P<minor>0|[1-9]\\d*)\\.
(?P<patch>0|[1-9]\\d*)
(?:
\\. # dot separator for pre-release section
(?P<pre_l>[a-zA-Z-]+) # pre-release label
(?P<pre_n>0|[1-9]\\d*) # pre-release version number
)? # pre-release section is optional
"""
serialize = [
"{major}.{minor}.{patch}.{pre_l}{pre_n}",
"{major}.{minor}.{patch}",
]
[[tool.bumpversion.files]]
filename = "python-avd/pyavd/__init__.py"
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'
parse = """(?x)
(?P<major>0|[1-9]\\d*)\\.
(?P<minor>0|[1-9]\\d*)\\.
(?P<patch>0|[1-9]\\d*)
(?:
\\. # dot separator for pre-release section
(?P<pre_l>[a-zA-Z-]+) # pre-release label
(?P<pre_n>0|[1-9]\\d*) # pre-release version number
)? # pre-release section is optional
"""
serialize = [
"{major}.{minor}.{patch}.{pre_l}{pre_n}",
"{major}.{minor}.{patch}",
]