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