Show More
@@ -1362,9 +1362,9 def match_dict_keys( | |||||
1362 | # All checks passed! |
|
1362 | # All checks passed! | |
1363 | return True |
|
1363 | return True | |
1364 |
|
1364 | |||
1365 | filtered_key_is_final: Dict[ |
|
1365 | filtered_key_is_final: Dict[Union[str, bytes, int, float], _DictKeyState] = ( | |
1366 | Union[str, bytes, int, float], _DictKeyState |
|
1366 | defaultdict(lambda: _DictKeyState.BASELINE) | |
1367 | ] = defaultdict(lambda: _DictKeyState.BASELINE) |
|
1367 | ) | |
1368 |
|
1368 | |||
1369 | for k in keys: |
|
1369 | for k in keys: | |
1370 | # If at least one of the matches is not final, mark as undetermined. |
|
1370 | # If at least one of the matches is not final, mark as undetermined. |
@@ -44,20 +44,17 else: | |||||
44 |
|
44 | |||
45 | @undoc |
|
45 | @undoc | |
46 | class HasGetItem(Protocol): |
|
46 | class HasGetItem(Protocol): | |
47 | def __getitem__(self, key) -> None: |
|
47 | def __getitem__(self, key) -> None: ... | |
48 | ... |
|
|||
49 |
|
48 | |||
50 |
|
49 | |||
51 | @undoc |
|
50 | @undoc | |
52 | class InstancesHaveGetItem(Protocol): |
|
51 | class InstancesHaveGetItem(Protocol): | |
53 | def __call__(self, *args, **kwargs) -> HasGetItem: |
|
52 | def __call__(self, *args, **kwargs) -> HasGetItem: ... | |
54 | ... |
|
|||
55 |
|
53 | |||
56 |
|
54 | |||
57 | @undoc |
|
55 | @undoc | |
58 | class HasGetAttr(Protocol): |
|
56 | class HasGetAttr(Protocol): | |
59 | def __getattr__(self, key) -> None: |
|
57 | def __getattr__(self, key) -> None: ... | |
60 | ... |
|
|||
61 |
|
58 | |||
62 |
|
59 | |||
63 | @undoc |
|
60 | @undoc | |
@@ -329,9 +326,9 class EvaluationContext(NamedTuple): | |||||
329 | #: Global namespace |
|
326 | #: Global namespace | |
330 | globals: dict |
|
327 | globals: dict | |
331 | #: Evaluation policy identifier |
|
328 | #: Evaluation policy identifier | |
332 | evaluation: Literal[ |
|
329 | evaluation: Literal["forbidden", "minimal", "limited", "unsafe", "dangerous"] = ( | |
333 | "forbidden", "minimal", "limited", "unsafe", "dangerous" |
|
330 | "forbidden" | |
334 | ] = "forbidden" |
|
331 | ) | |
335 | #: Whether the evaluation of code takes place inside of a subscript. |
|
332 | #: Whether the evaluation of code takes place inside of a subscript. | |
336 | #: Useful for evaluating ``:-1, 'col'`` in ``df[:-1, 'col']``. |
|
333 | #: Useful for evaluating ``:-1, 'col'`` in ``df[:-1, 'col']``. | |
337 | in_subscript: bool = False |
|
334 | in_subscript: bool = False |
@@ -15,6 +15,7 and stores the results. | |||||
15 |
|
15 | |||
16 | For more details, see the class docstrings below. |
|
16 | For more details, see the class docstrings below. | |
17 | """ |
|
17 | """ | |
|
18 | ||||
18 | from __future__ import annotations |
|
19 | from __future__ import annotations | |
19 |
|
20 | |||
20 | from warnings import warn |
|
21 | from warnings import warn |
@@ -535,8 +535,7 def test_custom_repr_namedtuple_partialmethod(): | |||||
535 | from functools import partialmethod |
|
535 | from functools import partialmethod | |
536 | from typing import NamedTuple |
|
536 | from typing import NamedTuple | |
537 |
|
537 | |||
538 | class Foo(NamedTuple): |
|
538 | class Foo(NamedTuple): ... | |
539 | ... |
|
|||
540 |
|
539 | |||
541 | Foo.__repr__ = partialmethod(lambda obj: "Hello World") |
|
540 | Foo.__repr__ = partialmethod(lambda obj: "Hello World") | |
542 | foo = Foo() |
|
541 | foo = Foo() |
@@ -4,6 +4,7 Line-based transformers are the simpler ones; token-based transformers are | |||||
4 | more complex. See test_inputtransformer2_line for tests for line-based |
|
4 | more complex. See test_inputtransformer2_line for tests for line-based | |
5 | transformations. |
|
5 | transformations. | |
6 | """ |
|
6 | """ | |
|
7 | ||||
7 | import platform |
|
8 | import platform | |
8 | import string |
|
9 | import string | |
9 | import sys |
|
10 | import sys |
@@ -160,14 +160,16 def test_get_ipython_dir_8(): | |||||
160 | # test only when HOME directory actually writable |
|
160 | # test only when HOME directory actually writable | |
161 | return |
|
161 | return | |
162 |
|
162 | |||
163 | with patch.object(paths, "_writable_dir", lambda path: bool(path)), patch.object( |
|
163 | with ( | |
164 | paths, "get_xdg_dir", return_value=None |
|
164 | patch.object(paths, "_writable_dir", lambda path: bool(path)), | |
165 | ), modified_env( |
|
165 | patch.object(paths, "get_xdg_dir", return_value=None), | |
|
166 | modified_env( | |||
166 | { |
|
167 | { | |
167 | "IPYTHON_DIR": None, |
|
168 | "IPYTHON_DIR": None, | |
168 | "IPYTHONDIR": None, |
|
169 | "IPYTHONDIR": None, | |
169 | "HOME": "/", |
|
170 | "HOME": "/", | |
170 | } |
|
171 | } | |
|
172 | ), | |||
171 | ): |
|
173 | ): | |
172 | assert paths.get_ipython_dir() == "/.ipython" |
|
174 | assert paths.get_ipython_dir() == "/.ipython" | |
173 |
|
175 |
@@ -8,6 +8,7 bindings, which is unstable and likely to crash | |||||
8 | This is used primarily by qt and qt_for_kernel, and shouldn't |
|
8 | This is used primarily by qt and qt_for_kernel, and shouldn't | |
9 | be accessed directly from the outside |
|
9 | be accessed directly from the outside | |
10 | """ |
|
10 | """ | |
|
11 | ||||
11 | import importlib.abc |
|
12 | import importlib.abc | |
12 | import sys |
|
13 | import sys | |
13 | import os |
|
14 | import os |
@@ -1,5 +1,6 | |||||
1 | """ Utilities for accessing the platform's clipboard. |
|
1 | """ Utilities for accessing the platform's clipboard. | |
2 | """ |
|
2 | """ | |
|
3 | ||||
3 | import os |
|
4 | import os | |
4 | import subprocess |
|
5 | import subprocess | |
5 |
|
6 |
@@ -906,12 +906,13 class IPythonDirective(Directive): | |||||
906 | required_arguments: int = 0 |
|
906 | required_arguments: int = 0 | |
907 | optional_arguments: int = 4 # python, suppress, verbatim, doctest |
|
907 | optional_arguments: int = 4 # python, suppress, verbatim, doctest | |
908 | final_argumuent_whitespace: bool = True |
|
908 | final_argumuent_whitespace: bool = True | |
909 |
option_spec: Dict[str, Any] = { |
|
909 | option_spec: Dict[str, Any] = { | |
910 | 'suppress' : directives.flag, |
|
910 | "python": directives.unchanged, | |
911 |
|
|
911 | "suppress": directives.flag, | |
912 |
|
|
912 | "verbatim": directives.flag, | |
913 |
|
|
913 | "doctest": directives.flag, | |
914 |
|
|
914 | "okexcept": directives.flag, | |
|
915 | "okwarning": directives.flag, | |||
915 | } |
|
916 | } | |
916 |
|
917 | |||
917 | shell = None |
|
918 | shell = None |
@@ -586,12 +586,14 class TerminalInteractiveShell(InteractiveShell): | |||||
586 | RuntimeBinding( |
|
586 | RuntimeBinding( | |
587 | command, |
|
587 | command, | |
588 | keys=new_keys or old_keys, |
|
588 | keys=new_keys or old_keys, | |
589 |
filter= |
|
589 | filter=( | |
|
590 | filter_from_string(new_filter) | |||
590 | if new_filter is not None |
|
591 | if new_filter is not None | |
591 | else ( |
|
592 | else ( | |
592 | old_filter |
|
593 | old_filter | |
593 | if old_filter is not None |
|
594 | if old_filter is not None | |
594 | else filter_from_string("always") |
|
595 | else filter_from_string("always") | |
|
596 | ) | |||
595 | ), |
|
597 | ), | |
596 | ) |
|
598 | ) | |
597 | ) |
|
599 | ) |
@@ -4,6 +4,7 Utilities function for keybinding with prompt toolkit. | |||||
4 | This will be bound to specific key press and filter modes, |
|
4 | This will be bound to specific key press and filter modes, | |
5 | like whether we are in edit mode, and whether the completer is open. |
|
5 | like whether we are in edit mode, and whether the completer is open. | |
6 | """ |
|
6 | """ | |
|
7 | ||||
7 | import re |
|
8 | import re | |
8 | from prompt_toolkit.key_binding import KeyPressEvent |
|
9 | from prompt_toolkit.key_binding import KeyPressEvent | |
9 |
|
10 |
General Comments 0
You need to be logged in to leave comments.
Login now