diff --git a/.github/workflows/auto-pr-description.yml b/.github/workflows/auto-pr-description.yml index 0d9cb8a..0c1519c 100644 --- a/.github/workflows/auto-pr-description.yml +++ b/.github/workflows/auto-pr-description.yml @@ -43,7 +43,6 @@ jobs: const now = new Date().toISOString().slice(0,16).replace('T',' '); const body = process.env.PR_BODY; const base = context.payload.pull_request.base.ref; - const head = context.payload.pull_request.head.ref; const update = { owner: context.repo.owner, repo: context.repo.repo, @@ -51,13 +50,8 @@ jobs: body, }; - // Branch roles come from `.releaserc.cjs`: - // - base `release`: stable releases - // - base `main`: prereleases ("rc") if (base === 'release') { update.title = `Release! PR for ${now}`; - } else if (base === 'main') { - update.title = `PR for ${now}`; } await github.rest.pulls.update(update); diff --git a/.github/workflows/lint_and_test.yaml b/.github/workflows/lint_and_test.yaml index 59b3862..5e769cb 100644 --- a/.github/workflows/lint_and_test.yaml +++ b/.github/workflows/lint_and_test.yaml @@ -35,7 +35,3 @@ jobs: run: make all env: UV_PYTHON: ${{ matrix.python-version }} - - - name: Check if code was reformatted - if: always() - run: git diff --exit-code diff --git a/CHANGELOG.md b/CHANGELOG.md index 172ff2f..a58085e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [1.0.1-rc.1](https://github.com/disafronov/python-logging-objects-with-schema/compare/v1.0.0...v1.0.1-rc.1) (2026-05-22) + +### Bug Fixes + +* respect logger filters for validation errors ([d34e5b6](https://github.com/disafronov/python-logging-objects-with-schema/commit/d34e5b63f7326febee051a540dee197d9e02ff44)) + ## [1.0.0](https://github.com/disafronov/python-logging-objects-with-schema/compare/v0.4.1...v1.0.0) (2026-05-05) ### ⚠ BREAKING CHANGES diff --git a/Makefile b/Makefile index 5ff3661..880aa4d 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ PYTEST_CMD = uv run python -m pytest -v COVERAGE_OPTS = --cov --cov-report=term-missing --cov-report=html # Phony targets -.PHONY: all clean dead-code format help install lint test test-coverage +.PHONY: all clean dead-code format help install lint test # Default target help: ## Show this help message @@ -30,7 +30,7 @@ format: ## Format code lint: ## Run linting tools @echo "Running linting tools..." - uv run black --check . && uv run isort --check-only . && uv run flake8 . && uv run mypy . && uv run bandit -r -c pyproject.toml . + uv run black --check . && uv run isort --check-only . && uv run flake8 . && uv run mypy && uv run bandit -c pyproject.toml -r src/ dead-code: ## Check for dead code using vulture @echo "Checking for dead code..." diff --git a/pyproject.toml b/pyproject.toml index 1f9f7e7..bc109c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "uv_build" [project] name = "logging-objects-with-schema" -version = "1.0.0" +version = "1.0.1rc1" description = "Proxy logging wrapper that validates extra fields against a JSON schema." readme = "README.md" requires-python = ">=3.11" @@ -54,47 +54,21 @@ dev = [ [tool.isort] profile = "black" -line_length = 88 -multi_line_output = 3 [tool.black] line-length = 88 include = "\\.pyi?$" -extend-exclude = """ -/( - \\.eggs - | \\.git - | \\.hg - | \\.mypy_cache - | \\.tox - | \\.venv - | build - | dist -)/ -""" [tool.flake8] max-line-length = 88 extend-ignore = [ "E203", "W503" ] -exclude = [ ".venv", "__pycache__", ".git", "htmlcov" ] +exclude = [ ".venv" ] [tool.mypy] -exclude = "tests/" -warn_return_any = true +files = [ "src" ] +strict = true warn_unused_configs = true -disallow_untyped_defs = true -disallow_incomplete_defs = true -check_untyped_defs = true -disallow_untyped_decorators = true -no_implicit_optional = true -warn_redundant_casts = true -warn_unused_ignores = true -warn_no_return = true warn_unreachable = true -strict_equality = true - -[tool.bandit] -exclude_dirs = [ ".venv", "__pycache__", ".git", "htmlcov", "tests" ] [tool.coverage.run] source = [ "src" ] @@ -103,11 +77,8 @@ branch = true [tool.coverage.report] fail_under = 100 exclude_lines = [ - "def __repr__", - "if self\\.debug", "raise AssertionError", "raise NotImplementedError", - "if 0:", "if __name__ == .__main__.:", "@(abc\\.)?abstractmethod" ] @@ -119,6 +90,5 @@ directory = "htmlcov" [tool.vulture] min_confidence = 80 -exclude = [ "__pycache__" ] ignore_names = [ "cls" ] -paths = [ "src", "tests" ] +paths = [ "src" ] diff --git a/src/logging_objects_with_schema/schema_logger.py b/src/logging_objects_with_schema/schema_logger.py index 3b4fbf8..1af1387 100644 --- a/src/logging_objects_with_schema/schema_logger.py +++ b/src/logging_objects_with_schema/schema_logger.py @@ -185,7 +185,6 @@ def _log( sinfo, # sinfo - stack info from caller ) try: - self.callHandlers(error_record) + self.handle(error_record) except Exception: - # If handler failed, log error to stderr (standard logging behavior) sys.stderr.write(f"Error in logging handler: {error_record}\n") diff --git a/tests/private/test_schema_logger.py b/tests/private/test_schema_logger.py index f189285..d6ad39e 100644 --- a/tests/private/test_schema_logger.py +++ b/tests/private/test_schema_logger.py @@ -434,11 +434,11 @@ def mock_dumps(*args, **kwargs): assert "validation_errors" in output -def test_schema_logger_log_handles_callhandlers_exception( +def test_schema_logger_log_handles_validation_error_handler_exception( tmp_path: Path, monkeypatch: pytest.MonkeyPatch, ) -> None: - """SchemaLogger._log should handle callHandlers exception gracefully.""" + """SchemaLogger._log should handle validation error handler exceptions.""" monkeypatch.chdir(tmp_path) _write_schema( tmp_path, diff --git a/tests/test_logging_compatibility.py b/tests/test_logging_compatibility.py index 556e0be..5a30cd2 100644 --- a/tests/test_logging_compatibility.py +++ b/tests/test_logging_compatibility.py @@ -126,3 +126,35 @@ def test_schema_logger_accepts_extra_fields_without_error( output = stream.getvalue() assert "msg" in output + + +def test_schema_logger_validation_errors_respect_logger_filters( + tmp_path: Path, + monkeypatch: pytest.MonkeyPatch, +) -> None: + """Validation error records should pass through logger filters.""" + + monkeypatch.chdir(tmp_path) + _write_schema( + tmp_path, + { + "ServicePayload": { + "RequestID": {"type": "str", "source": "request_id"}, + }, + }, + ) + + stream = StringIO() + handler = logging.StreamHandler(stream) + handler.setFormatter(logging.Formatter("%(levelname)s:%(message)s")) + + logger = SchemaLogger("test-filtered-validation-errors") + logger.addHandler(handler) + logger.setLevel(logging.INFO) + logger.addFilter(lambda record: not record.getMessage().startswith("{")) + + logger.info("msg", extra={"request_id": 42}) + + output = stream.getvalue() + assert "INFO:msg" in output + assert "validation_errors" not in output diff --git a/uv.lock b/uv.lock index e9c413c..2fe1843 100644 --- a/uv.lock +++ b/uv.lock @@ -1363,7 +1363,7 @@ version = "0.10.0" [[package]] name = "logging-objects-with-schema" -version = "1.0.0" +version = "1.0.1rc1" [package.source] editable = "."