[build-system]
requires = ["flit_core >=3.7,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "systemd_ctypes"
authors = [{name = "Allison Karlitskaya", email = "allison.karlitskaya@redhat.com"}]
readme = "README.md"
license = {file = "COPYING"}
classifiers = ["License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)"]
dynamic = ["version", "description"]

[project.urls]
Home = "https://github.com/allisonkarlitskaya/systemd_ctypes/"

[tool.mypy]
mypy_path = 'src'

[tool.pytest.ini_options]
pythonpath = ["src"]
log_cli = true

[tool.ruff]
line-length = 118
select = [
    "A",       # flake8-builtins
    "B",       # flake8-bugbear
    "C4",      # flake8-comprehensions
    "D300",    # pydocstyle: Forbid ''' in docstrings
    "DTZ",     # flake8-datetimez
    "E",       # pycodestyle
    "EXE",     # flake8-executable
    "F",       # pyflakes
    "G",       # flake8-logging-format
    "I",       # isort
    "ICN",     # flake8-import-conventions
    "ISC",     # flake8-implicit-str-concat
    "PLE",     # pylint errors
    "PGH",     # pygrep-hooks
    "PT",      # flake8-pytest-style
    "RSE",     # flake8-raise
    "RUF",     # ruff rules
    "T10",     # flake8-debugger
    "TCH",     # flake8-type-checking
    "W",       # warnings (mostly whitespace)
    "YTT",     # flake8-2020
]
ignore = [
    "A003",    # Class attribute is shadowing a python builtin
    "B905",    # `zip()` without an explicit `strict=` parameter
    "PT009",   # Use a regular `assert` instead of unittest-style `assertEqual`
    "PT017",   # Found assertion on exception `exc` in `except` block, use `pytest.raises()` instead
]

[tool.ruff.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false

[tool.ruff.isort]
known-first-party = ["systemd_ctypes"]

[tool.coverage.paths]
source = ["src", "*/site-packages"]

[tool.coverage.run]
source_pkgs = ["systemd_ctypes"]
branch = true

[tool.coverage.report]
show_missing = true
skip_covered = true
exclude_lines = [
  "pragma: no cover",  # default
  "raise NotImplementedError",
]

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = mypy,pycodestyle,ruff,pytest
isolated_build = True

# The default test environments use system packages and never PyPI.
[testenv:{mypy,pycodestyle,ruff,pytest,pkg}]
sitepackages = True
install_command = python3 -m pip install --no-index --no-build-isolation {opts} {packages}
wheel_build_env = pkg

# All other environments (names like py311-mypy, py36-pytest, etc) are isolated
# from the system and get their packages from PyPI, according to the specific
# test environment being requested.  We build the wheel in a common environment.
[testenv]
package = wheel
wheel_build_env = venv-pkg
skip_install = mypy,pycodestyle,ruff: True
deps =
  pytest,mypy: pytest-cov
  pytest,mypy: python-dbusmock
  mypy: mypy
  pycodestyle: pycodestyle
  ruff: ruff
commands =
  pytest: python3 -m pytest -opythonpath= {posargs:--cov}
  ruff: python3 -m ruff {posargs:src test}
  mypy: python3 -m mypy {posargs:src test}
  pycodestyle: python3 -m pycodestyle --max-line-length=118 {posargs:src test}
"""
