Skip to content

Commit 263ebaa

Browse files
authored
Fix some ruff issues with import (rule UP35 not activated yet) (#15037)
2 parents c2a0f5c + 5befe9c commit 263ebaa

File tree

19 files changed

+40
-35
lines changed

19 files changed

+40
-35
lines changed

IPython/core/completer.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,14 @@
201201
from functools import cached_property, partial
202202
from types import SimpleNamespace
203203
from typing import (
204-
Iterable,
205-
Iterator,
206204
Union,
207205
Any,
208-
Sequence,
209206
Optional,
210207
TYPE_CHECKING,
211-
Sized,
212208
TypeVar,
213209
Literal,
214210
)
211+
from collections.abc import Iterable, Iterator, Sequence, Sized
215212

216213
from IPython.core.guarded_eval import (
217214
guarded_eval,
@@ -247,7 +244,8 @@
247244
from typing import cast
248245

249246
if sys.version_info < (3, 12):
250-
from typing_extensions import TypedDict, NotRequired, Protocol, TypeAlias, TypeGuard
247+
from typing_extensions import TypedDict, Protocol
248+
from typing import NotRequired, TypeAlias, TypeGuard
251249
else:
252250
from typing import TypedDict, NotRequired, Protocol, TypeAlias, TypeGuard
253251

IPython/core/doctb.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import sys
44
from collections.abc import Sequence
55
from types import TracebackType
6-
from typing import Any, Callable, Optional
6+
from typing import Any, Optional
7+
from collections.abc import Callable
78

89
import stack_data
910
from pygments.formatters.terminal256 import Terminal256Formatter

IPython/core/guarded_eval.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
from typing import (
44
Annotated,
55
AnyStr,
6-
Callable,
76
Literal,
87
NamedTuple,
98
NewType,
109
Optional,
1110
Protocol,
12-
Sequence,
1311
TypeGuard,
1412
Union,
1513
get_args,
1614
get_origin,
1715
is_typeddict,
1816
)
17+
from collections.abc import Callable, Sequence
1918
import ast
2019
import builtins
2120
import collections
@@ -394,7 +393,7 @@ class EvaluationContext:
394393
#: Useful for evaluating ``:-1, 'col'`` in ``df[:-1, 'col']``.
395394
in_subscript: bool = False
396395
#: Auto import method
397-
auto_import: Callable[list[str], ModuleType] | None = None
396+
auto_import: Callable[[Sequence[str]], ModuleType] | None = None
398397
#: Overrides for evaluation policy
399398
policy_overrides: dict = field(default_factory=dict)
400399
#: Transient local namespace used to store mocks

IPython/core/history.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535

3636
from IPython.paths import locate_profile
3737
from IPython.utils.decorators import undoc
38-
from typing import Iterable, Tuple, Optional, TYPE_CHECKING
38+
from typing import Tuple, Optional, TYPE_CHECKING
39+
from collections.abc import Iterable
3940
import typing
4041
from warnings import warn
4142
from weakref import ref, WeakSet
@@ -1058,7 +1059,7 @@ def writeout_cache(self, conn: Optional[sqlite3.Connection] = None) -> None:
10581059
self.db_output_cache = []
10591060

10601061

1061-
from typing import Callable, Iterator
1062+
from collections.abc import Callable, Iterator
10621063
from weakref import ReferenceType
10631064

10641065

IPython/core/interactiveshell.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
from io import open as io_open
3333
from logging import error
3434
from pathlib import Path
35-
from typing import Callable
35+
from collections.abc import Callable
3636
from typing import List as ListType, Any as AnyType
37-
from typing import Literal, Optional, Sequence, Tuple
37+
from typing import Literal, Optional, Tuple
38+
from collections.abc import Sequence
3839
from warnings import warn
3940

4041
from IPython.external.pickleshare import PickleShareDB

IPython/core/tbtools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import types
66
import warnings
77
from types import TracebackType
8-
from typing import Any, Callable, Optional, Tuple
8+
from typing import Any, Optional, Tuple
9+
from collections.abc import Callable
910

1011
import stack_data
1112
from pygments.token import Token

IPython/core/ultratb.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
import warnings
7777
from collections.abc import Sequence
7878
from types import TracebackType
79-
from typing import Any, Callable, List, Optional, Tuple
79+
from typing import Any, List, Optional, Tuple
80+
from collections.abc import Callable
8081

8182
import stack_data
8283
from pygments.formatters.terminal256 import Terminal256Formatter

IPython/extensions/deduperreload/deduperreload.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import sys
1010
import textwrap
1111
from types import ModuleType
12-
from typing import TYPE_CHECKING, Any, Generator, Iterable, NamedTuple, cast
12+
from typing import TYPE_CHECKING, Any, NamedTuple, cast
13+
from collections.abc import Generator, Iterable
1314

1415
from IPython.extensions.deduperreload.deduperreload_patching import (
1516
DeduperReloaderPatchingMixin,

IPython/lib/display.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
from IPython.core.display import DisplayObject, TextDisplayObject
1010

11-
from typing import Tuple, Iterable, Optional
11+
from typing import Tuple, Optional
12+
from collections.abc import Iterable
1213

1314
__all__ = ['Audio', 'IFrame', 'YouTubeVideo', 'VimeoVideo', 'ScribdDocument',
1415
'FileLink', 'FileLinks', 'Code']

IPython/terminal/pt_inputhooks/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import importlib
22
import os
3-
from typing import Tuple, Callable
3+
from typing import Tuple
4+
from collections.abc import Callable
45

56
aliases = {
67
'qt4': 'qt',

0 commit comments

Comments
 (0)