|
32 | 32 |
|
33 | 33 | from typing import Any, Callable, Dict, Optional, Sequence, Union
|
34 | 34 |
|
35 |
| -try: |
36 |
| - from typing import Literal # type: ignore |
37 |
| -except ImportError: |
38 |
| - from typing_extensions import Literal # type: ignore |
| 35 | +if sys.version_info >= (3, 8): |
| 36 | + from typing import Literal |
| 37 | +else: |
| 38 | + from typing_extensions import Literal |
39 | 39 |
|
40 | 40 |
|
41 | 41 | # Load the attributes of a LogRecord so if some are
|
@@ -105,13 +105,15 @@ def __init__(
|
105 | 105 |
|
106 | 106 | exclude_keys=["error"]
|
107 | 107 | """
|
108 |
| - _kwargs = {} |
109 |
| - if validate is not None: |
110 |
| - # validate was introduced in py3.8 so we need to only provide it if the user provided it |
111 |
| - _kwargs["validate"] = validate |
112 |
| - super().__init__( # type: ignore[call-arg] |
113 |
| - fmt=fmt, datefmt=datefmt, style=style, **_kwargs # type: ignore[arg-type] |
114 |
| - ) |
| 108 | + # validate was introduced in py3.8 so we need to only provide it if the user provided it |
| 109 | + if sys.version_info >= (3, 8) and validate is not None: |
| 110 | + super().__init__( |
| 111 | + fmt=fmt, datefmt=datefmt, style=style, validate=validate, |
| 112 | + ) |
| 113 | + else: |
| 114 | + super().__init__( |
| 115 | + fmt=fmt, datefmt=datefmt, style=style, |
| 116 | + ) |
115 | 117 |
|
116 | 118 | if stack_trace_limit is not None:
|
117 | 119 | if not isinstance(stack_trace_limit, int):
|
|
0 commit comments