From a1080e34c041a2003a3a898453b213fbf1831acd Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Thu, 5 Sep 2024 01:12:56 -0400 Subject: [PATCH] build: Switch to pyproject.toml. Fix new mypy errors. --- pyproject.toml | 52 ++++++++++++++++++++++++++++++++++++++++++++++++- setup.cfg | 47 -------------------------------------------- yapw/clients.py | 6 +++--- 3 files changed, 54 insertions(+), 51 deletions(-) delete mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml index 2a4cb46..0d93963 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,56 @@ requires = ["setuptools>=61.2"] build-backend = "setuptools.build_meta" +[project] +name = "yapw" +version = "0.1.4" +authors = [{name = "Open Contracting Partnership", email = "data@open-contracting.org"}] +license = {text = "BSD"} +description = "A Pika wrapper with error handling, signal handling and good defaults." +classifiers = [ + "License :: OSI Approved :: BSD License", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", +] +urls = {Homepage = "https://github.com/open-contracting/yapw"} +requires-python = ">=3.10" +dependencies = [ + "pika>=1.2.0", + "typing-extensions;python_version<'3.8'", +] + +[project.readme] +file = "README.rst" +content-type = "text/x-rst" + +[project.optional-dependencies] +perf = ["orjson"] +test = [ + "coveralls", + "pytest", + "pytest-cov", +] +types = [ + "mypy", + "types-orjson", + "types-pika", +] +docs = [ + "furo", + "sphinx", + "sphinx-autobuild", + "sphinx-design", +] + +[tool.setuptools.packages.find] +exclude = [ + "tests", + "tests.*", +] + [tool.ruff] line-length = 119 target-version = "py310" @@ -11,7 +61,7 @@ select = ["ALL"] ignore = [ "ANN", "COM", "EM", # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules - "W191", "E501", "D206", "Q000", "Q001", "Q002", "Q003", "ISC001", + "W191", "D206", "Q000", "Q001", "Q002", "Q003", "ISC001", "D203", "D212", # incompatible rules "D200", # documentation preferences "C901", "PLR091", # complexity preferences diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index c443df6..0000000 --- a/setup.cfg +++ /dev/null @@ -1,47 +0,0 @@ -[metadata] -name = yapw -version = 0.1.4 -author = Open Contracting Partnership -author_email = data@open-contracting.org -license = BSD -description = A Pika wrapper with error handling, signal handling and good defaults. -url = https://github.com/open-contracting/yapw -long_description = file: README.rst -long_description_content_type = text/x-rst -classifiers = - License :: OSI Approved :: BSD License - Operating System :: POSIX :: Linux - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Programming Language :: Python :: Implementation :: CPython - -[options] -packages = find: -# For generic namedtuples. -python_requires = >=3.10 -install_requires = - pika>=1.2.0 - typing-extensions;python_version<'3.8' - -[options.packages.find] -exclude = - tests - tests.* - -[options.extras_require] -perf = - orjson -test = - coveralls - pytest - pytest-cov -types = - mypy - types-orjson - types-pika -docs = - furo - sphinx - sphinx-autobuild - sphinx-design diff --git a/yapw/clients.py b/yapw/clients.py index 87ef507..7031e06 100644 --- a/yapw/clients.py +++ b/yapw/clients.py @@ -15,7 +15,7 @@ from collections import namedtuple from concurrent.futures import ThreadPoolExecutor from functools import partial -from typing import TYPE_CHECKING, Any, Generic, NoReturn, TypeVar +from typing import TYPE_CHECKING, Any, Generic, TypeVar import pika from pika.adapters.asyncio_connection import AsyncioConnection @@ -45,7 +45,7 @@ def _on_message( method: pika.spec.Basic.Deliver, properties: pika.BasicProperties, body: bytes, - args: tuple[Callable[..., None], Decorator, Decode, ConsumerCallback, State[Any]], + args: tuple[Callable[..., Any], Decorator, Decode, ConsumerCallback, State[Any]], ) -> None: (submit, decorator, decode, callback, state) = args submit(decorator, decode, callback, state, channel, method, properties, body) @@ -642,7 +642,7 @@ def consume(self, on_message_callback: ConsumerCallback, decorator: Decorator, q """ self.channel.add_on_cancel_callback(self.channel_cancel_callback) - submit: partial[Future[NoReturn]] = partial(self.connection.ioloop.run_in_executor, self.executor) + submit: partial[Future[Any]] = partial(self.connection.ioloop.run_in_executor, self.executor) cb = partial(_on_message, args=(submit, decorator, self.decode, on_message_callback, self.state)) self.consumer_tag = self.channel.basic_consume(queue_name, cb, callback=self.channel_consumeok_callback)