From bd7f86f04ee4e0d1aa2279658d4d808a3b2dfb4a Mon Sep 17 00:00:00 2001 From: crimsonknave Date: Thu, 9 Oct 2025 16:23:13 -0400 Subject: [PATCH 1/3] Bump dependencies and fix resulting linting --- .gitignore | 3 + .pre-commit-config.yaml | 4 +- annotated_logger/__init__.py | 12 ++-- annotated_logger/plugins.py | 4 +- requirements.txt | 14 ++-- requirements/requirements-dev.txt | 103 ++++++++++++++---------------- test/test_decorator.py | 4 +- 7 files changed, 72 insertions(+), 72 deletions(-) diff --git a/.gitignore b/.gitignore index f09d704..07f238d 100644 --- a/.gitignore +++ b/.gitignore @@ -132,6 +132,9 @@ dmypy.json .mutmut-cache html/ +# vim +Session.vim + # Misc TODO.md junit.xml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4616e88..0ef56b6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.8.6 + rev: v0.14.0 hooks: # Run the linter. - id: ruff # Run the formatter. - id: ruff-format - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.390 + rev: v1.1.406 hooks: - id: pyright # I don't love having to specify these here, but pre-commit only seems to work diff --git a/annotated_logger/__init__.py b/annotated_logger/__init__.py index 8608b13..1e08e52 100644 --- a/annotated_logger/__init__.py +++ b/annotated_logger/__init__.py @@ -6,12 +6,11 @@ import logging.config import time import uuid -from collections.abc import Iterator +from collections.abc import Callable, Iterator from copy import copy, deepcopy from typing import ( TYPE_CHECKING, Any, - Callable, Concatenate, Literal, ParamSpec, @@ -732,7 +731,7 @@ def wrap_class( cls=wrapped, logger_base_name=logger_name ) logger.debug("init") - new = cast(AnnotatedClass[C_co], wrapped(*args, **kwargs)) + new = cast("AnnotatedClass[C_co]", wrapped(*args, **kwargs)) new.annotated_logger = logger return new @@ -766,7 +765,7 @@ def wrap_function(*args: P.args, **kwargs: P.kwargs) -> R: post_call_attempted = True _attempt_post_call(post_call, logger, *new_args, **new_kwargs) # pyright: ignore[reportCallIssue] end_time = time.perf_counter() - logger.annotate(run_time=f"{end_time - start_time :.1f}") + logger.annotate(run_time=f"{end_time - start_time:.1f}") with contextlib.suppress(TypeError): logger.annotate(count=len(result)) # pyright: ignore[reportArgumentType] @@ -880,7 +879,7 @@ def _inject_by_kwarg( else: instance = False # pragma: no mutate logger, annotations = self._pick_correct_logger( - function, instance, logger_base_name=logger_base_name + function, instance=instance, logger_base_name=logger_base_name ) if not provided: kwargs["annotated_logger"] = logger @@ -904,7 +903,7 @@ def _inject_by_index( # noqa: PLR0913 else: instance = False # pragma: no mutate logger, annotations = self._pick_correct_logger( - function, instance, logger_base_name=logger_base_name + function, instance=instance, logger_base_name=logger_base_name ) if not provided: args.insert(index, logger) @@ -927,6 +926,7 @@ def _check_parameters_for_self_and_cls( def _pick_correct_logger( self, function: Function[S, P, R], + *, instance: object | bool, logger_base_name: str | None = None, ) -> tuple[AnnotatedAdapter, Annotations | None]: diff --git a/annotated_logger/plugins.py b/annotated_logger/plugins.py index aaeec06..5e857bf 100644 --- a/annotated_logger/plugins.py +++ b/annotated_logger/plugins.py @@ -2,13 +2,15 @@ import contextlib import logging -from typing import TYPE_CHECKING, Any, Callable +from typing import TYPE_CHECKING, Any from requests.exceptions import HTTPError from annotated_logger.filter import AnnotatedFilter if TYPE_CHECKING: # pragma: no cover + from collections.abc import Callable + from annotated_logger import AnnotatedAdapter diff --git a/requirements.txt b/requirements.txt index d3e221f..7d88f2e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,19 +7,19 @@ # - requests # -certifi==2024.12.14 +certifi==2025.10.5 # via requests -charset-normalizer==3.4.1 +charset-normalizer==3.4.3 # via requests idna==3.10 # via requests -makefun==1.15.6 +makefun==1.16.0 # via hatch.envs.default -pychoir==0.0.27 +pychoir==0.0.29 # via hatch.envs.default -python-json-logger==3.2.1 +python-json-logger==4.0.0 # via hatch.envs.default -requests==2.32.3 +requests==2.32.5 # via hatch.envs.default -urllib3==2.3.0 +urllib3==2.5.0 # via requests diff --git a/requirements/requirements-dev.txt b/requirements/requirements-dev.txt index ab08fdd..c61e6e5 100644 --- a/requirements/requirements-dev.txt +++ b/requirements/requirements-dev.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by hatch-pip-compile with Python 3.10 +# This file is autogenerated by hatch-pip-compile with Python 3.12 # # - coverage # - mutmut @@ -20,128 +20,123 @@ # - requests # -certifi==2024.12.14 +certifi==2025.10.5 # via requests cfgv==3.4.0 # via pre-commit -charset-normalizer==3.4.1 +charset-normalizer==3.4.3 # via requests -click==8.1.8 +click==8.3.0 # via mutmut -coverage==7.6.10 +coverage==7.10.7 # via # hatch.envs.dev # pytest-cov -distlib==0.3.9 +distlib==0.4.0 # via virtualenv -exceptiongroup==1.2.2 - # via pytest -filelock==3.16.1 +filelock==3.20.0 # via virtualenv -freezegun==1.5.1 +freezegun==1.5.5 # via pytest-freezer -identify==2.6.5 +identify==2.6.15 # via pre-commit idna==3.10 # via requests -iniconfig==2.0.0 +iniconfig==2.1.0 # via pytest -junit-xml==1.8 +libcst==1.7.0 # via mutmut linkify-it-py==2.0.3 # via markdown-it-py -makefun==1.15.6 +makefun==1.16.0 # via hatch.envs.dev -markdown-it-py==3.0.0 +markdown-it-py==4.0.0 # via # mdit-py-plugins # rich # textual -mdit-py-plugins==0.4.2 +mdit-py-plugins==0.5.0 # via markdown-it-py mdurl==0.1.2 # via markdown-it-py -mutmut==3.2.2 +mutmut==3.3.1 # via hatch.envs.dev nodeenv==1.9.1 # via # pre-commit # pyright -packaging==24.2 +packaging==25.0 # via pytest -parso==0.8.4 - # via mutmut -platformdirs==4.3.6 +platformdirs==4.5.0 # via # textual # virtualenv -pluggy==1.5.0 - # via pytest -pre-commit==4.0.1 +pluggy==1.6.0 + # via + # pytest + # pytest-cov +pre-commit==4.3.0 # via hatch.envs.dev -pychoir==0.0.27 +pychoir==0.0.29 # via hatch.envs.dev -pygments==2.19.1 - # via rich -pyright==1.1.391 +pygments==2.19.2 + # via + # pytest + # rich + # textual +pyright==1.1.406 # via hatch.envs.dev -pytest==8.3.4 +pytest==8.4.2 # via # hatch.envs.dev + # mutmut # pytest-cov # pytest-freezer # pytest-github-actions-annotate-failures # pytest-mock # pytest-randomly -pytest-cov==6.0.0 +pytest-cov==7.0.0 # via hatch.envs.dev pytest-freezer==0.4.9 # via hatch.envs.dev -pytest-github-actions-annotate-failures==0.2.0 +pytest-github-actions-annotate-failures==0.3.0 # via hatch.envs.dev -pytest-mock==3.14.0 +pytest-mock==3.15.1 # via hatch.envs.dev -pytest-randomly==3.16.0 +pytest-randomly==4.0.1 # via hatch.envs.dev python-dateutil==2.9.0.post0 # via freezegun -python-json-logger==3.2.1 +python-json-logger==4.0.0 # via hatch.envs.dev -pyyaml==6.0.2 - # via pre-commit -requests==2.32.3 +pyyaml==6.0.3 + # via + # libcst + # pre-commit +requests==2.32.5 # via # hatch.envs.dev # requests-mock requests-mock==1.12.1 # via hatch.envs.dev -rich==13.9.4 +rich==14.2.0 # via textual -ruff==0.8.6 +ruff==0.14.0 # via hatch.envs.dev -setproctitle==1.3.4 +setproctitle==1.3.7 # via mutmut six==1.17.0 - # via - # junit-xml - # python-dateutil -textual==1.0.0 + # via python-dateutil +textual==6.2.1 # via mutmut -toml==0.10.2 - # via mutmut -tomli==2.2.1 - # via - # coverage - # pytest -typing-extensions==4.12.2 +typing-extensions==4.15.0 # via # hatch.envs.dev # pyright - # rich # textual uc-micro-py==1.0.3 # via linkify-it-py -urllib3==2.3.0 +urllib3==2.5.0 # via requests -virtualenv==20.28.1 +virtualenv==20.34.0 # via pre-commit diff --git a/test/test_decorator.py b/test/test_decorator.py index fcceef3..492c343 100644 --- a/test/test_decorator.py +++ b/test/test_decorator.py @@ -615,6 +615,6 @@ def test_args_kwargs_splat_provided_not_instance( class TestNonClassBased: def test_annotated_logger_must_be_first(self): with pytest.raises( - TypeError, match="^annotated_logger must be the first argument$" + TypeError, match=r"^annotated_logger must be the first argument$" ): - import example.invalid_order # noqa: F401 + import example.invalid_order # noqa: F401 PLC0415 From 4bea6a31c310f4230473fed3d946772fafc1dd3a Mon Sep 17 00:00:00 2001 From: crimsonknave Date: Thu, 9 Oct 2025 16:27:42 -0400 Subject: [PATCH 2/3] Missed ruff format call --- test/test_mocks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_mocks.py b/test/test_mocks.py index bfba062..863a747 100644 --- a/test/test_mocks.py +++ b/test/test_mocks.py @@ -58,7 +58,7 @@ def wrong_present_for_add_success(expected, missing=None, incorrect=None): else: incorrect_string = ", ".join( [ - f"\"Extra `{d['key']}` value is incorrect. Desired `{d['expected']}` ({type(d['expected'])}) , actual `{d['actual']}` ({type(d['actual'])})\"" + f'"Extra `{d["key"]}` value is incorrect. Desired `{d["expected"]}` ({type(d["expected"])}) , actual `{d["actual"]}` ({type(d["actual"])})"' for d in incorrect ] ) From fb3b184cad465a5ec626e4afca2040bb8f75ff36 Mon Sep 17 00:00:00 2001 From: crimsonknave Date: Thu, 9 Oct 2025 16:28:47 -0400 Subject: [PATCH 3/3] Version bump --- annotated_logger/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/annotated_logger/__init__.py b/annotated_logger/__init__.py index 1e08e52..4e0bfd4 100644 --- a/annotated_logger/__init__.py +++ b/annotated_logger/__init__.py @@ -33,7 +33,7 @@ # https://test.pypi.org/project/annotated-logger/ # The dev versions in testpypi can then be pulled in to whatever project needed # the new feature. -VERSION = "1.2.3" # pragma: no mutate +VERSION = "1.2.4" # pragma: no mutate T = TypeVar("T") P = ParamSpec("P")