Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nhairs/python-json-logger
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: nhairs/python-json-logger
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: refactor/centralize-formatters-fix-pypy
Choose a head ref
  • 7 commits
  • 9 files changed
  • 2 contributors

Commits on May 21, 2025

  1. Configuration menu
    Copy the full SHA
    fde1e9c View commit details
    Browse the repository at this point in the history
  2. Update docs

    nhairs committed May 21, 2025
    Configuration menu
    Copy the full SHA
    7f0a6bb View commit details
    Browse the repository at this point in the history

Commits on May 26, 2025

  1. Configuration menu
    Copy the full SHA
    df922fb View commit details
    Browse the repository at this point in the history
  2. [core] Add support for comma format

    Fixes #15
    nhairs committed May 26, 2025
    Configuration menu
    Copy the full SHA
    81d38e8 View commit details
    Browse the repository at this point in the history
  3. Update tests

    nhairs committed May 26, 2025
    Configuration menu
    Copy the full SHA
    8ffd19d View commit details
    Browse the repository at this point in the history

Commits on Jun 26, 2025

  1. Centralize formatter lists for tests and fix PyPy CI

    This commit centralizes the definitions of formatter lists used for
    testing and resolves an ImportError that was occurring in PyPy
    environments during test collection.
    
    Key changes:
    
    1.  Centralized Formatter Lists in `tests/__init__.py`:
        *   Added `from __future__ import annotations` for modern type hints.
        *   Defined `ALL_FORMATTERS: List[Type[BaseJsonFormatter]]` containing
            actual formatter class objects (`JsonFormatter`, and conditionally
            `OrjsonFormatter`, `MsgspecFormatter` based on availability of
            their underlying packages).
        *   Defined `ALL_FORMATTER_PATHS: List[str]` derived from
            `ALL_FORMATTERS` (e.g., `["pythonjsonlogger.json.JsonFormatter", ...]`).
        *   The conditional inclusion of formatters now correctly relies on
            `pythonjsonlogger.ORJSON_AVAILABLE` and
            `pythonjsonlogger.MSGSPEC_AVAILABLE` flags to prevent import
            attempts if dependencies are missing.
    
    2.  Updated `tests/test_formatters.py`:
        *   Removed its local definition of `ALL_FORMATTERS`.
        *   Now imports and uses the centralized `ALL_FORMATTERS` list from
            `tests.__init__`.
    
    3.  Updated `tests/test_dictconfig.py`:
        *   Removed its local definition of `SUPPORTED_DICTCONFIG_FORMATTERS`.
        *   Removed direct top-level imports of `pythonjsonlogger.orjson` and
            `pythonjsonlogger.msgspec` modules, which were causing
            `MissingPackageError` on PyPy environments where these optional
            dependencies are not installed. The `test_dictconfig.py` now relies
            on `ALL_FORMATTER_PATHS` imported from `tests.__init__`, where the
            conditional logic correctly handles availability.
        *   The parameterized test
            `test_external_reference_support_parameterized` now correctly uses
            the imported `ALL_FORMATTER_PATHS`.
    
    This refactoring ensures a single source of truth for formatter lists,
    improves maintainability, and crucially fixes the test collection errors
    on PyPy environments. All linters and tests now pass across all
    configured environments in `tox`.
    google-labs-jules[bot] committed Jun 26, 2025
    Configuration menu
    Copy the full SHA
    c9b76ff View commit details
    Browse the repository at this point in the history

Commits on Jun 27, 2025

  1. Focus dictConfig tests on library-specific integration

    This commit refines `tests/test_dictconfig.py` to concentrate on
    testing aspects unique to `python-json-logger`'s interaction with
    `logging.config.dictConfig`, rather than general `dictConfig` behaviors
    that are the responsibility of the standard library.
    
    Key changes:
    
    1.  Removed Redundant Tests:
        - `test_disable_existing_loggers`: This test primarily verified the
          standard `disable_existing_loggers` flag of `dictConfig`.
        - `test_multiple_handlers_and_formatters`: While it used the library's
          formatter, the core functionality tested (routing to multiple
          handlers) is standard `dictConfig` behavior.
        - `test_filter_configuration`: Testing filter application is also
          a standard `dictConfig` feature.
        - Associated helper classes (`TestStream1`, `TestStream2`, `LevelFilter`)
          and global instances (`test_stream_1_instance`, etc.) were removed
          as they were only used by these tests.
    
    2.  Retained Focused Tests:
        - `test_external_reference_support_parameterized`: Kept as it tests
          the crucial `ext://` reference resolution for formatter options,
          which is a key integration point for `python-json-logger` with
          `dictConfig`. This test is also parameterized to run against all
          supported formatter types (`JsonFormatter`, `OrjsonFormatter`,
          `MsgspecFormatter` via `ALL_FORMATTER_PATHS`).
        - `test_json_encoder_option` and `test_json_serializer_option`: Kept
          as they specifically test `ext://` references for configuring custom
          encoders and serializers, a `dictConfig`-specific interaction for
          the library's formatters.
    
    This streamlining ensures that `test_dictconfig.py` is more focused on
    validating the unique aspects of `python-json-logger`'s support for and
    integration with `dictConfig`, reducing redundancy with tests that would
    be more appropriate for the standard library's own test suite.
    
    All linters and the full `tox` test suite pass with these changes.
    google-labs-jules[bot] committed Jun 27, 2025
    Configuration menu
    Copy the full SHA
    df7cb80 View commit details
    Browse the repository at this point in the history
Loading