ruff.toml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # Ruff configuration
  2. ####################
  3. exclude = [
  4. ".eggs",
  5. ".git",
  6. ".pyenv",
  7. ".pytest_cache",
  8. ".ruff_cache",
  9. ".venv",
  10. ".vscode",
  11. "__pypackages__",
  12. "_build",
  13. "build",
  14. "dist",
  15. "netbox/project-static/**",
  16. "node_modules",
  17. "site-packages",
  18. "venv",
  19. ]
  20. # Enforce line length and indent-width
  21. line-length = 120
  22. indent-width = 4
  23. # Ignores anything in .gitignore
  24. respect-gitignore = true
  25. # Always generate Python 3.12-compatible code
  26. target-version = "py312"
  27. [lint]
  28. # Pin the effective default rule set used with `preview = true` to match Ruff 0.15.1.
  29. # Ruff 0.15.2 changed the preview defaults, see https://github.com/astral-sh/ruff/releases/tag/0.15.2
  30. # Keeping this explicit makes ruff deterministic.
  31. select = ["E4", "E7", "E9", "F"]
  32. extend-select = [
  33. "E1", # pycodestyle errors: indentation-related (e.g., unexpected/missing indent)
  34. "E2", # pycodestyle errors: whitespace-related (e.g., missing whitespace, extra spaces)
  35. "E3", # pycodestyle errors: blank lines / spacing around definitions
  36. "E501", # pycodestyle: line too long (enforced with `line-length` above)
  37. "W", # pycodestyle warnings (various style warnings, often whitespace/newlines)
  38. "I", # import sorting (isort-equivalent)
  39. "RET", # return semantics (flake8-return family: consistent/explicit returns; remove redundant else/assign before return)
  40. "UP", # pyupgrade: modernize syntax for your target Python (e.g., f-strings, built-in generics, newer stdlib idioms)
  41. "RUF022", # ruff: enforce sorted `__all__` lists
  42. ]
  43. ignore = [
  44. "F403", # pyflakes: `from ... import *` used; unable to detect undefined names
  45. "F405", # pyflakes: name may be undefined or defined from star imports
  46. "RET504", # return: unnecessary assignment before `return` (e.g., `x = expr; return x` -> `return expr`)
  47. "UP032", # pyupgrade: prefer f-strings over `str.format(...)`
  48. ]
  49. preview = true
  50. [lint.isort]
  51. known-first-party = [
  52. "account",
  53. "circuits",
  54. "core",
  55. "dcim",
  56. "extras",
  57. "ipam",
  58. "netbox",
  59. "tenancy",
  60. "users",
  61. "utilities",
  62. "virtualization",
  63. "vpn",
  64. "wireless",
  65. ]
  66. [lint.per-file-ignores]
  67. "template_code.py" = ["E501"]
  68. "netbox/netbox/graphql/filter_lookups.py" = ["UP046"] # Strawberry typing: keep `Generic[T]` for now
  69. "netbox/netbox/graphql/scalars.py" = ["UP007"] # Strawberry scalar typing: `Union[...]` required
  70. [format]
  71. # Use single quotes for strings.
  72. quote-style = "single"
  73. # Indent with spaces, rather than tabs.
  74. indent-style = "space"
  75. # Enforce UNIX line ending
  76. line-ending = "lf"