Skip to content

Commit 9270d73

Browse files
committed
Address todos / review comments
1 parent d1d8c58 commit 9270d73

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/pythonjsonlogger/core.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def __init__(
184184
"""
185185
## logging.Formatter compatibility
186186
## ---------------------------------------------------------------------
187-
# Note: validate added in 3.8, defaults added in 3.10
187+
# Note: validate added in python 3.8, defaults added in 3.10
188188
if style in logging._STYLES:
189189
_style = logging._STYLES[style][0](fmt) # type: ignore[operator]
190190
if validate:
@@ -196,6 +196,8 @@ def __init__(
196196
self._style = style
197197
self._fmt = fmt
198198

199+
# TODO: Validate comma format
200+
199201
else:
200202
raise ValueError(f"Style must be one of: {','.join(logging._STYLES.keys())}")
201203

@@ -278,15 +280,9 @@ def parse(self) -> List[str]:
278280
list of fields to be extracted and serialized
279281
"""
280282
if self._fmt is None:
281-
# TODO: does it matter that we do this before checking if the style is valid?
282-
# (we already (mostly) check for valid style names in __init__
283283
return []
284284

285285
if isinstance(self._style, str) and self._style == ",":
286-
# TODO: should we check that there are no empty fields?
287-
# If yes we should do this in __init__ where we validate other styles?
288-
# Do we drop empty fields?
289-
# etc
290286
return [field.strip() for field in self._fmt.split(",") if field.strip()]
291287

292288
if isinstance(self._style, logging.StringTemplateStyle):

tests/test_formatters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def test_default_format(env: LoggingEnvironment, class_: type[BaseJsonFormatter]
158158

159159
@pytest.mark.parametrize("class_", ALL_FORMATTERS)
160160
def test_percentage_format(env: LoggingEnvironment, class_: type[BaseJsonFormatter]):
161-
# Note: All kind of different %s styles to check the regex
161+
# Note: We use different %s styles in the format to check the regex correctly collects them
162162
env.set_formatter(class_("[%(levelname)8s] %(message)s %(filename)s:%(lineno)d %(asctime)"))
163163

164164
msg = "testing logging format"

0 commit comments

Comments
 (0)