-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpyproject.toml
More file actions
230 lines (202 loc) · 6.69 KB
/
pyproject.toml
File metadata and controls
230 lines (202 loc) · 6.69 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
[project]
name = "infrahub_ansible_modules"
version = "1.8.0"
description = "Ansible collection to interact with Infrahub's API"
authors = [{name = "OpsMill", email = "info@opsmill.com"}]
license = {text = "GPLv3"}
requires-python = ">=3.10,<3.14"
dependencies = [
"ansible-core>=2.17.14",
"filelock>=3.20.1", # CVE-2025-68146: transitive dep of tox, pinned for security
"infrahub-sdk[all]>=1.5,<2.0",
"jinja2>=3.1.6",
]
[project.optional-dependencies]
numpy = [
"numpy>=1.24.2,<2; python_version>='3.9' and python_version<'3.12'",
"numpy>=1.26.2,<2; python_version>='3.12' and python_version<'3.13'",
"numpy>=2.1.0,<3; python_version>='3.13'",
]
[dependency-groups]
dev = [
"codecov",
"invoke>=2.2.1,<3",
"mypy>=1.15.0,<2",
"types-PyYAML>=6.0.12",
"ruff==0.15.7",
"mock>=5.2.0,<6",
"pytest>=9.0.2,<10",
"pytest-mock",
"pytest-xdist",
"pytest-pythonpath",
"ansible-lint>=26.2.0,<27",
"tox>=4.47.0,<5",
]
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = [
"tests"
]
pythonpath = ["."]
[tool.mypy]
pretty = true
ignore_missing_imports = true
disallow_untyped_defs = true
warn_return_any = true
warn_unused_ignores = true
# Exclude problematic module that has complex try/except patterns
exclude = [
"plugins/module_utils/infrahub_utils\\.py$",
]
[[tool.mypy.overrides]]
module = "tasks.*"
# Invoke Collection typing is overly strict about module types
disallow_untyped_defs = false
[tool.pyright]
# Disable pyright - we use mypy for type checking
# Many errors are due to Ansible/infrahub_sdk being runtime dependencies
reportMissingImports = false
reportPossiblyUnboundVariable = false
reportRedeclaration = false
reportAttributeAccessIssue = false
reportCallIssue = false
reportReturnType = false
reportOptionalMemberAccess = false
reportArgumentType = false
[tool.ruff]
line-length = 120
exclude = [
".git",
".tox",
".venv",
"env",
"_build",
"build",
"dist",
"examples",
]
[tool.ruff.lint]
preview = true
task-tags = [
"FIXME",
"TODO",
"XXX",
]
select = ["ALL"]
ignore = [
"COM812", # missing-trailing-comma
"CPY", # flake8-copyright
"D", # pydocstyle
"DOC", # pydoclint
"ISC", # flake8-implicit-str-concat
"FBT", # flake8-boolean-trap
##################################################################################################
# Rules below needs to be Investigated #
##################################################################################################
"PT", # flake8-pytest-style
"PGH", # pygrep-hooks
"ERA", # eradicate commented-out code
"SLF001", # flake8-self
"EM", # flake8-errmsg
"TRY", # tryceratops
"TD", # flake8-todos
"FIX", # flake8-fixme
"TID", # flake8-tidy-imports
"G", # flake8-logging-format
"FLY", # flynt
"RSE", # flake8-raise
"BLE", # flake8-blind-except (BLE)
"A", # flake8-builtins
##################################################################################################
# The ignored rules below should be removed once the code has been updated, they are included #
# like this so that we can reactivate them one by one. Alternatively ignored after further #
# investigation if they are deemed to not make sense. #
##################################################################################################
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
"C408", # Unnecessary `dict` call (rewrite as a literal)
"E402", # Module level import not at top of file
"INP001", # Is part of an implicit namespace package
"N806", # Variable in function should be lowercase
"PLC0415", # `import` should be at the top-level of a file
"PLR0912", # Too many branches
"PLR6201", # Use a `set` literal when testing for membership
"PLR6301", # Method could be a function, class method, or static method
"PLR1702", # Too many nested blocks
"PLR0913", # Too many arguments in function definition
"RET504", # Unnecessary assignment before `return` statement
]
[tool.ruff.lint.per-file-ignores]
"docs/**/*.py" = [
"ALL"
]
"plugins/**/*.py" = [
##################################################################################################
# Review and change the below later #
##################################################################################################
"ANN001", # Missing type annotation for function argument
"ANN201", # ANN201 Missing return type annotation for public function
"ANN202", # Missing return type annotation for private function
"ANN204", # Missing return type annotation for special method
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"F404", # `from __future__` imports must occur at the beginning of the file
"UP001", # `__metaclass__ = type` is implied
"UP010", # Unnecessary `__future__` imports
]
"tasks/*.py" = [
"T201", # use of `print`
]
"tasks/__init__.py" = [
"RUF067", # __init__ module re-exports (invoke task runner pattern)
"T201", # use of `print`
]
#https://docs.astral.sh/ruff/formatter/black/
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
[tool.ruff.lint.isort]
known-first-party = ["infrahub"]
[tool.ruff.lint.pycodestyle]
max-line-length = 150
[tool.ruff.lint.mccabe]
# Target max-complexity=10
max-complexity = 19
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build]
# Exclude docs from wheel - it contains node_modules and build artifacts
# Documentation should be accessed online, not bundled in the package
exclude = [
"docs/",
"tests/",
".github/",
".tox/",
".venv/",
"*.tar.gz",
]
[tool.hatch.build.targets.sdist]
include = [
"plugins/**/*",
"roles/**/*",
"meta/**/*",
"galaxy.yml",
"README.md",
"LICENSE.txt",
"CHANGELOG.rst",
"pyproject.toml",
]
[tool.hatch.build.targets.wheel]
# For Ansible collections distributed as wheels, we need to include the
# collection structure (plugins, roles, meta) as data files, not Python packages.
# Using only-include ensures we get exactly what we need without bloat.
only-include = [
"plugins",
"roles",
"meta",
"galaxy.yml",
"README.md",
"LICENSE.txt",
"CHANGELOG.rst",
]