diff --git a/aprsd_slack_plugin/conf/__init__.py b/aprsd_slack_plugin/conf/__init__.py index 9973407..f3ea23a 100644 --- a/aprsd_slack_plugin/conf/__init__.py +++ b/aprsd_slack_plugin/conf/__init__.py @@ -2,6 +2,5 @@ from oslo_config import cfg from aprsd_slack_plugin.conf import slack - CONF = cfg.CONF slack.register_opts(CONF) diff --git a/aprsd_slack_plugin/conf/opts.py b/aprsd_slack_plugin/conf/opts.py index b92ad6d..4d1e08c 100644 --- a/aprsd_slack_plugin/conf/opts.py +++ b/aprsd_slack_plugin/conf/opts.py @@ -31,7 +31,6 @@ import importlib import os import pkgutil - LIST_OPTS_FUNC_NAME = "list_opts" @@ -65,8 +64,8 @@ def _import_modules(module_names): mod = importlib.import_module("aprsd_slack_plugin.conf." + modname) if not hasattr(mod, LIST_OPTS_FUNC_NAME): msg = ( - "The module 'aprsd_slack_plugin.conf.%s' should have a '%s' " - "function which returns the config options." % (modname, LIST_OPTS_FUNC_NAME) + f"The module 'aprsd_slack_plugin.conf.{modname}' should have a " + f"'{LIST_OPTS_FUNC_NAME}' function which returns the config options." ) raise Exception(msg) else: diff --git a/aprsd_slack_plugin/conf/slack.py b/aprsd_slack_plugin/conf/slack.py index 7c67813..3f2f079 100644 --- a/aprsd_slack_plugin/conf/slack.py +++ b/aprsd_slack_plugin/conf/slack.py @@ -1,6 +1,5 @@ from oslo_config import cfg - slack_group = cfg.OptGroup( name="aprsd_slack_plugin", title="APRSD Slack Plugin settings", diff --git a/aprsd_slack_plugin/location_plugin.py b/aprsd_slack_plugin/location_plugin.py index c17d1c3..aae608f 100644 --- a/aprsd_slack_plugin/location_plugin.py +++ b/aprsd_slack_plugin/location_plugin.py @@ -111,10 +111,7 @@ class SlackLocationPlugin( callsign_url = f"" aprs_url = ( - "".format( - lat, - lon, - ) + f"" ) message = {} diff --git a/aprsd_slack_plugin/notify_plugin.py b/aprsd_slack_plugin/notify_plugin.py index 26c2797..1ef627e 100644 --- a/aprsd_slack_plugin/notify_plugin.py +++ b/aprsd_slack_plugin/notify_plugin.py @@ -4,9 +4,10 @@ from aprsd import packets, plugin from oslo_config import cfg import aprsd_slack_plugin -from aprsd_slack_plugin import base_plugin -from aprsd_slack_plugin import conf # noqa - +from aprsd_slack_plugin import ( + base_plugin, + conf, # noqa +) CONF = cfg.CONF LOG = logging.getLogger("APRSD") diff --git a/pyproject.toml b/pyproject.toml index 7859b69..9180f71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,3 @@ -[build-system] -requires = ["setuptools>=46.0", "wheel"] -build-backend = "setuptools.build_meta" [project] name = "aprsd_slack_plugin" @@ -39,16 +36,14 @@ dev = [ "pip-tools", ] -[project.entry-points] -"oslo.config.opts" = { "aprsd_slack_plugin.conf" = "aprsd_slack_plugin.conf.opts:list_opts" } +[project.entry-points."oslo.config.opts"] +"aprsd_slack_plugin.conf" = "aprsd_slack_plugin.conf.opts:list_opts" [tool.setuptools] +py-modules = ["aprsd_slack_plugin"] +package-data = {aprsd_slack_plugin = ["*.dat"]} packages = ["aprsd_slack_plugin"] -[tool.setuptools.package-data] -aprsd_slack_plugin = ["py.typed"] - - [tool.isort] profile = "black" line_length = 99 @@ -59,9 +54,62 @@ skip_gitignore = true # If you need to skip/exclude folders, consider using skip_glob as that will allow the # isort defaults for skip to remain without the need to duplicate them. -[tool.coverage.run] -branch = true - [tool.mypy] ignore_missing_imports = true strict = true + +[build-system] +requires = [ + "setuptools>=80.0", + "setuptools_scm>=0", + "wheel", +] +build-backend = "setuptools.build_meta" + +[tool.ruff] +line-length = 88 +target-version = "py311" + +[tool.ruff.lint] +select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # pyflakes + "I", # isort + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "UP", # pyupgrade +] +ignore = [ + "E501", # line too long (handled by formatter) +] + +[tool.ruff.lint.isort] +force-sort-within-sections = true + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" + +[tool.pytest.ini_options] +testpaths = ["tests"] +python_files = ["test_*.py"] +python_classes = ["Test*"] +python_functions = ["test_*"] +addopts = [ + "-ra", + "--strict-markers", + "--strict-config", + "--cov=aprsd_slack_plugin", + "--cov-report=term-missing", + "--cov-report=html", +] + +[tool.coverage.run] +branch = true +source = ["aprsd_slack_plugin"] +omit = [ + "*/tests/*", + "*/test_*.py", +] +[tool.setuptools_scm] diff --git a/tox.ini b/tox.ini index b3675c8..7f4e618 100644 --- a/tox.ini +++ b/tox.ini @@ -23,6 +23,7 @@ isolated_build = true package = editable deps = pytest + pytest-cov aprsd commands = # Use -bb to enable BytesWarnings as error to catch str/bytes misuse. @@ -45,6 +46,13 @@ deps = commands = uv run ruff check aprsd_slack_plugin tests +[testenv:fmt] +skip_install = true +deps = + ruff +commands = + uv run ruff format aprsd_slack_plugin tests + [testenv:docs] package = editable deps =