Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

Conversation

@erdnaxeli
Copy link
Contributor

Now that the package include py.typed, mypy actually checks the type. I am using disallow-untyped-calls, so it fails because the constructor of JsonFormatter is untyped. This PR fixes it.

I run tox which runs black, which fixed some formatting issues.

Comment on lines 109 to 123
def __init__(
self,
*args: Any,
json_default: OptionalCallableOrStr = None,
json_encoder: OptionalCallableOrStr = None,
json_serialiser: OptionalCallableOrStr = json.dumps,
json_indent: Optional[Union[int, str]] = None,
json_ensure_ascii: bool = True,
prefix: str = "",
rename_fields: Optional[dict] = None,
static_fields: Optional[dict] = None,
reserved_attrs: Tuple[str, ...] = RESERVED_ATTRS,
timestamp: Union[bool, str] = False,
**kwargs: Any
):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The important part is here.

Comment on lines +145 to +154
self.json_default = self._str_to_fn(json_default)
self.json_encoder = self._str_to_fn(json_encoder)
self.json_serializer = self._str_to_fn(json_serialiser)
self.json_indent = json_indent
self.json_ensure_ascii = json_ensure_ascii
self.prefix = prefix
self.rename_fields = rename_fields or {}
self.static_fields = static_fields or {}
self.reserved_attrs = dict(zip(reserved_attrs, reserved_attrs))
self.timestamp = kwargs.pop("timestamp", False)
self.timestamp = timestamp
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Comment on lines +130 to +131
:param json_indent: indent parameter for json.dumps
:param json_ensure_ascii: ensure_ascii parameter for json.dumps
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the duplicated doc for json_indent and I moved json_ensure_ascii next to it.

Copy link
Owner

@madzak madzak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an aside, typing really makes this code look ugly as hell :(

@madzak madzak merged commit 5f85723 into madzak:master Feb 28, 2023
@erdnaxeli erdnaxeli deleted the fix/typing branch March 1, 2023 09:04
@jenstroeger
Copy link

As an aside, typing really makes this code look ugly as hell :(

Heheh, but it’s worthwhile to catch bugs. But anyway, do you know when this will roll out into a new release?

@erdnaxeli
Copy link
Contributor Author

erdnaxeli commented May 2, 2023

Hi, could you consider making a new release? Currently all our apps have a version constraint <2.7 on this lib in order to mypy to pass.

@OmerFI
Copy link

OmerFI commented Nov 7, 2023

Hi @madzak could you publish a release with this change included?

nhairs pushed a commit to nhairs/python-json-logger that referenced this pull request Apr 1, 2024
madzak/python-json-logger#170 was included on the main branch of the upstream but never released, thus it was inadvertently released in `3.0.0`. This included the accidental renaming from US spelling to UK spelling of "serializer".

This PR reverts that change.


Co-authored-by: Julian Gilbey <jdg@debian.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants