File tree Expand file tree Collapse file tree 6 files changed +48
-18
lines changed Expand file tree Collapse file tree 6 files changed +48
-18
lines changed Original file line number Diff line number Diff line change 22* .swp
33build
44dist
5+ dist_uploaded
56* .egg-info
67
78# Tests and validation
Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
55and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
66
7+ ## [ 3.2.1] ( https://github.com/nhairs/python-json-logger/compare/v3.2.0...v3.2.1 ) - 2024-12-16
8+
9+ ### Fixed
10+ - Import error on ` import pythonjsonlogger.jsonlogger ` [ #29 ] ( https://github.com/nhairs/python-json-logger/issues/29 )
11+
12+
713## [ 3.2.0] ( https://github.com/nhairs/python-json-logger/compare/v3.1.0...v3.2.0 ) - 2024-12-11
814
915### Changed
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44
55[project ]
66name = " python-json-logger"
7- version = " 3.2.0 "
7+ version = " 3.2.1 "
88description = " JSON Log Formatter for the Python Logging Package"
99authors = [
1010 {
name =
" Zakaria Zajac" ,
email =
" [email protected] " },
Original file line number Diff line number Diff line change 88## Installed
99
1010## Application
11- import pythonjsonlogger . json
12- import pythonjsonlogger . utils
11+ from . import json
12+ from . import utils
1313
1414### CONSTANTS
1515### ============================================================================
16- ORJSON_AVAILABLE = pythonjsonlogger .utils .package_is_available ("orjson" )
17- MSGSPEC_AVAILABLE = pythonjsonlogger .utils .package_is_available ("msgspec" )
18-
19-
20- ### DEPRECATED COMPATIBILITY
21- ### ============================================================================
22- def __getattr__ (name : str ):
23- if name == "jsonlogger" :
24- warnings .warn (
25- "pythonjsonlogger.jsonlogger has been moved to pythonjsonlogger.json" ,
26- DeprecationWarning ,
27- )
28- return pythonjsonlogger .json
29- raise AttributeError (f"module { __name__ } has no attribute { name } " )
16+ ORJSON_AVAILABLE = utils .package_is_available ("orjson" )
17+ MSGSPEC_AVAILABLE = utils .package_is_available ("msgspec" )
Original file line number Diff line number Diff line change 1+ """Stub module retained for compatibility.
2+
3+ It retains access to old names whilst sending deprecation warnings.
4+ """
5+
6+ # pylint: disable=wrong-import-position,unused-import
7+
8+ import warnings
9+
10+ ## Throw warning
11+ warnings .warn (
12+ "pythonjsonlogger.jsonlogger has been moved to pythonjsonlogger.json" ,
13+ DeprecationWarning ,
14+ )
15+
16+ ## Import names
17+ from .json import JsonFormatter , JsonEncoder
18+ from .core import RESERVED_ATTRS
Original file line number Diff line number Diff line change 44from __future__ import annotations
55
66## Standard Library
7+ import subprocess
8+ import sys
79
810## Installed
911import pytest
1618### ============================================================================
1719def test_jsonlogger_deprecated ():
1820 with pytest .deprecated_call ():
19- pythonjsonlogger .jsonlogger
21+ import pythonjsonlogger .jsonlogger
2022 return
2123
2224
@@ -26,3 +28,18 @@ def test_jsonlogger_reserved_attrs_deprecated():
2628 # a DeprecationWarning and we specifically want the one for RESERVED_ATTRS
2729 pythonjsonlogger .json .RESERVED_ATTRS
2830 return
31+
32+
33+ @pytest .mark .parametrize (
34+ "command" ,
35+ [
36+ "from pythonjsonlogger import jsonlogger" ,
37+ "import pythonjsonlogger.jsonlogger" ,
38+ "from pythonjsonlogger.jsonlogger import JsonFormatter" ,
39+ "from pythonjsonlogger.jsonlogger import RESERVED_ATTRS" ,
40+ ],
41+ )
42+ def test_import (command : str ):
43+ output = subprocess .check_output ([sys .executable , "-c" , f"{ command } ;print('OK')" ])
44+ assert output .strip () == b"OK"
45+ return
You can’t perform that action at this time.
0 commit comments