forked from opsmill/infrahub-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyproject.toml
285 lines (258 loc) · 10.7 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
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
[tool.poetry]
name = "infrahub-sync"
version = "1.0.1"
description = "Infrahub-Sync is a versatile Python package that synchronizes data between a source and a destination system"
authors = ["OpsMill <[email protected]>"]
readme = "README.md"
license = "Apache-2.0"
homepage = "https://opsmill.com"
repository = "https://github.com/opsmill/infrahub"
documentation = "https://docs.infrahub.app/integrations/sync/"
packages = [{ include = "infrahub_sync" }]
classifiers = [
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
[tool.poetry.dependencies]
python = ">=3.9, < 3.13"
infrahub-sdk = {version = "^1", extras = ["all"]}
structlog = ">=22.3,<25.0"
diffsync = { version = ">=1.10,<2.0 || >=2.0", extras = ["redis"] }
netutils = ">=1.9"
tqdm = ">=4.66"
[tool.poetry.group.dev.dependencies]
pytest = "*"
pytest-clarity = "^1.0.1"
pytest-cov = ">=4,<7"
pytest-httpx = "*"
yamllint = "*"
pylint = "*"
mypy = "*"
ipython = "*"
pytest-asyncio = "*"
requests = "*"
pre-commit = ">=2.20,<5.0"
types-toml = "*"
types-ujson = "*"
types-pyyaml = "*"
typer-cli = "*"
ruff = "0.7.2"
pytest-xdist = "^3.3.1"
types-python-slugify = ">=8.0.0.3"
[tool.poetry.scripts]
infrahub-sync = "infrahub_sync.cli:app"
[tool.pylint.general]
extension-pkg-whitelist = [
"pydantic",
"ujson",
]
[tool.pylint.format]
disable = "logging-fstring-interpolation"
[tool.pylint.basic]
# No docstrings required for private methods (Pylint default), or for test_ functions.
no-docstring-rgx="^(_|test_)"
[tool.pylint.messages_control]
# Line length is enforced by Black, so pylint doesn't need to check it.
# Pylint and Black disagree about how to format multi-line arrays; Black wins.
# assigning-non-slot,no-member,unsupported-membership-test,unsubscriptable-object,unsupported-assignment-operation,not-an-iterable
# are disabled because of our move to pydantic 2, pylint does not seem to respect the type hint for pydantic 2 model fields.
disable = """,
line-too-long,
missing-module-docstring,
missing-function-docstring,
missing-class-docstring,
consider-using-from-import,
invalid-name,
too-many-arguments,
too-many-locals,
keyword-arg-before-vararg,
too-few-public-methods,
too-many-instance-attributes,
fixme,
consider-using-f-string,
protected-access,
import-self,
wrong-import-order,
assigning-non-slot,
no-member,
unsupported-membership-test,
unsubscriptable-object,
unsupported-assignment-operation,
not-an-iterable,
multiple-statements,
"""
[tool.pylint.miscellaneous]
notes = """,
FIXME,
XXX,
"""
[tool.pylint.similarities]
min-similarity-lines = 20
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = [
"tests"
]
filterwarnings = [
"ignore:Module already imported so cannot be rewritten",
"ignore:the imp module is deprecated",
"ignore:Deprecated call to",
]
addopts = "-vs --cov-report term-missing --cov-report xml --dist loadscope"
[tool.mypy]
pretty = true
ignore_missing_imports = true
disallow_untyped_defs = true
disable_error_code = ["type-abstract"]
[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 = [
"ANN", # flake8-annotations
"ASYNC", # flake8-async
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"C90", # mccabe complexity
"DJ", # flake8-django
"DTZ", # flake8-datetimez
"E", # pycodestyle errors
"EXE", # flake8-executable
"F", # pyflakes
"I", # isort-like checks
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"N", # pep8-naming
"PERF", # Perflint
"PIE", # flake8-pie
"PL", # pylint
"PTH", # flake8-use-pathlib
"PYI", # flake8-pyi
"Q", # flake8-quotes
"RET", # flake8-return
"S", # flake8-bandit
"TCH", # flake8-type-checking
"T10", # flake8-debugger
"UP", # pyupgrade
"W", # pycodestyle warnings
"YTT", # flake8-2020
]
ignore = [
##################################################################################################
# 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. #
##################################################################################################
"ASYNC230", # Async functions should not open files with blocking methods like `open`
"ASYNC251", # Async functions should not call `time.sleep`
"B007", # Loop control variable not used within loop body
"B008", # Do not perform function call `Depends` in argument defaults;
"B009", # [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access.
"B010", # [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access.
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
"C403", # Unnecessary `list` comprehension (rewrite as a `set` comprehension)
"C409", # Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal)
"C414", # Unnecessary `list` call within `sorted()`
"N801", # Class name should use CapWords convention
"N802", # Function name should be lowercase
"N805", # First argument of a method should be named self
"N806", # Variable in function should be lowercase
"N812", # Lowercase imported as non-lowercase
"PERF203", # `try`-`except` within a loop incurs performance overhead
"PERF401", # Use a list comprehension to create a transformed list
"PERF402", # Use `list` or `list.copy` to create a copy of a list
"PERF403", # Use a dictionary comprehension instead of a for-loop
"PLC0415", # `import` should be at the top-level of a file
"PLC2701", # Private name import from external module
"PLR0904", # Too many public methods
"PLR0912", # Too many branches
"PLR0913", # Too many arguments in function definition
"PLR0914", # Too many local variables
"PLR0915", # Too many statements
"PLR0916", # Too many Boolean expressions
"PLR0917", # Too many positional arguments
"PLR1702", # Too many nested blocks
"PLR2004", # Magic value used in comparison this could possibly be fine in the tests folders
"PLR6201", # Use a `set` literal when testing for membership
"PLR6301", # Method could be a function, class method, or static method
"PLW0603", # Using the global statement to update `SETTINGS` is discouraged
"PLW1508", # Invalid type for environment variable default; expected `str` or `None`
"PLW3201", # Bad or misspelled dunder method name `__init_subclass_with_meta__`
"PTH100", # `os.path.abspath()` should be replaced by `Path.resolve()`
"PTH102", # `os.mkdir()` should be replaced by `Path.mkdir()`
"PTH103", # `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
"PTH107", # `os.remove()` should be replaced by `Path.unlink()`
"PTH108", # `os.unlink()` should be replaced by `Path.unlink()`
"PTH109", # `os.getcwd()` should be replaced by `Path.cwd()`
"PTH110", # `os.path.exists()` should be replaced by `Path.exists()`
"PTH112", # `os.path.isdir()` should be replaced by `Path.is_dir()`
"PTH113", # `os.path.isfile()` should be replaced by `Path.is_file()`
"PTH117", # `os.path.isabs()` should be replaced by `Path.is_absolute()`
"PTH118", # `os.path.join()` should be replaced by `Path` with `/` operator
"RET503", # Missing explicit `return` at the end of function able to return non-`None` value
"RET504", # Unnecessary assignment before `return` statement
"S101", # Use of `assert` detected
"S105", # Possible hardcoded password assigned to: "REGEX_PASSWORD"
"S108", # Probable insecure usage of temporary file or directory
"S202", # Uses of `tarfile.extractall()`
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
"S701", # By default, jinja2 sets `autoescape` to `False`. Consider using `autoescape=True`
"UP007", # Use X | Y for type annotations
"UP012", # Unnecessary call to encode as UTF-8
"UP018", # Unnecessary {literal_type} call (rewrite as a literal)
"UP031", # Use format specifiers instead of percent format
"UP034", # Avoid extraneous parentheses
]
#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 = 33
[tool.ruff.lint.per-file-ignores]
"infrahub_sync/**.py" = [
##################################################################################################
# Review and change the below later #
##################################################################################################
"ANN001", # Missing type annotation for function argument
"ANN002", # Missing type annotation for `*args`
"ANN003", # Missing type annotation for `**kwargs`
"ANN201", # Missing return type annotation for public function
"ANN202", # Missing return type annotation for private function
"ANN204", # Missing return type annotation for special method
"ANN205", # Missing return type annotation for staticmethod
"ANN206", # Missing return type annotation for classmethod
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
]
"infrahub_sync/adapters/**.py" = [
"INP001", # Is part of an implicit namespace package
##################################################################################################
# Review and change the below later #
##################################################################################################
"C416", # Unnecessary `list` comprehension
]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"