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

Split core functionality and support orjson and msgspec #9

Merged
merged 27 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
60893a5
Refactor into core and json module, add orjson support
nhairs Apr 27, 2024
7f7ea2a
Format tests
nhairs Apr 27, 2024
e9aff5b
Allow tests to complete on all platforms
nhairs Apr 27, 2024
eaf56e2
Fix broken GHA spec
nhairs Apr 27, 2024
c36d6da
Don't support defaults kwargs (py310+ only)
nhairs Apr 27, 2024
4b19678
Drop py37 support, begin testing again py313
nhairs Apr 27, 2024
0d8b8a1
Fix py313 in GHA
nhairs Apr 27, 2024
3897a97
Don't instlal python on pypy
nhairs Apr 27, 2024
2eb8820
Run py313 in py313...
nhairs Apr 27, 2024
bc2b96e
Avoid orjson on python 3.13 while its not supported
nhairs Apr 27, 2024
1441721
Migrate tests to pytest, test OrjsonFormatter where possible
nhairs Apr 28, 2024
c017bef
Update docstrings to use mkdocstrings compatible
nhairs Apr 28, 2024
457a74c
Fix formatting, linting, typing
nhairs Apr 28, 2024
0d2bc65
Remove py37 from tox config
nhairs Apr 28, 2024
0ee6b9a
Maintain backwards compatibility
nhairs Apr 29, 2024
a0b595b
Add more tests
nhairs Apr 30, 2024
77dcdae
Add support for deprecated json.RESERVED_ATTRS
nhairs Apr 30, 2024
b61fc98
fix assert in test
nhairs May 1, 2024
89f0820
Update test names
nhairs May 3, 2024
a2df91b
Add support for msgspec
nhairs May 3, 2024
44c610d
Fix msgspec specifiers
nhairs May 3, 2024
32f763f
simplify ORJSON_AVAILABLE check
nhairs May 3, 2024
487388c
Update README and CHANGELOG
nhairs May 3, 2024
5cc6e3d
Fix formatting
nhairs May 3, 2024
ce76b66
Add other encoders to README
nhairs May 5, 2024
44406d3
Update freezegun issue references
nhairs May 5, 2024
5a6b959
Remove optional dependencies for specific encoders
nhairs May 5, 2024
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
Prev Previous commit
Next Next commit
Add support for deprecated json.RESERVED_ATTRS
  • Loading branch information
nhairs committed Apr 30, 2024
commit 77dcdae5974424b5f44ae11b65525bea92909a42
13 changes: 13 additions & 0 deletions src/pythonjsonlogger/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import json
import traceback
from typing import Any, Callable, Optional, Union
import warnings

## Application
from . import core
Expand Down Expand Up @@ -97,3 +98,15 @@ def jsonify_log_record(self, log_record: core.LogRecord) -> str:
indent=self.json_indent,
ensure_ascii=self.json_ensure_ascii,
)


### DEPRECATED COMPATIBILITY
### ============================================================================
def __getattr__(name: str):
if name == "RESERVED_ATTRS":
warnings.warn(
"RESERVED_ATTRS has been moved to pythonjsonlogger.core",
DeprecationWarning,
)
return core.RESERVED_ATTRS
raise AttributeError(f"module {__name__} has no attribute {name}")
8 changes: 8 additions & 0 deletions tests/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ def test_jsonlogger_deprecated():
with pytest.deprecated_call():
pythonjsonlogger.jsonlogger
return


def test_jsonlogger_reserved_attrs_deprecated():
with pytest.deprecated_call():
# Note: We use json instead of jsonlogger as jsonlogger will also produce
# a DeprecationWarning and we specifically want the one for RESERVED_ATTRS
pythonjsonlogger.json.RESERVED_ATTRS
return
Loading