diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f73a842..0392d5f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,23 +1,29 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v6.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - - id: check-added-large-files + - id: check-json - id: detect-private-key - id: check-merge-conflict - id: check-case-conflict - - id: check-docstring-first - id: check-builtin-literals + - id: check-illegal-windows-names - repo: https://github.com/asottile/setup-cfg-fmt - rev: v1.16.0 + rev: v2.7.0 hooks: - id: setup-cfg-fmt -- repo: https://github.com/dizballanze/gray - rev: v0.10.1 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.14.10 hooks: - - id: gray + ###### Relevant part below ###### + - id: ruff-check + types_or: [python, pyi] + args: ["check", "--select", "I", "--fix"] + ###### Relevant part above ###### + - id: ruff-format + types_or: [python, pyi] diff --git a/aprsd_slack_plugin/__init__.py b/aprsd_slack_plugin/__init__.py index c0094f0..e2a164b 100644 --- a/aprsd_slack_plugin/__init__.py +++ b/aprsd_slack_plugin/__init__.py @@ -10,6 +10,13 @@ # License for the specific language governing permissions and limitations # under the License. -import pbr.version +try: + from importlib.metadata import PackageNotFoundError, version +except ImportError: + # Python < 3.8 + from importlib_metadata import PackageNotFoundError, version -__version__ = pbr.version.VersionInfo("aprsd_slack_plugin").version_string() +try: + __version__ = version("aprsd_slack_plugin") +except PackageNotFoundError: + __version__ = "unknown" diff --git a/pyproject.toml b/pyproject.toml index 3a5104b..9e02910 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,11 +2,53 @@ requires = ["setuptools>=46.0", "wheel"] build-backend = "setuptools.build_meta" -[tool.black] -# Use the more relaxed max line length permitted in PEP8. -line-length = 99 -target-version = ["py36", "py37", "py38"] -# black will automatically exclude all files listed in .gitignore +[project] +name = "aprsd_slack_plugin" +version = "1.2.0" +description = "Amateur radio APRS daemon which listens for messages and responds" +readme = "README.rst" +requires-python = ">=3.11" +license = {file = "LICENSE.txt"} +authors = [ + {name = "Walter A. Boring IV", email = "something@somewhere.com"} +] +classifiers = [ + "Topic :: Communications :: Ham Radio", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python", + "Programming Language :: Python :: 3.11", +] +dependencies = [ + "slack_sdk>=3.0", + "slackeventsapi>=2.1.0", + "aprsd", + "oslo_config", +] + +[project.optional-dependencies] +dev = [ + "tox", + "pytest", + "pytest-cov", + "mypy", + "flake8", + "pep8-naming", + "black", + "isort", + "sphinx", + "pre-commit", + "pip-tools", +] + +[project.entry-points] +"oslo.config.opts" = { "aprsd_slack_plugin.conf" = "aprsd_slack_plugin.conf.opts:list_opts" } + +[tool.setuptools] +packages = ["aprsd_slack_plugin"] + +[tool.setuptools.package-data] +aprsd_slack_plugin = ["py.typed"] + [tool.isort] profile = "black" @@ -20,3 +62,7 @@ skip_gitignore = true [tool.coverage.run] branch = true + +[tool.mypy] +ignore_missing_imports = true +strict = true diff --git a/requirements-dev.in b/requirements-dev.in deleted file mode 100644 index da88fa3..0000000 --- a/requirements-dev.in +++ /dev/null @@ -1,13 +0,0 @@ -tox -pytest -pytest-cov -mypy -flake8 -pep8-naming -black -isort -pbr -Sphinx -aprsd -pre-commit -pip-tools diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 4885b4f..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,76 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.9 -# by the following command: -# -# pip-compile --annotation-style=line --resolver=backtracking requirements-dev.in -# -alabaster==0.7.13 # via sphinx -aprsd==1.0.0 # via -r requirements-dev.in -babel==2.12.1 # via sphinx -black==23.3.0 # via -r requirements-dev.in -build==0.10.0 # via pip-tools -cachetools==5.3.1 # via tox -certifi==2023.5.7 # via requests -cfgv==3.3.1 # via pre-commit -chardet==5.1.0 # via tox -charset-normalizer==3.2.0 # via requests -click==8.1.4 # via aprsd, black, click-completion, pip-tools -click-completion==0.5.2 # via aprsd -colorama==0.4.6 # via tox -coverage[toml]==7.2.7 # via pytest-cov -distlib==0.3.6 # via virtualenv -docutils==0.20.1 # via sphinx -exceptiongroup==1.1.2 # via pytest -filelock==3.12.2 # via tox, virtualenv -flake8==6.0.0 # via -r requirements-dev.in, pep8-naming -identify==2.5.24 # via pre-commit -idna==3.4 # via requests -imagesize==1.4.1 # via sphinx -imapclient==2.3.1 # via aprsd -importlib-metadata==6.8.0 # via sphinx -iniconfig==2.0.0 # via pytest -isort==5.12.0 # via -r requirements-dev.in -jinja2==3.1.2 # via click-completion, sphinx -markupsafe==2.1.3 # via jinja2 -mccabe==0.7.0 # via flake8 -mypy==1.4.1 # via -r requirements-dev.in -mypy-extensions==1.0.0 # via black, mypy -nodeenv==1.8.0 # via pre-commit -packaging==23.1 # via black, build, pyproject-api, pytest, sphinx, tox -pathspec==0.11.1 # via black -pbr==5.11.1 # via -r requirements-dev.in, aprsd -pep8-naming==0.13.3 # via -r requirements-dev.in -pip-tools==6.14.0 # via -r requirements-dev.in -platformdirs==3.8.1 # via black, tox, virtualenv -pluggy==1.2.0 # via aprsd, pytest, tox -pre-commit==3.3.3 # via -r requirements-dev.in -pycodestyle==2.10.0 # via flake8 -pyflakes==3.0.1 # via flake8 -pygments==2.15.1 # via sphinx -pyproject-api==1.5.3 # via tox -pyproject-hooks==1.0.0 # via build -pytest==7.4.0 # via -r requirements-dev.in, pytest-cov -pytest-cov==4.1.0 # via -r requirements-dev.in -pyyaml==6.0 # via aprsd, pre-commit -requests==2.31.0 # via aprsd, sphinx -shellingham==1.5.0.post1 # via click-completion -six==1.16.0 # via aprsd, click-completion, imapclient -snowballstemmer==2.2.0 # via sphinx -sphinx==7.0.1 # via -r requirements-dev.in -sphinxcontrib-applehelp==1.0.4 # via sphinx -sphinxcontrib-devhelp==1.0.2 # via sphinx -sphinxcontrib-htmlhelp==2.0.1 # via sphinx -sphinxcontrib-jsmath==1.0.1 # via sphinx -sphinxcontrib-qthelp==1.0.3 # via sphinx -sphinxcontrib-serializinghtml==1.1.5 # via sphinx -tomli==2.0.1 # via black, build, coverage, mypy, pip-tools, pyproject-api, pyproject-hooks, pytest, tox -tox==4.6.4 # via -r requirements-dev.in -typing-extensions==4.7.1 # via black, mypy -urllib3==2.0.3 # via requests -virtualenv==20.23.1 # via pre-commit, tox -wheel==0.40.0 # via pip-tools -zipp==3.16.0 # via importlib-metadata - -# The following packages are considered to be unsafe in a requirements file: -# pip -# setuptools diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index aa8735a..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -pbr -slack_sdk>=3.0 -slackeventsapi>=2.1.0 -aprsd -oslo_config diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index c2146eb..0000000 --- a/setup.cfg +++ /dev/null @@ -1,42 +0,0 @@ -[metadata] -name = aprsd_slack_plugin -long_description = file: README.rst -long_description_content_type = text/x-rst -author = Walter A. Boring IV -author_email = something@somewhere.com -license_file = LICENSE.txt -classifier = - Topic :: Communications :: Ham Radio - Operating System :: POSIX :: Linux - Programming Language :: Python - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 -description_file = - README.rst -summary = Amateur radio APRS daemon which listens for messages and responds - -[options.entry_points] -oslo.config.opts = - aprsd_slack_plugin.conf = aprsd_slack_plugin.conf.opts:list_opts - -[global] -setup-hooks = - pbr.hooks.setup_hook - -[files] -packages = - aprsd_slack_plugin - -[build_sphinx] -source-dir = doc/source -build-dir = doc/build -all_files = 1 - -[upload_sphinx] -upload-dir = doc/build/html - -[mypy] -ignore_missing_imports = True -strict = True diff --git a/setup.py b/setup.py index 70592f3..328a482 100755 --- a/setup.py +++ b/setup.py @@ -12,15 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT -import setuptools +# Configuration is now in pyproject.toml +# This file is kept for compatibility with tools that expect setup.py +from setuptools import setup -# In python < 2.7.4, a lazy loading of package `pbr` will break -# setuptools if some other modules registered functions in `atexit`. -# solution from: http://bugs.python.org/issue15881#msg170215 -try: - import multiprocessing # noqa -except ImportError: - pass - -setuptools.setup(setup_requires=["pbr"], pbr=True) +setup() diff --git a/tox.ini b/tox.ini index 9d5590c..a2311c8 100644 --- a/tox.ini +++ b/tox.ini @@ -1,25 +1,18 @@ -[flake8] -# Use the more relaxed max line length permitted in PEP8. -max-line-length = 99 -# This ignore is required by black. -extend-ignore = E203 -extend-exclude = - venv - # This is the configuration for the tox-gh-actions plugin for GitHub Actions # https://github.com/ymyzk/tox-gh-actions # This section is not needed if not using GitHub Actions for CI. [gh-actions] python = - 3.9: py39 + 3.11: py311 [tox] # These are the default environments that will be run # when ``tox`` is run without arguments. envlist = lint - py{39} + py{311} skip_missing_interpreters = true +requires = tox-uv # Activate isolated build environment. tox will use a virtual environment # to build a source distribution from the source tree. For build tools and @@ -27,45 +20,46 @@ skip_missing_interpreters = true isolated_build = true [testenv] +package = editable deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/requirements-dev.txt + pytest commands = # Use -bb to enable BytesWarnings as error to catch str/bytes misuse. # Use -Werror to treat warnings as errors. - {envpython} -bb -Werror -m pytest {posargs} + uv run pytest tests {posargs} [testenv:type-check] skip_install = true deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/requirements-dev.txt + pytest + mypy commands = - mypy src tests + uv run mypy src tests [testenv:lint] skip_install = true deps = - -r{toxinidir}/requirements-dev.txt + pytest + ruff commands = - flake8 aprsd_slack_plugin tests + uv run ruff check aprsd_slack_plugin tests [testenv:docs] skip_install = true deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/requirements-dev.txt + pytest + sphinx changedir = {toxinidir}/docs commands = - {envpython} clean_docs.py - sphinx-apidoc --force --output-dir apidoc {toxinidir}/aprsd_slack_plugin - sphinx-build -a -W . _build + uv run python clean_docs.py + uv run sphinx-apidoc --force --output-dir apidoc {toxinidir}/aprsd_slack_plugin + uv run sphinx-build -a -W . _build [testenv:licenses] skip_install = true recreate = true deps = - -r{toxinidir}/requirements.txt + pytest pip-licenses commands = - pip-licenses {posargs} + uv run pip-licenses {posargs}