[build-system]
requires = ["setuptools>=50.3.2", "wheel", "setuptools-declarative-requirements", "setuptools_scm[toml]>=3.4"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "src/saltfactories/version.py"
write_to_template = "# pylint: skip-file\n\n__version__ = \"{version}\"\n"

[tool.towncrier]
package = "saltfactories"
filename = "CHANGELOG.rst"
directory = "changelog/"
title_format = "{version} ({project_date})"
issue_format = "`#{issue} <https://github.com/saltstack/pytest-salt-factories/issues/{issue}>`_"

  [[tool.towncrier.type]]
  directory = "breaking"
  name = "Breaking Changes"
  showcontent = true

  [[tool.towncrier.type]]
  directory = "deprecation"
  name = "Deprecations"
  showcontent = true

  [[tool.towncrier.type]]
  directory = "feature"
  name = "Features"
  showcontent = true

  [[tool.towncrier.type]]
  directory = "improvement"
  name = "Improvements"
  showcontent = true

  [[tool.towncrier.type]]
  directory = "bugfix"
  name = "Bug Fixes"
  showcontent = true

  [[tool.towncrier.type]]
  directory = "doc"
  name = "Improved Documentation"
  showcontent = true

  [[tool.towncrier.type]]
  directory = "trivial"
  name = "Trivial/Internal Changes"
  showcontent = true

[tool.ruff]
line-length = 120
select = [
  "ALL",
]
unfixable = [
  "PT023",  # (pytest-incorrect-mark-parentheses-style)
]
show-fixes = true
show-source = true
target-version = "py37"
respect-gitignore = true
src = [
  "src",
  "test"
]
extend-exclude = [
  ".nox",
  "examples",
]
extend-include = [
  "setup.py",
  "noxfile.py",
  "src/**/*.pyi",
]
ignore-init-module-imports = true
builtins = [
  "__opts__",
  "__salt__",
  "__context__",
  "__grains__",
  "__pillar__",
  "__salt_system_encoding__",
]
# Group violations by containing file.
ignore = [
  "ANN",     # annotations
  "PTH",     # Replace with pathlib.Path
  "D107",    # Missing docstring in `__init__`
  "D200",    # Reformat to one line
  "D212",    # Remove whitespace after opening quotes
  "COM",     # flake8-commas - Black takes care of this
  "ERA",     # eradicate
  "SIM108",  # Use ternary operator `A = X if Y else Z` instead of `if`-`else`-block
  "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
  "FBT001",  # Boolean positional arg in function definition
  "FBT002",  # Boolean default value in function definition
  "FBT003",  # Boolean positional value in function call
  "PT001",   # use @pytest.fixture() over @pytest.fixture
  "PT023",   # Use `@pytest.mark.<xyz>()` over `@pytest.mark.<xyz>`
]

[tool.ruff.per-file-ignores]
"src/saltfactories/utils/ports.py" = [
  "F403",
  "D100",     # Missing docstring in public module
]
"src/saltfactories/utils/ports.pyi" = [
  "F403",
  "D100",     # Missing docstring in public module
]
"src/saltfactories/utils/processes.py" = [
  "F403",
  "D100",     # Missing docstring in public module
]
"src/saltfactories/utils/processes.pyi" = [
  "F403",
  "D100",     # Missing docstring in public module
]
"src/saltfactories/utils/functional.py" = [
  "A003",     # Class attribute `id` is shadowing a Python builtin
  "BLE001",   # Do not catch blind exception: `Exception`
]
"src/saltfactories/utils/saltext/**/*.py" = [
  "ANN",    # Ignore missing type annotations
  "UP032",  # Use f-string instead of `format` call
]
"src/saltfactories/utils/saltext/log_handlers/pytest_log_handler.py" = [
  "BLE001",   # Do not catch blind exception: `Exception`
]
"src/**/*.py" = [
  "D104",     # Missing docstring in public package
]
"src/saltfactories/__main__.py" = [
  "T201",     # `print` found
]
"src/saltfactories/bases.py" = [
  "SLF001",   # Private member accessed
]
"src/saltfactories/manager.py" = [
  "SLF001",   # Private member accessed
  "D417",     # Missing argument descriptions in the docstring
  "PLR0913",  # Too many arguments to function call
]
"src/saltfactories/cli/cloud.py" = [
  "ARG003",   # Unused class method argument
]
"src/saltfactories/daemons/container.py" = [
  "ARG002",   # Unused method argument
  "BLE001",   # Do not catch blind exception: `Exception`
  "TD003",    # Missing issue link on the line following this TODO
  "FIX002",   # Line contains TODO, consider resolving the issue
]
"src/saltfactories/daemons/master.py" = [
  "D417",     # Missing argument descriptions in the docstring
]
"src/saltfactories/utils/markers.py" = [
  "SLF001",   # Private member accessed
]
"src/saltfactories/utils/coverage/sitecustomize.py" = [
  "D100",     # Missing docstring in public module
  "INP001",   # File * is part of an implicit namespace package. Add an `__init__.py`
]
"src/saltfactories/plugins/loader.py" = [
  "B018",   # Found useless expression. Either assign it to a variable or remove it.
  "SLF001",   # Private member accessed
]
"src/saltfactories/plugins/log_server.py" = [
  "BLE001",   # Do not catch blind exception: `Exception`
]
"tests/**/*.py" = [
  "ANN",      # Ignore missing type annotations in tests
  "PTH",      # Convert to pathlib.Path
  "ARG001",   # Unused function argument
  "D100",     # Missing docstring in public module
  "D102",     # Missing docstring in public method
  "D103",     # Missing docstring in public function
  "D104",     # Missing docstring in public package
  "DTZ003",   # The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
  "PLR2004",  # Magic value used in comparison, consider replacing 3 with a constant variable
  "PT007",    # Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`
  "RET504",   # Unnecessary variable assignment before `return` statement"
  "S101",     # Ignore the use of 'assert ...' in tests
  "S603",     # `subprocess` call: check for execution of untrusted input
  "SIM117",   # Use a single `with` statement with multiple contexts instead of nested `with` statements
  "TCH002",   # Move third-party import into a type-checking block
  "TCH003",   # Move standard library import `pathlib` into a type-checking block
  "SLF001",   # Private member accessed
  "D205",     # 1 blank line required between summary line and description
]
"tests/functional/loader/test_fixture_deps.py" = [
  "B018", # Found useless expression. Either assign it to a variable or remove it.
]
"tests/functional/loader/test_loader.py" = [
  "B018", # Found useless expression. Either assign it to a variable or remove it.
]
"setup.py" = [
  "D",
  "EXE001",   # Shebang is present but file is not executable
]
"noxfile.py" = [
  "D",
  "ANN",
  "PTH",
  "SLF001",
  "C901",
  "PLR0912",
  "DTZ005",
  "FBT002",
  "PLR0913", # Too many arguments to function call"
  "PLR0915", # Too many statements
]
"tools/**/*.py" = [
  "D104",     # Missing docstring in public package
]
[tool.ruff.pydocstyle]
# Use Google-style docstrings.
convention = "google"

[tool.ruff.isort]
combine-as-imports = false
force-single-line = true
known-first-party = ["src"]
forced-separate = ["tests"]

[tool.ruff.flake8-quotes]
docstring-quotes = "double"

[tool.ruff.mccabe]
max-complexity = 25

[tool.ruff.pylint]
max-args = 10
max-branches = 35
max-returns = 8

[tool.ruff.pep8-naming]
ignore-names = [
  "__virtual__",
]
