Show More
@@ -14,10 +14,6 from typing import ( | |||||
14 | get_args, |
|
14 | get_args, | |
15 | get_origin, |
|
15 | get_origin, | |
16 | ) |
|
16 | ) | |
17 | from typing_extensions import ( |
|
|||
18 | Self, # Python >=3.10 |
|
|||
19 | TypeAliasType, # Python >=3.12 |
|
|||
20 | ) |
|
|||
21 | import ast |
|
17 | import ast | |
22 | import builtins |
|
18 | import builtins | |
23 | import collections |
|
19 | import collections | |
@@ -27,10 +23,20 from functools import cached_property | |||||
27 | from dataclasses import dataclass, field |
|
23 | from dataclasses import dataclass, field | |
28 | from types import MethodDescriptorType, ModuleType |
|
24 | from types import MethodDescriptorType, ModuleType | |
29 |
|
25 | |||
30 |
|
||||
31 | from IPython.utils.decorators import undoc |
|
26 | from IPython.utils.decorators import undoc | |
32 |
|
27 | |||
33 |
|
28 | |||
|
29 | if sys.version_info < (3, 11): | |||
|
30 | from typing_extensions import Self | |||
|
31 | else: | |||
|
32 | from typing import Self | |||
|
33 | ||||
|
34 | if sys.version_info < (3, 12): | |||
|
35 | from typing_extensions import TypeAliasType | |||
|
36 | else: | |||
|
37 | from typing import TypeAliasType | |||
|
38 | ||||
|
39 | ||||
34 | @undoc |
|
40 | @undoc | |
35 | class HasGetItem(Protocol): |
|
41 | class HasGetItem(Protocol): | |
36 | def __getitem__(self, key) -> None: |
|
42 | def __getitem__(self, key) -> None: |
@@ -1,3 +1,4 | |||||
|
1 | import sys | |||
1 | from contextlib import contextmanager |
|
2 | from contextlib import contextmanager | |
2 | from typing import NamedTuple, Literal, NewType |
|
3 | from typing import NamedTuple, Literal, NewType | |
3 | from functools import partial |
|
4 | from functools import partial | |
@@ -7,14 +8,21 from IPython.core.guarded_eval import ( | |||||
7 | guarded_eval, |
|
8 | guarded_eval, | |
8 | _unbind_method, |
|
9 | _unbind_method, | |
9 | ) |
|
10 | ) | |
10 | from typing_extensions import ( |
|
|||
11 | Self, # Python >=3.10 |
|
|||
12 | TypeAliasType, # Python >=3.12 |
|
|||
13 | ) |
|
|||
14 | from IPython.testing import decorators as dec |
|
11 | from IPython.testing import decorators as dec | |
15 | import pytest |
|
12 | import pytest | |
16 |
|
13 | |||
17 |
|
14 | |||
|
15 | if sys.version_info < (3, 11): | |||
|
16 | from typing_extensions import Self | |||
|
17 | else: | |||
|
18 | from typing import Self | |||
|
19 | ||||
|
20 | if sys.version_info < (3, 12): | |||
|
21 | from typing_extensions import TypeAliasType | |||
|
22 | else: | |||
|
23 | from typing import TypeAliasType | |||
|
24 | ||||
|
25 | ||||
18 | def create_context(evaluation: str, **kwargs): |
|
26 | def create_context(evaluation: str, **kwargs): | |
19 | return EvaluationContext(locals=kwargs, globals={}, evaluation=evaluation) |
|
27 | return EvaluationContext(locals=kwargs, globals={}, evaluation=evaluation) | |
20 |
|
28 |
General Comments 0
You need to be logged in to leave comments.
Login now