From 0668d4fd28ffd5f2b029de99f56cc1acd554b066 Mon Sep 17 00:00:00 2001 From: crimsonknave Date: Wed, 11 Dec 2024 16:37:44 -0500 Subject: [PATCH 1/4] Fix references to previous name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e7eb03..7333725 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [contribution]: https://github.com/github/annotated-logger/blob/main/CONTRIBUTING.md -[![Coverage badge](https://github.com/github/logger-decorator/raw/python-coverage-comment-action-data/badge.svg)](https://github.com/github/logger-decorator/tree/python-coverage-comment-action-data) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/) +[![Coverage badge](https://github.com/github/annotated-logger/raw/python-coverage-comment-action-data/badge.svg)](https://github.com/github/annotated-logger/tree/python-coverage-comment-action-data) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/) The `annotated-logger` package provides a decorator that can inject a annotatable logger object into a method or class. This logger object is a drop in replacement for `logging.logger` with additional functionality. From d8a78484bfff9d3e72c70d924e5255f3a55e3451 Mon Sep 17 00:00:00 2001 From: crimsonknave Date: Wed, 11 Dec 2024 16:45:45 -0500 Subject: [PATCH 2/4] Bump dependencies and update for new linting --- .pre-commit-config.yaml | 2 +- annotated_logger/__init__.py | 2 +- annotated_logger/mocks.py | 4 +- pyproject.toml | 1 - requirements.txt | 12 ++--- requirements/requirements-dev.txt | 83 ++++++++++++++++++++----------- test/conftest.py | 12 ++--- test/test_logging_config.py | 2 +- test/test_plugins.py | 20 ++++---- 9 files changed, 80 insertions(+), 58 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 25cd103..a71a8bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.5.7 + rev: v0.8.2 hooks: # Run the linter. - id: ruff diff --git a/annotated_logger/__init__.py b/annotated_logger/__init__.py index 49ca0f6..e4309ff 100644 --- a/annotated_logger/__init__.py +++ b/annotated_logger/__init__.py @@ -6,13 +6,13 @@ import logging.config import time import uuid +from collections.abc import Iterator from copy import copy, deepcopy from typing import ( TYPE_CHECKING, Any, Callable, Concatenate, - Iterator, Literal, ParamSpec, Protocol, diff --git a/annotated_logger/mocks.py b/annotated_logger/mocks.py index 93f80a8..232e0d6 100644 --- a/annotated_logger/mocks.py +++ b/annotated_logger/mocks.py @@ -234,13 +234,13 @@ def assert_logged( assert_logged.check(self) -@pytest.fixture() +@pytest.fixture def annotated_logger_object() -> logging.Logger: """Logger to wrap with the `annotated_logger_mock` fixture.""" return logging.getLogger("annotated_logger") -@pytest.fixture() +@pytest.fixture def annotated_logger_mock(annotated_logger_object: logging.Logger) -> AnnotatedLogMock: """Fixture for a mock of the annotated logger.""" handler = annotated_logger_object.handlers[0] diff --git a/pyproject.toml b/pyproject.toml index b8e70d3..996adf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -102,7 +102,6 @@ filterwarnings = [ [tool.ruff] lint.select = ["ALL"] lint.ignore = [ - "ANN101", "D100", "D104", # Disabled as they conflict with the formatter: "W191", "E111", "E114", "E117", "D206", "D300", "Q000", "Q001", "Q002", "Q003", "COM812", "COM819", "ISC001", "ISC002", diff --git a/requirements.txt b/requirements.txt index a929f47..928637c 100644 --- a/requirements.txt +++ b/requirements.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 # # - makefun # - pychoir @@ -7,13 +7,13 @@ # - requests # -certifi==2024.7.4 +certifi==2024.8.30 # via requests -charset-normalizer==3.3.2 +charset-normalizer==3.4.0 # via requests -idna==3.7 +idna==3.10 # via requests -makefun==1.15.2 +makefun==1.15.6 # via hatch.envs.default pychoir==0.0.27 # via hatch.envs.default @@ -21,5 +21,5 @@ python-json-logger==2.0.7 # via hatch.envs.default requests==2.32.3 # via hatch.envs.default -urllib3==2.2.2 +urllib3==2.2.3 # via requests diff --git a/requirements/requirements-dev.txt b/requirements/requirements-dev.txt index 20f5548..48656e8 100644 --- a/requirements/requirements-dev.txt +++ b/requirements/requirements-dev.txt @@ -20,61 +20,72 @@ # - requests # -certifi==2024.7.4 +certifi==2024.8.30 # via requests cfgv==3.4.0 # via pre-commit -charset-normalizer==3.3.2 +charset-normalizer==3.4.0 # via requests click==8.1.7 # via mutmut -coverage==7.5.4 +coverage==7.6.9 # via # hatch.envs.dev # pytest-cov -distlib==0.3.8 +distlib==0.3.9 # via virtualenv -exceptiongroup==1.2.1 +exceptiongroup==1.2.2 # via pytest -filelock==3.15.4 +filelock==3.16.1 # via virtualenv freezegun==1.5.1 # via pytest-freezer -glob2==0.7 - # via mutmut -identify==2.5.36 +identify==2.6.3 # via pre-commit -idna==3.7 +idna==3.10 # via requests iniconfig==2.0.0 # via pytest -junit-xml==1.9 +junit-xml==1.8 # via mutmut -makefun==1.15.2 +linkify-it-py==2.0.3 + # via markdown-it-py +makefun==1.15.6 # via hatch.envs.dev -mutmut==2.5.0 +markdown-it-py==3.0.0 + # via + # mdit-py-plugins + # rich + # textual +mdit-py-plugins==0.4.2 + # via markdown-it-py +mdurl==0.1.2 + # via markdown-it-py +mutmut==3.2.2 # via hatch.envs.dev nodeenv==1.9.1 # via # pre-commit # pyright -packaging==24.1 +packaging==24.2 # via pytest parso==0.8.4 # via mutmut -platformdirs==4.2.2 - # via virtualenv +platformdirs==4.3.6 + # via + # textual + # virtualenv pluggy==1.5.0 # via pytest -pony==0.7.17 - # via mutmut -pre-commit==3.7.1 +pre-commit==4.0.1 # via hatch.envs.dev pychoir==0.0.27 # via hatch.envs.dev -pyright==1.1.376 +pygments==2.18.0 + # via rich +pyright==1.1.390 # via hatch.envs.dev -pytest==8.2.2 +pytest==8.3.4 # via # hatch.envs.dev # pytest-cov @@ -82,7 +93,7 @@ pytest==8.2.2 # pytest-github-actions-annotate-failures # pytest-mock # pytest-randomly -pytest-cov==5.0.0 +pytest-cov==6.0.0 # via hatch.envs.dev pytest-freezer==0.4.8 # via hatch.envs.dev @@ -90,13 +101,13 @@ pytest-github-actions-annotate-failures==0.2.0 # via hatch.envs.dev pytest-mock==3.14.0 # via hatch.envs.dev -pytest-randomly==3.15.0 +pytest-randomly==3.16.0 # via hatch.envs.dev python-dateutil==2.9.0.post0 # via freezegun python-json-logger==2.0.7 # via hatch.envs.dev -pyyaml==6.0.1 +pyyaml==6.0.2 # via pre-commit requests==2.32.3 # via @@ -104,21 +115,33 @@ requests==2.32.3 # requests-mock requests-mock==1.12.1 # via hatch.envs.dev -ruff==0.5.7 +rich==13.9.4 + # via textual +ruff==0.8.2 # via hatch.envs.dev -six==1.16.0 +setproctitle==1.3.4 + # via mutmut +six==1.17.0 # via # junit-xml # python-dateutil +textual==0.89.1 + # via mutmut toml==0.10.2 # via mutmut -tomli==2.0.1 +tomli==2.2.1 # via # coverage # pytest typing-extensions==4.12.2 - # via hatch.envs.dev -urllib3==2.2.2 + # via + # hatch.envs.dev + # pyright + # rich + # textual +uc-micro-py==1.0.3 + # via linkify-it-py +urllib3==2.2.3 # via requests -virtualenv==20.26.3 +virtualenv==20.28.0 # via pre-commit diff --git a/test/conftest.py b/test/conftest.py index 614d1ef..8efdf25 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -16,7 +16,7 @@ pytest_plugins = ["annotated_logger.mocks"] -@pytest.fixture() +@pytest.fixture def fail_mock(mocker): return mocker.patch("annotated_logger.mocks.pytest.fail") @@ -27,26 +27,26 @@ def fail_mock(mocker): # logging config, as it gets clobbered by the most recently imported module # This is a more complete solution than using `pytest-forked` which only # fixed the issue if the test file didn't import more than one that conflicted -@pytest.fixture() +@pytest.fixture def _reload_api(): importlib.reload(example.api) -@pytest.fixture() +@pytest.fixture def _reload_calculator(): importlib.reload(example.calculator) -@pytest.fixture() +@pytest.fixture def _reload_default(): importlib.reload(example.default) -@pytest.fixture() +@pytest.fixture def _reload_actions(): importlib.reload(example.actions) -@pytest.fixture() +@pytest.fixture def _reload_logging_config(): importlib.reload(example.logging_config) diff --git a/test/test_logging_config.py b/test/test_logging_config.py index 82e62e5..f9da807 100644 --- a/test/test_logging_config.py +++ b/test/test_logging_config.py @@ -6,7 +6,7 @@ from annotated_logger.mocks import AnnotatedLogMock -@pytest.fixture() +@pytest.fixture def annotated_logger_object(): return logging.getLogger("annotated_logger.logging_config") diff --git a/test/test_plugins.py b/test/test_plugins.py index 234bf66..1f144e8 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -37,7 +37,7 @@ def filter(self, _record: logging.LogRecord) -> bool: raise SpyPlugin.BoomError -@pytest.fixture() +@pytest.fixture def annotated_logger(plugins): return AnnotatedLogger( plugins=plugins, @@ -49,41 +49,41 @@ def annotated_logger(plugins): ) -@pytest.fixture() +@pytest.fixture def plugins(): return [] -@pytest.fixture() +@pytest.fixture def annotate_logs(annotated_logger): return annotated_logger.annotate_logs -@pytest.fixture() +@pytest.fixture def broken_plugin(): return SpyPlugin(working=False) -@pytest.fixture() +@pytest.fixture def working_plugin(): return SpyPlugin(working=True) -@pytest.fixture() +@pytest.fixture def skip_plugin(): return SpyPlugin(filter_message=True) # Request the annotated_logger fixture so that the config # has been setup before we get the logger -@pytest.fixture() +@pytest.fixture def annotated_logger_object(annotated_logger): # noqa: ARG001 return logging.getLogger("annotated_logger") class TestPlugins: class TestSkip: - @pytest.fixture() + @pytest.fixture def plugins(self, skip_plugin): return [skip_plugin] @@ -99,7 +99,7 @@ def should_work(): assert annotated_logger_mock.records == [] class TestWorking: - @pytest.fixture() + @pytest.fixture def plugins(self, working_plugin): return [working_plugin] @@ -128,7 +128,7 @@ def throws_exception(): assert working_plugin.exception_triggered is True class TestBroken: - @pytest.fixture() + @pytest.fixture def plugins(self, broken_plugin, working_plugin): return [broken_plugin, working_plugin, broken_plugin] From 031d8beed11e86f41df860e97be73557f4af5c2a Mon Sep 17 00:00:00 2001 From: crimsonknave Date: Wed, 11 Dec 2024 16:56:55 -0500 Subject: [PATCH 3/4] Sync pyright pre-commit version --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a71a8bf..d82a0ca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: # Run the formatter. - id: ruff-format - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.382 + rev: v1.1.390 hooks: - id: pyright # I don't love having to specify these here, but pre-commit only seems to work From 1b9b24ad685b36cd295ac9eb1802b7b40fea7230 Mon Sep 17 00:00:00 2001 From: crimsonknave Date: Wed, 11 Dec 2024 16:57:50 -0500 Subject: [PATCH 4/4] Update codeowners --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d583413..b621e71 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @github/vuln-mgmt-eng +* @github/annotated-logger-reviewers