Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
375 lines (336 loc) · 16.1 KB
/
Copy pathpyproject.toml
File metadata and controls
375 lines (336 loc) · 16.1 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
# See PEP 517 / PEP 621 for the spec of this file.
#
# This pyproject.toml is generated from the NetBox Labs plugin scaffold.
# The NetBox version range this plugin supports lives in PluginConfig
# (see netbox_scripts/__init__.py: min_version / max_version),
# not here. Update both places when you bump the supported range.
#
# [tool.*] sections are sorted alphabetically by top-level tool name.
# Keep [tool.ruff] in this file; do not introduce a separate ruff.toml
# or .ruff.toml. Sub-tables under each tool (e.g. [tool.ruff.lint.*],
# [tool.setuptools.packages.find]) preserve their natural reading order.
[build-system]
requires = ["setuptools>=77.0.3"]
build-backend = "setuptools.build_meta"
[project]
name = "netbox-scripts"
version = "0.2.0"
description = "Custom Scripts for NetBox"
readme = { file = "README.md", content-type = "text/markdown" }
license = "Apache-2.0"
license-files = ["LICENSE"]
requires-python = ">=3.12"
authors = [
{ name = "NetBox Labs", email = "support@netboxlabs.com" },
]
maintainers = [
{ name = "NetBox Labs", email = "support@netboxlabs.com" },
]
keywords = ["netbox", "netbox-plugin"]
classifiers = [
"Development Status :: 4 - Beta",
"Framework :: Django",
"Framework :: Django :: 6.1",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Intended Audience :: Telecommunications Industry",
"Natural Language :: English",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: System :: Networking",
]
[project.urls]
Homepage = "https://github.com/netbox-community/netbox-scripts"
Documentation = "https://netbox-community.github.io/netbox-scripts/"
Source = "https://github.com/netbox-community/netbox-scripts"
Issues = "https://github.com/netbox-community/netbox-scripts/issues"
Changelog = "https://github.com/netbox-community/netbox-scripts/releases"
[project.optional-dependencies]
# Pinned for reproducible CI; items 4 and 5 may extend each group.
dev = [
"build==1.6.0",
"twine==7.0.0",
]
test = [
"check-manifest==0.51",
"coverage[toml]==7.16.0",
"moto[s3]==5.2.3",
"tblib==3.2.2",
]
docs = [
"mkdocs==1.6.1",
"mkdocs-material==9.7.7",
"zensical==0.0.59",
]
[tool.check-manifest]
# Files tracked in git but intentionally excluded from sdist/wheel.
# These are dev-tooling / project-meta files, not Python distribution content.
ignore = [
".git-blame-ignore-revs",
".pre-commit-config.yaml",
"AGENTS.md",
"CLAUDE.md",
"COMPATIBILITY.md",
"CONTRIBUTING.md",
"SECURITY.md",
"docs/*.md",
"docs/user-guide/*.md",
"docs/administration/*.md",
"docs/reference/*.md",
"docs/reference/models/*.md",
"docs/development/*.md",
"mkdocs.yml",
"testing/*.py",
# Per-view query-count baseline: test-only tooling, not distribution content.
"netbox_scripts/tests/query_counts.json",
# Pre-commit hook script, not distribution content.
"scripts/check_cloud_compat.py",
# CI canary script, not distribution content.
"scripts/check_netbox_internals.py",
"uv.lock",
".github/ISSUE_TEMPLATE/*.yaml",
".github/ISSUE_TEMPLATE/config.yml",
".github/codeql/*.yml",
".github/labels.yml",
".github/pull_request_template.md",
".github/workflows/*.yml",
]
[tool.codespell]
# Path patterns relative to repo root; extend as needed per plugin.
skip = "*.po,*.lock,*.svg,*.min.js,*.min.css,docs/_build,site,build,dist,.git"
# Add comma-separated tokens here when a plugin needs to whitelist false-positives.
# Leave commented when empty: codespell's pyproject parser rejects ignore-words-list = "".
count = true
[tool.coverage.run]
source = ["netbox_scripts"]
omit = [
"*/migrations/*",
"*/tests/*",
]
concurrency = ["multiprocessing"]
parallel = true
sigterm = true
[tool.coverage.report]
show_missing = true
skip_covered = false
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
]
[tool.djlint]
# NetBox templates follow Django conventions.
profile = "django"
indent = 2
max_line_length = 120
# Conservative ignore set; document each addition with a one-line comment.
# H006: image without explicit height/width (NetBox UI conventions).
# H013: image without alt attribute (NetBox icon helpers often omit).
# H023: entity-encoded characters in templates (intentional in NetBox).
# H030: meta description tag (NetBox sets at base template).
# H031: meta keywords tag (NetBox sets at base template).
ignore = "H006,H013,H023,H030,H031"
[tool.ruff]
exclude = [
".eggs",
".git",
".pyenv",
".pytest_cache",
".ruff_cache",
".venv",
".vscode",
"__pypackages__",
"_build",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]
# Enforce line length and indentation width.
line-length = 120
indent-width = 4
# Ignore files and directories listed in .gitignore.
respect-gitignore = true
# Generate and lint against the lowest-supported Python (python_version prompt).
target-version = "py312"
[tool.ruff.lint]
# Pin the effective default rule set used with `preview = true` to match Ruff 0.15.1.
# Ruff 0.15.2 changed the preview defaults:
# https://github.com/astral-sh/ruff/releases/tag/0.15.2
# Keeping this explicit makes Ruff deterministic instead of inheriting future preview-default changes.
select = [
"E4", # pycodestyle: import/module-level errors from Ruff's historical default set.
"E7", # pycodestyle: statement/style errors from Ruff's historical default set.
"E9", # pycodestyle: syntax/runtime-adjacent errors from Ruff's historical default set.
"F", # pyflakes: undefined names, unused imports, and other likely bugs.
]
extend-select = [
# Baseline style and modernization checks.
"E1", # pycodestyle: indentation errors.
"E2", # pycodestyle: whitespace around operators and delimiters.
"E3", # pycodestyle: blank-line spacing around definitions.
"E501", # pycodestyle: line length for Python code.
"W", # pycodestyle warnings: tabs, invalid escapes, and other warning-level style issues.
"W505", # pycodestyle: documentation/comment line length; enabled by `lint.pycodestyle.max-doc-length`.
"D", # pydocstyle: docstring style and coverage, per `lint.pydocstyle.convention`.
"I", # isort: keep imports grouped and sorted consistently.
"UP", # pyupgrade: use modern Python syntax supported by `target-version`.
"C4", # flake8-comprehensions: remove unnecessary or misleading comprehension patterns.
"ISC", # flake8-implicit-str-concat: catch accidental implicit/explicit string concatenation.
"RET", # flake8-return: keep return paths explicit and consistent.
"SIM", # flake8-simplify: catch straightforward simplification opportunities.
"PTH", # flake8-use-pathlib: prefer pathlib APIs over os/os.path where practical.
# Django/i18n safety. These pair well with NetBox's UP032 ignore because translation
# strings should remain statically extractable rather than being interpolated first.
"INT", # flake8-gettext: prevent f-string, .format(), and %-formatting inside gettext calls.
# Accidental debug code.
"T100", # flake8-debugger: catch breakpoint(), pdb, and similar debug statements before merge.
# Executable/shebang hygiene for scripts.
"EXE001", # flake8-executable: shebang is present but the file is not executable.
"EXE002", # flake8-executable: file is executable but no shebang is present.
"EXE004", # flake8-executable: shebang has leading whitespace.
"EXE005", # flake8-executable: shebang is not on the first line.
# Logging correctness.
"G010", # flake8-logging-format: replace deprecated logging.warn() with logging.warning().
"G101", # flake8-logging-format: prevent logging extra= keys from clashing with LogRecord fields.
"G201", # flake8-logging-format: prefer logging.exception() over logging.error(..., exc_info=True).
"G202", # flake8-logging-format: avoid redundant exc_info=True with logging.exception().
"LOG001", # flake8-logging: avoid direct Logger construction; use logging.getLogger().
"LOG002", # flake8-logging: require a valid logging.getLogger() argument.
"LOG014", # flake8-logging: avoid exc_info= outside exception handlers.
"LOG015", # flake8-logging: avoid root logger calls; use module loggers.
"PLE1205", # Pylint: too many arguments supplied to a logging format string.
"PLE1206", # Pylint: too few arguments supplied to a logging format string.
# Timezone-aware datetime usage. This is especially relevant in a Django app.
"DTZ003", # flake8-datetimez: avoid datetime.utcnow(); prefer aware UTC datetimes.
"DTZ005", # flake8-datetimez: avoid datetime.now() without a timezone.
"DTZ006", # flake8-datetimez: avoid datetime.fromtimestamp() without a timezone.
"DTZ901", # flake8-datetimez: avoid naive datetime.min/datetime.max sentinels.
# Bugbear correctness checks.
"B002", # flake8-bugbear: catch ++x/--x, which do not increment/decrement in Python.
"B004", # flake8-bugbear: avoid unreliable callable checks based on __call__.
"B005", # flake8-bugbear: catch likely misuse of str.strip() with multi-character strings.
"B006", # flake8-bugbear: prevent mutable default arguments.
"B008", # flake8-bugbear: prevent function calls in default arguments.
"B012", # flake8-bugbear: avoid return/break/continue inside finally blocks.
"B013", # flake8-bugbear: catch redundant tuples in exception handlers.
"B014", # flake8-bugbear: catch duplicate exception classes in handlers.
"B016", # flake8-bugbear: catch invalid raise of literals.
"B018", # flake8-bugbear: catch useless expressions that are likely forgotten code.
"B020", # flake8-bugbear: catch loop variables that override the iterator variable.
"B023", # flake8-bugbear: catch late-binding loop-variable closures.
"B025", # flake8-bugbear: catch duplicate exceptions across try/except handlers.
"B029", # flake8-bugbear: catch except () handlers, which catch nothing.
"B030", # flake8-bugbear: catch except handlers using non-exception classes.
"B033", # flake8-bugbear: catch duplicate values where uniqueness is expected.
"B035", # flake8-bugbear: catch dict comprehensions with static keys.
"B039", # flake8-bugbear: prevent mutable defaults for context variables.
# Ruff-specific correctness and maintenance checks.
# RUF009 is intentionally not selected: Strawberry Django uses calls such as
# strawberry_django.filter_field() as dataclass field metadata, not as shared mutable defaults.
"RUF008", # Ruff: prevent mutable dataclass defaults.
"RUF016", # Ruff: catch invalid index types.
"RUF018", # Ruff: catch assignment expressions inside assert statements.
"RUF022", # Ruff: keep __all__ lists sorted.
"RUF024", # Ruff: prevent shared mutable values from dict.fromkeys().
"RUF026", # Ruff: catch suspicious default_factory usage.
"RUF028", # Ruff: catch invalid formatter suppression comments.
"RUF030", # Ruff: avoid print() calls as assert messages.
"RUF032", # Ruff: avoid constructing Decimal from float literals.
"RUF040", # Ruff: catch invalid assert message literal arguments.
"RUF041", # Ruff: remove unnecessary nested Literal types.
"RUF046", # Ruff: remove unnecessary int() casts.
"RUF051", # Ruff: prefer dict.pop() over key-in-dict followed by del.
"RUF057", # Ruff: remove unnecessary round() calls on integers.
"RUF059", # Ruff: catch unused unpacked variables that should be named "_".
"RUF100", # Ruff: keep noqa comments from going stale.
"RUF101", # Ruff: catch noqa comments that target redirected or renamed rules.
"RUF200", # Ruff: validate pyproject.toml metadata against the relevant PEP schemas.
# Security-adjacent control-flow checks. These may need targeted noqa comments in
# rare intentional cases, but silent failure and dynamic execution should be explicit.
"S102", # flake8-bandit: flag exec(); intentional dynamic execution should be documented.
"S110", # flake8-bandit: flag try/except/pass; silent failure should be visible.
"S112", # flake8-bandit: flag try/except/continue; silent failure in loops should be visible.
# Test/mock correctness.
"PGH005", # pygrep-hooks: catch invalid access to mock attributes.
# Note: SLF is intentionally not selected for now. NetBox has legitimate internal
# and test code that reaches into framework/private members, and SLF currently maps
# to the very broad private-member-access rule.
]
# If you add a rule to `ignore`, document the rationale inline below AND in the
# plugin's developer-facing docs so reviewers can see why the exception was granted.
ignore = [
"D100", # pydocstyle: missing docstring in public module. Module docstrings are added where they earn their keep.
"D104", # pydocstyle: missing docstring in public package. Package marker files carry no prose.
"D105", # pydocstyle: missing docstring in magic method. Dunder semantics are already known.
"D106", # pydocstyle: missing docstring in nested class. Django Meta classes are self-describing.
"D107", # pydocstyle: missing docstring in __init__. The class docstring covers construction.
"F403", # pyflakes: `from ... import *` used; unable to detect undefined names.
"F405", # pyflakes: name may be undefined or defined from star imports.
"RET504", # flake8-return: allow assigning to a named variable before returning for readability.
"SIM102", # flake8-simplify: allow nested if-statements where they make control flow clearer.
"SIM114", # flake8-simplify: allow separate if-branches when separate branches aid readability.
"UP032", # pyupgrade: keep str.format(...) available, especially for translation strings.
]
preview = true
[tool.ruff.lint.isort]
known-first-party = [
"account",
"circuits",
"core",
"dcim",
"extras",
"ipam",
"netbox",
"tenancy",
"users",
"utilities",
"virtualization",
"vpn",
"wireless",
"netbox_scripts",
]
[tool.ruff.lint.per-file-ignores]
"template_code.py" = ["E501"] # Generated/template code may exceed normal line length.
"netbox_scripts/__init__.py" = ["F822"] # PEP 562 lazy re-exports: the __all__ names resolve through module __getattr__ at runtime, invisible to static analysis.
"**/migrations/*.py" = ["D", "E501", "I"] # Django-generated migrations: no docstring coverage; long generated values; emitted in non-isort-canonical order.
"**/tests/*.py" = ["D"] # Tests do not require docstring coverage by default.
"**/__init__.py" = ["D104"] # Package marker files do not require public package docstrings.
[tool.ruff.lint.pycodestyle]
# Required for W505. Keep documentation/comment line length aligned with the overall
# line length unless the plugin's style guide adopts a separate docstring limit.
max-doc-length = 120
[tool.ruff.lint.pydocstyle]
# One of "google", "numpy", "pep257". Matches the other NetBox Labs plugins.
convention = "pep257"
# Decorators that make a method a property, so its docstring is held to the noun-phrase rule
# rather than the imperative-mood one. Without this, a cached_property is checked as a plain
# function and the two rules contradict each other.
property-decorators = ["django.utils.functional.cached_property"]
[tool.ruff.format]
# Use single quotes for strings.
quote-style = "single"
# Indent with spaces, rather than tabs.
indent-style = "space"
# Enforce UNIX line endings.
line-ending = "lf"
# Skip auto-format on Django-emitted migrations; their generated layout
# (multi-arg call wrapping, dict-in-call) is not Ruff-canonical and
# reformatting them produces noisy diffs without semantic value. This is
# additive over the top-level Ruff exclude defaults.
exclude = ["**/migrations/*.py"]
[tool.setuptools]
include-package-data = true
[tool.setuptools.packages.find]
where = ["."]
include = ["netbox_scripts*"]
[tool.setuptools.package-data]
"netbox_scripts" = [
"templates/**",
"static/**",
"locale/**/*.mo",
]