Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc8c2e6

Browse files
authored
Merge pull request#28995 from jorenham/typing/__future__.annotations
TYP: remove ``from __future__ import annotations``
2 parentsc807e09 +8360da6 commitdc8c2e6

File tree

10 files changed

+8
-42
lines changed

10 files changed

+8
-42
lines changed

‎numpy/_core/tests/test_arraymethod.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
this is private API, but when added, public API may be added here.
44
"""
55

6-
from __future__importannotations
7-
86
importtypes
97
fromtypingimportAny
108

‎numpy/_core/tests/test_multiarray.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__importannotations
2-
31
importbuiltins
42
importcollections.abc
53
importctypes

‎numpy/_typing/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Private counterpart of ``numpy.typing``."""
22

3-
from __future__importannotations
4-
53
from ._array_likeimportArrayLikeasArrayLike
64
from ._array_likeimportNDArrayasNDArray
75
from ._array_likeimport_ArrayLikeas_ArrayLike

‎numpy/_typing/_array_like.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__importannotations
2-
31
importsys
42
fromcollections.abcimportCallable,Collection,Sequence
53
fromtypingimportTYPE_CHECKING,Any,Protocol,TypeAlias,TypeVar,runtime_checkable
@@ -20,7 +18,6 @@
2018

2119
_T=TypeVar("_T")
2220
_ScalarT=TypeVar("_ScalarT",bound=np.generic)
23-
_ScalarT_co=TypeVar("_ScalarT_co",bound=np.generic,covariant=True)
2421
_DTypeT=TypeVar("_DTypeT",bound=dtype[Any])
2522
_DTypeT_co=TypeVar("_DTypeT_co",covariant=True,bound=dtype[Any])
2623

‎numpy/_typing/_nbit_base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class NBitBase:
3030
3131
.. code-block:: python
3232
33-
>>> from __future__ import annotations
3433
>>> from typing import TypeVar, TYPE_CHECKING
3534
>>> import numpy as np
3635
>>> import numpy.typing as npt

‎numpy/_typing/_nested_sequence.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
"""A module containing the `_NestedSequence` protocol."""
22

3-
from __future__importannotations
4-
5-
fromtypingimport (
6-
TYPE_CHECKING,
7-
Any,
8-
Protocol,
9-
TypeVar,
10-
runtime_checkable,
11-
)
3+
fromtypingimportTYPE_CHECKING,Any,Protocol,TypeVar,runtime_checkable
124

135
ifTYPE_CHECKING:
146
fromcollections.abcimportIterator
@@ -36,8 +28,6 @@ class _NestedSequence(Protocol[_T_co]):
3628
--------
3729
.. code-block:: python
3830
39-
>>> from __future__ import annotations
40-
4131
>>> from typing import TYPE_CHECKING
4232
>>> import numpy as np
4333
>>> from numpy._typing import _NestedSequence
@@ -64,19 +54,19 @@ def __len__(self, /) -> int:
6454
"""Implement ``len(self)``."""
6555
raiseNotImplementedError
6656

67-
def__getitem__(self,index:int,/)->_T_co|_NestedSequence[_T_co]:
57+
def__getitem__(self,index:int,/)->"_T_co | _NestedSequence[_T_co]":
6858
"""Implement ``self[x]``."""
6959
raiseNotImplementedError
7060

7161
def__contains__(self,x:object,/)->bool:
7262
"""Implement ``x in self``."""
7363
raiseNotImplementedError
7464

75-
def__iter__(self,/)->Iterator[_T_co|_NestedSequence[_T_co]]:
65+
def__iter__(self,/)->"Iterator[_T_co | _NestedSequence[_T_co]]":
7666
"""Implement ``iter(self)``."""
7767
raiseNotImplementedError
7868

79-
def__reversed__(self,/)->Iterator[_T_co|_NestedSequence[_T_co]]:
69+
def__reversed__(self,/)->"Iterator[_T_co | _NestedSequence[_T_co]]":
8070
"""Implement ``reversed(self)``."""
8171
raiseNotImplementedError
8272

‎numpy/f2py/_backends/_backend.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__importannotations
2-
31
fromabcimportABC,abstractmethod
42

53

‎numpy/f2py/_backends/_meson.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__importannotations
2-
31
importerrno
42
importos
53
importre

‎numpy/typing/tests/test_runtime.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""Test the runtime usage of `numpy.typing`."""
22

3-
from __future__importannotations
4-
53
fromtypingimport (
64
Any,
75
NamedTuple,
8-
Union,
6+
Union,# pyright: ignore[reportDeprecated]
97
get_args,
108
get_origin,
119
get_type_hints,
@@ -55,10 +53,7 @@ def test_get_type_hints(name: type, tup: TypeTup) -> None:
5553
"""Test `typing.get_type_hints`."""
5654
typ=tup.typ
5755

58-
# Explicitly set `__annotations__` in order to circumvent the
59-
# stringification performed by `from __future__ import annotations`
60-
deffunc(a):pass
61-
func.__annotations__= {"a":typ,"return":None}
56+
deffunc(a:typ)->None:pass
6257

6358
out=get_type_hints(func)
6459
ref= {"a":typ,"return":type(None)}
@@ -70,10 +65,7 @@ def test_get_type_hints_str(name: type, tup: TypeTup) -> None:
7065
"""Test `typing.get_type_hints` with string-representation of types."""
7166
typ_str,typ=f"npt.{name}",tup.typ
7267

73-
# Explicitly set `__annotations__` in order to circumvent the
74-
# stringification performed by `from __future__ import annotations`
75-
deffunc(a):pass
76-
func.__annotations__= {"a":typ_str,"return":None}
68+
deffunc(a:typ_str)->None:pass
7769

7870
out=get_type_hints(func)
7971
ref= {"a":typ,"return":type(None)}

‎numpy/typing/tests/test_typing.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__importannotations
2-
31
importimportlib.util
42
importos
53
importre
@@ -118,7 +116,7 @@ def run_mypy() -> None:
118116
filename=None
119117

120118

121-
defget_test_cases(*directories:str)->Iterator[ParameterSet]:
119+
defget_test_cases(*directories:str)->"Iterator[ParameterSet]":
122120
fordirectoryindirectories:
123121
forroot,_,filesinos.walk(directory):
124122
forfnameinfiles:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp