Skip to content

Commit 0e1fcfe

Browse files
committed
pylint and not required
1 parent 3e37573 commit 0e1fcfe

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

packages/service-library/src/servicelib/logging_errors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from pprint import pformat
3-
from typing import Any, NotRequired, TypedDict
3+
from typing import Any, TypedDict
44

55
from models_library.error_codes import ErrorCodeStr
66
from models_library.errors_classes import OsparcErrorMixin
@@ -43,7 +43,7 @@ def create_troubleshotting_log_message(
4343

4444
class LogKwargs(TypedDict):
4545
msg: str
46-
extra: NotRequired[LogExtra | None]
46+
extra: LogExtra
4747

4848

4949
def create_troubleshotting_log_kwargs(

packages/service-library/src/servicelib/logging_utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
from datetime import datetime
1515
from inspect import getframeinfo, stack
1616
from pathlib import Path
17-
from pprint import pformat
18-
from typing import Any, TypeAlias, TypedDict, TypeVar
17+
from typing import Any, NotRequired, TypeAlias, TypedDict, TypeVar
1918

2019
from .utils_secrets import mask_sensitive_data
2120

@@ -319,9 +318,9 @@ def log_catch(logger: logging.Logger, *, reraise: bool = True) -> Iterator[None]
319318
raise exc from exc
320319

321320

322-
class LogExtra(TypedDict, total=False):
323-
log_uid: str
324-
log_oec: str
321+
class LogExtra(TypedDict):
322+
log_uid: NotRequired[str]
323+
log_oec: NotRequired[str]
325324

326325

327326
LogLevelInt: TypeAlias = int

packages/service-library/tests/test_logging_errors.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ class MyError(OsparcErrorMixin, RuntimeError):
4141
)
4242

4343
assert log_kwargs["msg"] == log_msg
44+
assert log_kwargs["extra"] is not None
4445
assert (
45-
log_kwargs["extra"]["log_uid"] == "123"
46+
# pylint: disable=unsubscriptable-object
47+
log_kwargs["extra"]["log_uid"]
48+
== "123"
4649
), "user_id is injected as extra from context"
4750

4851
with caplog.at_level(logging.WARNING):

0 commit comments

Comments
 (0)