-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpyproject.toml
More file actions
496 lines (407 loc) · 15.3 KB
/
pyproject.toml
File metadata and controls
496 lines (407 loc) · 15.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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
[project]
name = "infrahub-sdk"
version = "1.19.0"
description = "Python Client to interact with Infrahub"
authors = [
{name = "OpsMill", email = "info@opsmill.com"}
]
readme = "README.md"
license = {text = "Apache-2.0"}
requires-python = ">=3.10,<3.15"
classifiers = [
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dependencies = [
"pydantic>=2.0.0,!=2.0.1,!=2.1.0,<3.0.0",
"pydantic-settings>=2.0",
"graphql-core>=3.1,<3.3",
"httpx>=0.20",
"ujson>=5",
"dulwich>=0.24.7",
"whenever>=0.9.3,<0.10.0",
"netutils>=1.0.0",
"tomli>=1.1.0; python_version<'3.11'",
]
[project.urls]
Homepage = "https://opsmill.com"
Repository = "https://github.com/opsmill/infrahub-sdk-python"
Documentation = "https://docs.infrahub.app/python-sdk/introduction"
[project.scripts]
infrahubctl = "infrahub_sdk.ctl.cli:app"
[project.entry-points."pytest11"]
"pytest-infrahub" = "infrahub_sdk.pytest_plugin.plugin"
[project.optional-dependencies]
ctl = [
"Jinja2>=3",
"numpy>=1.24.2; python_version<'3.12'",
"numpy>=1.26.2; python_version>='3.12'",
"pyarrow>=14",
"pyyaml>=6",
"rich>=12,<14",
"typer>=0.12.5",
"click==8.1.*",
"ariadne-codegen==0.15.3",
"mdxify>=0.2.23; python_version>='3.10'",
]
all = [
"Jinja2>=3",
"numpy>=1.24.2; python_version<'3.12'",
"numpy>=1.26.2; python_version>='3.12'",
"pyarrow>=14",
"pytest",
"pyyaml>=6",
"rich>=12,<14",
"typer>=0.12.5",
"click==8.1.*",
"ariadne-codegen==0.15.3",
]
[dependency-groups]
# Core optional dependencies
tests = [
"infrahub-testcontainers>=1.7.3",
"pytest>=9.0,<9.1",
"pytest-asyncio>=1.3,<1.4",
"pytest-clarity>=1.0.1",
"pytest-cov>=4.0.0",
"pytest-httpx>=0.30",
"pytest-xdist>=3.3.1",
]
lint = [
"yamllint",
"mypy==1.11.2",
"ruff==0.15.0",
"astroid>=3.1,<4.0",
"ty==0.0.14",
]
types = [
"types-ujson",
"types-pyyaml",
"types-python-slugify>=8.0.0.3",
]
dev = [
{include-group = "tests"},
{include-group = "lint"},
{include-group = "types"},
"ipython",
"requests",
"prek>=0.3.0",
"codecov",
"invoke>=2.2.0",
"towncrier>=24.8.0",
]
[tool.coverage.run]
branch = true
[tool.coverage.report]
exclude_lines = ["if TYPE_CHECKING:", "raise NotImplementedError()"]
[tool.pytest.ini_options]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "session"
testpaths = ["tests"]
filterwarnings = [
"ignore:Module already imported so cannot be rewritten",
"ignore:Deprecated call to",
]
addopts = "-vs --cov-report term-missing --cov-report xml --dist loadscope"
[tool.ty]
[tool.ty.environment]
python-version = "3.10"
[[tool.ty.overrides]]
include = ["infrahub_sdk/**"]
[tool.ty.overrides.rules]
unused-ignore-comment = "ignore" # Clashes with mypy's type ignore comments
# File-specific overrides for remaining type violations
# Fix these incrementally by addressing violations and removing the override
[[tool.ty.overrides]]
include = ["infrahub_sdk/checks.py"]
[tool.ty.overrides.rules]
invalid-await = "ignore" # 1 violation
[[tool.ty.overrides]]
include = ["infrahub_sdk/file_handler.py", "infrahub_sdk/utils.py"]
[tool.ty.overrides.rules]
unresolved-attribute = "ignore" # 5 violations total (1 in file_handler.py, 4 in utils.py)
[[tool.ty.overrides]]
include = ["infrahub_sdk/transfer/**"]
[tool.ty.overrides.rules]
invalid-argument-type = "ignore" # 2 violations in importer/json.py
invalid-assignment = "ignore" # 1 violation in importer/json.py
[[tool.ty.overrides]]
include = ["infrahub_sdk/node/node.py"]
[tool.ty.overrides.rules]
invalid-argument-type = "ignore" # 9 violations - lines 776, 855, 859, 862
[[tool.ty.overrides]]
include = ["infrahub_sdk/ctl/config.py"]
[tool.ty.overrides.rules]
unresolved-import = "ignore" # import tomli as tomllib when running on later versions of Python
[[tool.ty.overrides]]
include = ["tests/**"]
[tool.ty.overrides.rules]
unused-ignore-comment = "ignore" # Clashes with mypy's type ignore comments
[[tool.ty.overrides]]
include = ["tests/fixtures/**"]
[tool.ty.overrides.rules]
invalid-argument-type = "ignore" # Test fixtures - dynamic mock data
possibly-missing-attribute = "ignore" # Test fixtures use dynamic attributes
# Test-specific overrides - tests have more lenient type checking
# Fix these incrementally, starting with files that have fewer violations
[[tool.ty.overrides]]
include = ["tests/unit/sdk/conftest.py"]
[tool.ty.overrides.rules]
invalid-argument-type = "ignore" # 434 violations - test fixtures with dynamic types
[[tool.ty.overrides]]
include = [
"tests/unit/sdk/test_node.py",
"tests/unit/sdk/test_hierarchical_nodes.py",
"tests/unit/sdk/test_schema.py",
]
[tool.ty.overrides.rules]
invalid-argument-type = "ignore" # 97 violations total across these files
invalid-assignment = "ignore"
not-subscriptable = "ignore"
not-iterable = "ignore"
unresolved-attribute = "ignore"
possibly-missing-attribute = "ignore"
[[tool.ty.overrides]]
include = [
"tests/integration/**",
"tests/unit/sdk/test_store_branch.py",
"tests/unit/sdk/test_repository.py",
]
[tool.ty.overrides.rules]
invalid-argument-type = "ignore" # ~120 violations across integration tests
invalid-assignment = "ignore"
no-matching-overload = "ignore"
possibly-missing-attribute = "ignore" # Tests use dynamic node attributes
[[tool.ty.overrides]]
include = [
"tests/unit/sdk/spec/test_object.py",
"tests/unit/sdk/test_client.py",
"tests/unit/ctl/test_graphql_utils.py",
]
[tool.ty.overrides.rules]
invalid-argument-type = "ignore" # 29 violations
invalid-assignment = "ignore"
no-matching-overload = "ignore"
possibly-missing-attribute = "ignore"
[[tool.ty.overrides]]
include = [
"tests/unit/sdk/test_artifact.py",
"tests/unit/sdk/test_group_context.py",
"tests/unit/sdk/test_utils.py",
"tests/unit/sdk/checks/test_checks.py",
"tests/unit/sdk/graphql/test_plugin.py",
"tests/unit/sdk/test_protocols_generator.py",
"tests/unit/sdk/test_schema_sorter.py",
"tests/unit/sdk/test_topological_sort.py",
"tests/unit/sdk/test_schema_export.py",
]
[tool.ty.overrides.rules]
invalid-argument-type = "ignore" # Remaining files with 1-5 violations each
invalid-method-override = "ignore"
no-matching-overload = "ignore"
[[tool.ty.overrides]]
include = ["docs/**"]
[tool.ty.overrides.rules]
##################################################################################################
# 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. #
##################################################################################################
invalid-assignment = "ignore"
[tool.mypy]
pretty = true
ignore_missing_imports = true
disallow_untyped_defs = true
[[tool.mypy.overrides]]
module = "infrahub_sdk.ctl.check"
disable_error_code = ["call-overload"]
[[tool.mypy.overrides]]
module = "infrahub_sdk.utils"
disable_error_code = ["arg-type", "attr-defined", "return-value", "union-attr"]
[tool.ruff]
line-length = 120
exclude = [
".git",
".tox",
".venv",
"env",
"_build",
"build",
"dist",
"examples",
"tests/fixtures/unit/test_graphql_plugin",
]
[tool.ruff.lint]
preview = true
task-tags = ["FIXME", "TODO", "XXX"]
select = ["ALL"]
ignore = [
"D", # pydocstyle
"DOC", # pydoclint
"CPY", # flake8-copyright
"T201", # use of `print`
"COM812", # missing-trailing-comma
##################################################################################################
# Rules below needs to be Investigated #
##################################################################################################
"ERA", # eradicate commented-out code
"SLF001", # flake8-self
"EM", # flake8-errmsg
"TRY", # tryceratops
"TD", # flake8-todos
"FIX", # flake8-fixme
"TID", # flake8-tidy-imports
"FBT", # flake8-boolean-trap
"G", # flake8-logging-format
"BLE", # flake8-blind-except (BLE)
##################################################################################################
# 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. #
##################################################################################################
"B008", # Do not perform function call `typer.Option` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
"N802", # Function name should be lowercase
"PERF203", # `try`-`except` within a loop incurs performance overhead
"PLR0913", # Too many arguments in function definition
"PLR0917", # Too many positional arguments
"PLR2004", # Magic value used in comparison
"PLR6301", # Method could be a function, class method, or static method
"RUF029", # Function is declared `async`, but doesn't `await` or use `async` features.
"RUF067", # `__init__` module should only contain docstrings and re-exports
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
"TC003", # Move standard library import `collections.abc.Iterable` into a type-checking block
"UP031", # Use format specifiers instead of percent format
]
#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.flake8-builtins]
ignorelist = [
"id",
# Review and update builtin shadowing below this line
"filter",
"format",
"property",
]
[tool.ruff.lint.isort]
known-first-party = ["infrahub_sdk", "infrahub_ctl"]
[tool.ruff.lint.pycodestyle]
max-line-length = 150
[tool.ruff.lint.mccabe]
# Target max-complexity=10
max-complexity = 17
[tool.ruff.lint.per-file-ignores]
"infrahub_sdk/**/*.py" = [
##################################################################################################
# Review and change the below later #
##################################################################################################
"ANN202", # Missing return type annotation for private function
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"ASYNC240", # Async functions should not use pathlib.Path methods, use trio.Path or anyio.path
]
"infrahub_sdk/client.py" = [
##################################################################################################
# Review and change the below later #
##################################################################################################
"PLR0904", # Too many public methods
]
"infrahub_sdk/node/node.py" = [
##################################################################################################
# Review and change the below later #
##################################################################################################
"PLR0912", # Too many branches
"PLR0904", # Too many public methods
]
"infrahub_sdk/node/related_node.py" = [
##################################################################################################
# Review and change the below later #
##################################################################################################
"PLR0912", # Too many branches
]
"infrahub_sdk/pytest_plugin/models.py" = [
"S105", # 'PASS' is not a password but a state
]
"infrahub_sdk/template/__init__.py" = [
##################################################################################################
# Review and change the below later #
##################################################################################################
"S701", # By default, jinja2 sets `autoescape` to `False`. Consider using `autoescape=True` or the `select_autoescape` function to mitigate XSS vulnerabilities.
]
"infrahub_sdk/spec/object.py" = [
##################################################################################################
# Review and change the below later #
##################################################################################################
"PLR0912", # Too many branches
]
"infrahub_sdk/transfer/importer/json.py" = [
##################################################################################################
# Review and change the below later #
##################################################################################################
"PLR0912", # Too many branches
]
"tests/**/*.py" = [
"PLR2004", # Magic value used in comparison
"S101", # Use of assert detected
"S105", # Possible hardcoded password assigned to variable
"S106", # Possible hardcoded password assigned to argument
"ARG001", # Unused function argument
"ARG002", # Unused method argument
"PT011", # `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception
"PT012", # `pytest.raises()` block should contain a single simple statement
]
# tests/integration/
"tests/integration/test_infrahub_client.py" = ["PLR0904"]
"tests/integration/test_infrahub_client_sync.py" = ["PLR0904"]
"tasks.py" = [
"PLC0415", # `import` should be at the top-level of a file
]
[tool.towncrier]
package = "infrahub_sdk"
directory = "changelog"
filename = "CHANGELOG.md"
start_string = "<!-- towncrier release notes start -->\n"
underlines = ["", "", ""]
title_format = "## [{version}](https://github.com/opsmill/infrahub-sdk-python/tree/v{version}) - {project_date}"
issue_format = "[#{issue}](https://github.com/opsmill/infrahub-sdk-python/issues/{issue})"
orphan_prefix = "+"
template = "changelog/towncrier.md.template"
[[tool.towncrier.type]]
directory = "security"
name = "Security"
showcontent = true
[[tool.towncrier.type]]
directory = "removed"
name = "Removed"
showcontent = true
[[tool.towncrier.type]]
directory = "deprecated"
name = "Deprecated"
showcontent = true
[[tool.towncrier.type]]
directory = "added"
name = "Added"
showcontent = true
[[tool.towncrier.type]]
directory = "changed"
name = "Changed"
showcontent = true
[[tool.towncrier.type]]
directory = "fixed"
name = "Fixed"
showcontent = true
[[tool.towncrier.type]]
directory = "housekeeping"
name = "Housekeeping"
showcontent = true
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["infrahub_sdk"]