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

[tool.setuptools_scm]
write_to = "napari_plugin_manager/_version.py"

[tool.setuptools.packages.find]
where = ["."]
include = ["napari_plugin_manager"]
exclude = []
namespaces = false  

[project]
name = "napari-plugin-manager"
description = "Install plugins for napari, in napari."
readme = "README.md"
authors = [
  {name = "napari team", email = "napari-steering-council@googlegroups.com"}
]
license = {file = "LICENSE"}
classifiers = [
    "Development Status :: 3 - Alpha",
    "Environment :: X11 Applications :: Qt",
    "Framework :: napari",
    "Intended Audience :: Education",
    "Intended Audience :: Science/Research",
    "License :: OSI Approved :: BSD License",
    "Programming Language :: C",
    "Programming Language :: Python",
    "Programming Language :: Python :: 3 :: Only",
    "Programming Language :: Python :: 3.9",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
    "Topic :: Scientific/Engineering",
    "Topic :: Scientific/Engineering :: Visualization",
    "Topic :: Scientific/Engineering :: Information Analysis",
    "Topic :: Scientific/Engineering :: Bio-Informatics",
    "Topic :: Utilities",
    "Operating System :: Microsoft :: Windows",
    "Operating System :: POSIX",
    "Operating System :: Unix",
    "Operating System :: MacOS"
]
requires-python = ">=3.8"
dependencies = [
  "npe2",
  "qtpy",
  "superqt",
  "pip"
]
dynamic = [
  "version"
]

[project.optional-dependencies]
dev = [
  "PyQt5",
  "pre-commit",
]

testing = [
  "flaky",
  "pytest",
  "pytest-cov",
  "pytest-qt",
  "virtualenv"
]

docs = [
  "sphinx>6",
  "sphinx-autobuild",
  "sphinx-external-toc",
  "sphinx-copybutton",
  "sphinx-favicon",
  "myst-nb",
  "napari-sphinx-theme>=0.3.0",
]

[project.urls]
homepage = "https://github.com/napari/napari-plugin-manager"

[tool.black]
target-version = ['py39', 'py310', 'py311']
skip-string-normalization = true
line-length = 79

[tool.check-manifest]
ignore = [
  ".pre-commit-config.yaml",
  "napari_plugin_manager/_version.py",  # added during build by setuptools_scm
  "*.pyi",  # added by make typestubs
]

[tool.ruff]
line-length = 79
select = [
    "E", "F", "W", #flake8
    "UP", # pyupgrade
    "I", # isort
    "YTT", #flake8-2020
    "TCH", # flake8-type-checing
    "BLE", # flake8-blind-exception
    "B", # flake8-bugbear
    "A", # flake8-builtins
    "C4", # flake8-comprehensions
    "ISC", # flake8-implicit-str-concat
    "G", # flake8-logging-format
    "PIE", # flake8-pie
    "COM", # flake8-commas
    "SIM", # flake8-simplify
    "INP", # flake8-no-pep420
    "Q", # flake8-quotes
    "RET", # flake8-return
    "TID",  # flake8-tidy-imports # replace absolutify import
    "TRY", # tryceratops
    "ICN", # flake8-import-conventions
    "RUF", # ruff specyfic rules
]
ignore = [
    "E501", "UP006", "TCH001", "TCH002", "TCH003",
    "A003", # flake8-builtins - we have class attributes violating these rule
    "COM812", # flake8-commas - we don't like adding comma on single line of arguments
    "SIM117", # flake8-simplify - we some of merged with statements are not looking great with black, reanble after drop python 3.9
    "Q000",
    "RET504", # not fixed yet https://github.com/charliermarsh/ruff/issues/2950
    "TRY003", # require implement multiple exception class
    "RUF005", # problem with numpy compatybility, see https://github.com/charliermarsh/ruff/issues/2142#issuecomment-1451038741

]

exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".mypy_cache",
    ".pants.d",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "venv",
    "*vendored*",
    "*_vendor*",
]

target-version = "py38"
fix = true

[tool.ruff.per-file-ignores]
"**/_tests/*.py" = ["B011", "INP001", "TRY301"]

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

[tool.ruff.flake8-tidy-imports]
# Disallow all relative imports.
ban-relative-imports = "all"

[tool.ruff.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true

[tool.ruff.isort]
known-first-party=['napari_plugin_manager']

[tool.pytest.ini_options]
# These follow standard library warnings filters syntax.  See more here:
# https://docs.python.org/3/library/warnings.html#describing-warning-filters
addopts = "--maxfail=5 --durations=10 -rXxs"

# NOTE: only put things that will never change in here.
# napari deprecation and future warnings should NOT go in here.
# instead... assert the warning with `pytest.warns()` in the relevant test,
# That way we can clean them up when no longer necessary
filterwarnings = [
  "error:::napari_plugin_manager", # turn warnings from napari into errors
  "error:::test_.*", # turn warnings in our own tests into errors
]

markers = [
  "enabledialog: Allow to use dialog in test"
]

[tool.mypy]
files = "napari_plugin_manager"
ignore_missing_imports = true
exclude = [
  "_tests",
]
show_error_codes = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
check_untyped_defs = true
# # maybe someday :)
# disallow_any_generics = true
# no_implicit_reexport = true
# disallow_untyped_defs = true
