Skip to content

Commit 4ea018a

Browse files
alexmalyshevmeta-codesync[bot]
authored andcommitted
Fix typing.Self not being available on Python 3.10
Summary: The pyrefly tests are failing as a result of this import. Reviewed By: martindemello Differential Revision: D96511508 fbshipit-source-id: 40918d30c16c4801081c050a84f9221a7ef4d590
1 parent 3800b50 commit 4ea018a

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

cinderx/PythonLib/cinderx/compiler/static/pyrefly_info.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import os
99
from ast import AST, Attribute
1010
from dataclasses import dataclass
11-
from typing import Self, TypedDict
11+
from typing import TypedDict
1212

1313
from cinderx.compiler.static.module_table import ModuleTable
1414
from cinderx.compiler.static.types import (
@@ -19,6 +19,14 @@
1919
Value,
2020
)
2121

22+
# Remove this once we drop the Python 3.10 tests.
23+
try:
24+
from typing import Self
25+
except ImportError:
26+
from typing import TypeVar
27+
28+
Self = TypeVar("T", bound="Self")
29+
2230

2331
class Location(TypedDict):
2432
start_line: int

0 commit comments

Comments
 (0)