[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "edwh-restic-plugin"
dynamic = ["version"]
description = ''
readme = "README.md"
requires-python = ">=3.10"
license-expression = "MIT"
keywords = []
authors = [
    { name = "Remco Boerma", email = "remco.b@educationwarehouse.nl" },
    { name = "Robin van der Noord", email = "robin.vdn@educationwarehouse.nl" },
]
classifiers = [
    "Development Status :: 4 - Beta",
    "Programming Language :: Python",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Programming Language :: Python :: Implementation :: CPython",
    "Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
    'edwh',
    'tqdm',
    'termcolor',
    'typing-extensions',
]

[project.optional-dependencies]
dev = [
    "hatch",
    # "python-semantic-release >= 8.0.0a5",
    "black",
]

[project.entry-points."edwh.tasks"]
restic = "edwh_restic_plugin.tasks"

[project.urls]
Documentation = "https://github.com/educationwarehouse/edwh-restic-plugin#readme"
Issues = "https://github.com/educationwarehouse/edwh-restic-plugin/issues"
Source = "https://github.com/educationwarehouse/edwh-restic-plugin"

[tool.hatch.version]
path = "src/edwh_restic_plugin/__about__.py"

[tool.hatch.envs.default]
dependencies = [
    "coverage[toml]>=6.5",
    "pytest",
]
[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = [
    "- coverage combine",
    "coverage report",
]
cov = [
    "test-cov",
    "cov-report",
]

[[tool.hatch.envs.all.matrix]]
python = ["3.10", "3.11", "3.12"]

[tool.hatch.envs.lint]
detached = true
dependencies = [
    "black>=23.1.0",
    "mypy>=1.0.0",
    "ruff>=0.0.243",
]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:src/edwh_restic_plugin tests}"
style = [
    "ruff {args:.}",
    "black --check --diff {args:.}",
]
fmt = [
    "black {args:.}",
    "ruff --fix {args:.}",
    "style",
]
all = [
    "style",
    "typing",
]

[tool.black]
target-version = ["py310"]
line-length = 120
# 'extend-exclude' excludes files or directories in addition to the defaults
extend-exclude = '''
# A regex preceded with ^/ will apply only to files and directories
# in the root of the project.
(
  ^.*\.bak\/.+     # ignore every .bak directory
  ^.*venv.+\/.+    # ignore every venv directory
  venv.+|.+\.bak   # idk why it suddenly works, let's not touch it
)
'''

[tool.isort]
profile = "black"
extend_skip_glob = ["*.bak/*"]


[tool.mypy]
python_version = "3.11"

# `some: int = None` looks nicer than `some: int | None = None` and pycharm still understands it
no_implicit_optional = false  # I guess 'strict_optional' should be true, but disable this one because it's double!
# same as above (thrown if no_implicit_optional = False)
# ACTUALLY: not the same! Setting strict_optional = false may miss some type errors like
# 'Item "None" of "Optional" has no attribute "lower"'
# 'strict_optional' complains more for class properties and 'no_implicit_optional' for function arguments
# strict_optional = false
# 3rd party packages may not be typed, that's not my fault!
ignore_missing_imports = true
# kinda hypocritical to disable Optional and still enable strict, but I do agree with some other strict rules.
strict = false
# fixes defs with clear return var (doesn't seem to work for __init__ which is the most obvious case)
# check_untyped_defs = True

exclude = ["venv", ".bak"]

[tool.ruff]
target-version = "py311"
line-length = 120
extend-exclude = ["*.bak/", "venv*/"]

[tool.ruff.lint]
select = [
    "F", # pyflake error
    "E", # pycodestyle error
    "W", # pycodestyle warning
    "Q", # quotes
    "A", # builtins
    # "C4", # comprehensions - NO: doesn't allow dict()
    # "RET", # return - NO: annoying
    "SIM", # simplify
    "ARG", # unused arguments
    # "COM", # comma's - NO: annoying
    # "PTH", # use pathlib - NO: annoying
    "RUF", # ruff rules
]
unfixable = [
    # Don't touch unused imports
    "F401",
]

ignore = [
    "RUF013", # implicit Optional
    "RUF012", # classvar
]

[tool.bandit]
# bandit -c pyproject.toml -r .
exclude_dirs = [".bak", "venv"]
skips = [
    "B108"  # hard coded /tmp/... files are fine for me tbh
]

[tool.su6]
# every checker:
directory = "src"
# 'all' and 'fix':
include = []
exclude = ["pytest"]
# 'all':
stop-after-first-failure = true

[tool.semantic_release]
branch = "main"
version_variable = "src/edwh_restic_plugin/__about__.py:__version__"
change_log = "CHANGELOG.md"
upload_to_repository = false
upload_to_release = false
build_command = "hatch build"
