Skip to content

Commit e190ad6

Browse files
authored
Fix type hint for _stdlib style arg (#77)
* Fix type hint for _stdlib `style` arg * Add typing_extensions for <py3.8 * More mypy fixes * Ignore missing Literal
1 parent 0c6746d commit e190ad6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repos:
1515
rev: v0.910
1616
hooks:
1717
- id: mypy
18-
args: [--strict, --show-error-codes, --no-warn-unused-ignores]
18+
args: [--strict, --show-error-codes, --no-warn-unused-ignores, --implicit-reexport]
1919
- repo: https://github.com/ambv/black
2020
rev: 21.6b0
2121
hooks:

ecs_logging/_stdlib.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
if TYPE_CHECKING:
3434
from typing import Optional, Any, Callable, Dict, Sequence
3535

36+
try:
37+
from typing import Literal, Union # type: ignore
38+
except ImportError:
39+
from typing_extensions import Literal, Union # type: ignore
40+
3641

3742
# Load the attributes of a LogRecord so if some are
3843
# added in the future we won't mistake them for 'extra=...'
@@ -75,7 +80,7 @@ def __init__(
7580
self, # type: Any
7681
fmt=None, # type: Optional[str]
7782
datefmt=None, # type: Optional[str]
78-
style="%", # type: str
83+
style="%", # type: Union[Literal["%"], Literal["{"], Literal["$"]]
7984
validate=None, # type: Optional[bool]
8085
stack_trace_limit=None, # type: Optional[int]
8186
extra=None, # type: Optional[Dict[str, Any]]

0 commit comments

Comments
 (0)