Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fixes #27

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @github/vuln-mgmt-eng
* @github/annotated-logger-reviewers
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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
# 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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion annotated_logger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions annotated_logger/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#
# 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
# - python-json-logger
# - 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
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
83 changes: 53 additions & 30 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,105 +20,128 @@
# - 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
# pytest-freezer
# 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
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
# hatch.envs.dev
# 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
12 changes: 6 additions & 6 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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)
2 changes: 1 addition & 1 deletion test/test_logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
20 changes: 10 additions & 10 deletions test/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]

Expand All @@ -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]

Expand Down Expand Up @@ -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]

Expand Down
Loading