Skip to content

Commit 8e625d2

Browse files
committed
Move TypedDict
1 parent eb2e20c commit 8e625d2

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

pylint/reporters/json_reporter.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,40 @@
77
from __future__ import annotations
88

99
import json
10+
import sys
1011
from typing import TYPE_CHECKING, Any, Optional
1112

1213
from pylint.interfaces import UNDEFINED
1314
from pylint.message import Message
1415
from pylint.reporters.base_reporter import BaseReporter
1516
from pylint.typing import MessageLocationTuple
1617

17-
if TYPE_CHECKING:
18+
if sys.version_info >= (3, 8):
1819
from typing import TypedDict
20+
else:
21+
from typing_extensions import TypedDict
1922

23+
if TYPE_CHECKING:
2024
from pylint.lint.pylinter import PyLinter
2125
from pylint.reporters.ureports.nodes import Section
2226

23-
OldJsonExport = TypedDict(
24-
"OldJsonExport",
25-
{
26-
"type": str,
27-
"module": str,
28-
"obj": str,
29-
"line": int,
30-
"column": int,
31-
"endLine": Optional[int],
32-
"endColumn": Optional[int],
33-
"path": str,
34-
"symbol": str,
35-
"message": str,
36-
# "message-id" is not a valid name, so we have to define the TypedDict like this
37-
"message-id": str,
38-
},
39-
)
27+
# Since message-id is an invalid name we need to use the alternative syntax
28+
OldJsonExport = TypedDict(
29+
"OldJsonExport",
30+
{
31+
"type": str,
32+
"module": str,
33+
"obj": str,
34+
"line": int,
35+
"column": int,
36+
"endLine": Optional[int],
37+
"endColumn": Optional[int],
38+
"path": str,
39+
"symbol": str,
40+
"message": str,
41+
"message-id": str,
42+
},
43+
)
4044

4145

4246
class BaseJSONReporter(BaseReporter):

0 commit comments

Comments
 (0)