File tree 6 files changed +48
-18
lines changed
6 files changed +48
-18
lines changed Original file line number Diff line number Diff line change 2
2
* .swp
3
3
build
4
4
dist
5
+ dist_uploaded
5
6
* .egg-info
6
7
7
8
# 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.
4
4
The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
5
5
and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
6
6
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
+
7
13
## [ 3.2.0] ( https://github.com/nhairs/python-json-logger/compare/v3.1.0...v3.2.0 ) - 2024-12-11
8
14
9
15
### Changed
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
5
5
[project ]
6
6
name = " python-json-logger"
7
- version = " 3.2.0 "
7
+ version = " 3.2.1 "
8
8
description = " JSON Log Formatter for the Python Logging Package"
9
9
authors = [
10
10
{
name =
" Zakaria Zajac" ,
email =
" [email protected] " },
Original file line number Diff line number Diff line change 8
8
## Installed
9
9
10
10
## Application
11
- import pythonjsonlogger . json
12
- import pythonjsonlogger . utils
11
+ from . import json
12
+ from . import utils
13
13
14
14
### CONSTANTS
15
15
### ============================================================================
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 4
4
from __future__ import annotations
5
5
6
6
## Standard Library
7
+ import subprocess
8
+ import sys
7
9
8
10
## Installed
9
11
import pytest
16
18
### ============================================================================
17
19
def test_jsonlogger_deprecated ():
18
20
with pytest .deprecated_call ():
19
- pythonjsonlogger .jsonlogger
21
+ import pythonjsonlogger .jsonlogger
20
22
return
21
23
22
24
@@ -26,3 +28,18 @@ def test_jsonlogger_reserved_attrs_deprecated():
26
28
# a DeprecationWarning and we specifically want the one for RESERVED_ATTRS
27
29
pythonjsonlogger .json .RESERVED_ATTRS
28
30
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