build: use hatch for build backend, and use ruff for linting (#139)

* style: ruff fixes

* style: no implicit optional

* keep mypy manual

* build: add fake setup.py

* build: use hatch

* update ruff

* update ruff settings

* chore: merge

* smaller sdist

* fix: fix qfont typing

* fix types again

* add toc permalink

* ignore setup.py from sdist
This commit is contained in:
Talley Lambert
2022-12-01 08:21:03 -05:00
committed by GitHub
parent 7b2d8bfb2d
commit 6abd3a21a6
24 changed files with 264 additions and 287 deletions

View File

@@ -1,7 +1,7 @@
# https://peps.python.org/pep-0517/
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools-scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
# https://peps.python.org/pep-0621/
[project]
@@ -11,7 +11,15 @@ readme = "README.md"
requires-python = ">=3.7"
license = { text = "BSD 3-Clause License" }
authors = [{ email = "talley.lambert@gmail.com" }, { name = "Talley Lambert" }]
keywords = ["qt", "pyqt", "pyside", "widgets", "range slider", "components", "gui"]
keywords = [
"qt",
"pyqt",
"pyside",
"widgets",
"range slider",
"components",
"gui",
]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: X11 Applications :: Qt",
@@ -43,11 +51,6 @@ dependencies = [
test = ["pint", "pytest", "pytest-cov", "pytest-qt", "tox", "tox-conda"]
dev = [
"black",
"flake8-bugbear",
"flake8-docstrings",
"flake8-pyprojecttoml",
"flake8-typing-imports",
"flake8",
"ipython",
"isort",
"jedi<0.18.0",
@@ -62,6 +65,7 @@ dev = [
"rich",
"tox-conda",
"tox",
"types-Pygments",
]
docs = ["mkdocs-macros-plugin", "mkdocs-material", "mkdocstrings[python]"]
quantity = ["pint"]
@@ -78,49 +82,52 @@ Source = "https://github.com/pyapp-kit/superqt"
Tracker = "https://github.com/pyapp-kit/superqt/issues"
Changelog = "https://github.com/pyapp-kit/superqt/blob/main/CHANGELOG.md"
[tool.hatch.version]
source = "vcs"
# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
[tool.setuptools]
zip-safe = false
include-package-data = true
packages = { find = { where = ["src"], exclude = [] } }
[tool.setuptools.package-data]
"*" = ["py.typed", "*.pyi"]
# https://github.com/pypa/setuptools_scm/#pyprojecttoml-usage
[tool.setuptools_scm]
write_to = "src/superqt/_version.py"
[tool.hatch.build.targets.sdist]
include = ["src", "tests", "CHANGELOG.md"]
# https://pycqa.github.io/isort/docs/configuration/options.html
[tool.isort]
profile = "black"
src_paths = ["src/superqt", "tests"]
# https://flake8.pycqa.org/en/latest/user/options.html
# https://gitlab.com/durko/flake8-pyprojecttoml
[tool.flake8]
exclude = "docs,.eggs,examples,_version.py"
max-line-length = 88
min-python-version = "3.8.0"
docstring-convention = "all" # use numpy convention, while allowing D417
extend-ignore = """
E203 # whitespace before ':'
D107,D203,D212,D213,D402,D413,D415,D416 # numpy
D100 # missing docstring in public module
D401 # imperative mood
W503 # line break before binary operator
E302,E704 # black will handle these when we want them
"""
per-file-ignores = ["tests/*:D"]
# https://github.com/charliermarsh/ruff
[tool.ruff]
line-length = 88
target-version = "py37"
src = ["src","tests"]
extend-select = [
"E", # style errors
"F", # flakes
# "D", # pydocstyle
"I001", # isort
"U", # pyupgrade
# "N", # pep8-naming
# "S", # bandit
"C", # flake8-comprehensions
"B", # flake8-bugbear
"A001", # flake8-builtins
"RUF", # ruff-specific rules
"M001", # Unused noqa directive
]
extend-ignore = [
"D100", # Missing docstring in public module
"D107", # Missing docstring in __init__
"D203", # 1 blank line required before class docstring
"D212", # Multi-line docstring summary should start at the first line
"D213", # Multi-line docstring summary should start at the second line
"D413", # Missing blank line after last section
"D416", # Section name should end with a colon
"C901", # Function is too complex
]
# http://www.pydocstyle.org/en/stable/usage.html
[tool.pydocstyle]
match_dir = "src/superqt"
convention = "numpy"
add_select = "D402,D415,D417"
ignore = "D100,D213,D401,D413,D107"
[tool.ruff.per-file-ignores]
"tests/*.py" = ["D"]
"examples/demo_widget.py" = ["E501"]
"examples/*.py" = ["B"]
# https://docs.pytest.org/en/6.2.x/customize.html
[tool.pytest.ini_options]
@@ -135,14 +142,17 @@ filterwarnings = [
# https://mypy.readthedocs.io/en/stable/config_file.html
[tool.mypy]
files = "src/**/"
files = "src/**/*.py"
strict = true
disallow_untyped_defs = false
disallow_untyped_calls = false
disallow_any_generics = false
disallow_subclassing_any = false
show_error_codes = true
pretty = true
exclude = ['tests/**/*']
[[tool.mypy.overrides]]
module = ["superqt.qtcompat.*"]
ignore_missing_imports = true
@@ -172,4 +182,6 @@ ignore = [
"CHANGELOG.md",
"CONTRIBUTING.md",
"codecov.yml",
".ruff_cache/**/*",
"setup.py"
]