From e497f2418b58fa571cb64e367f5a2308167ca1a0 Mon Sep 17 00:00:00 2001 From: Dimitrios Liappis Date: Wed, 25 Jun 2025 16:59:36 +0300 Subject: [PATCH 1/6] Fix typo identified in #172 This commit fixes a mistake observed in https://github.com/elastic/ecs-logging-python/pull/172#discussion_r2166707106 and allows to simply the code further (no need for a helper function) --- ecs_logging/_stdlib.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ecs_logging/_stdlib.py b/ecs_logging/_stdlib.py index 33536bb..bae5afb 100644 --- a/ecs_logging/_stdlib.py +++ b/ecs_logging/_stdlib.py @@ -46,10 +46,6 @@ _LOGRECORD_DIR = set() -def _converter(secs: Optional[float] = None) -> time.struct_time: - return time.gmtime(secs) - - class StdlibFormatter(logging.Formatter): """ECS Formatter for the standard library ``logging`` module""" @@ -77,8 +73,7 @@ class StdlibFormatter(logging.Formatter): "process", "message", } | _LOGRECORD_DIR - - convert = _converter + converter: Callable[[float | None], time.struct_time] = staticmethod(time.gmtime) def __init__( self, From 6fdda72014fa0a3343cb31bef7f1d248a69d20a5 Mon Sep 17 00:00:00 2001 From: Dimitrios Liappis Date: Wed, 25 Jun 2025 17:26:19 +0300 Subject: [PATCH 2/6] Add 3.8/3.9 compatibility for mypy --- ecs_logging/_stdlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs_logging/_stdlib.py b/ecs_logging/_stdlib.py index bae5afb..cf5ac29 100644 --- a/ecs_logging/_stdlib.py +++ b/ecs_logging/_stdlib.py @@ -73,7 +73,7 @@ class StdlibFormatter(logging.Formatter): "process", "message", } | _LOGRECORD_DIR - converter: Callable[[float | None], time.struct_time] = staticmethod(time.gmtime) + converter: Callable[Union[float, None], time.struct_time] = staticmethod(time.gmtime) def __init__( self, From 1f5f274285b6eb7cb824c03dc4513cfda48c94d7 Mon Sep 17 00:00:00 2001 From: Dimitrios Liappis Date: Wed, 25 Jun 2025 17:28:17 +0300 Subject: [PATCH 3/6] Fix lint --- ecs_logging/_stdlib.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ecs_logging/_stdlib.py b/ecs_logging/_stdlib.py index cf5ac29..a835702 100644 --- a/ecs_logging/_stdlib.py +++ b/ecs_logging/_stdlib.py @@ -73,7 +73,9 @@ class StdlibFormatter(logging.Formatter): "process", "message", } | _LOGRECORD_DIR - converter: Callable[Union[float, None], time.struct_time] = staticmethod(time.gmtime) + converter: Callable[[Union[float, None]], time.struct_time] = staticmethod( + time.gmtime + ) def __init__( self, From 8727fb16a1770c408c02e4c1032805dc64ed46ec Mon Sep 17 00:00:00 2001 From: Dimitrios Liappis Date: Wed, 25 Jun 2025 17:46:17 +0300 Subject: [PATCH 4/6] Also fix precommit and old mypy --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a4ff5b..57e7e64 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: hooks: - id: check-bash-syntax - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.910 + rev: v1.16.1 hooks: - id: mypy args: From bf2123b540ab022088c0e3f56705948afb7c3be2 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Thu, 26 Jun 2025 09:09:55 +0200 Subject: [PATCH 5/6] Update ecs_logging/_stdlib.py --- ecs_logging/_stdlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs_logging/_stdlib.py b/ecs_logging/_stdlib.py index a835702..5cedb9c 100644 --- a/ecs_logging/_stdlib.py +++ b/ecs_logging/_stdlib.py @@ -73,7 +73,7 @@ class StdlibFormatter(logging.Formatter): "process", "message", } | _LOGRECORD_DIR - converter: Callable[[Union[float, None]], time.struct_time] = staticmethod( + converter: Callable[[Optional[float]], time.struct_time] = staticmethod( time.gmtime ) From 27a059ef9d5c08f0cdecf2ecc7363cafd5898e23 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Thu, 26 Jun 2025 09:13:12 +0200 Subject: [PATCH 6/6] Update ecs_logging/_stdlib.py --- ecs_logging/_stdlib.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ecs_logging/_stdlib.py b/ecs_logging/_stdlib.py index 5cedb9c..28e9f13 100644 --- a/ecs_logging/_stdlib.py +++ b/ecs_logging/_stdlib.py @@ -73,9 +73,7 @@ class StdlibFormatter(logging.Formatter): "process", "message", } | _LOGRECORD_DIR - converter: Callable[[Optional[float]], time.struct_time] = staticmethod( - time.gmtime - ) + converter: Callable[[Optional[float]], time.struct_time] = staticmethod(time.gmtime) def __init__( self,