Upgrade mypy python_version to 3.11 (#118418)

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/118418
Approved by: https://github.com/albanD
ghstack dependencies: #118414
This commit is contained in:
Edward Z. Yang
2024-01-26 18:55:54 -08:00
committed by PyTorch MergeBot
parent 978faf1fa2
commit 89a1175e0e
6 changed files with 6 additions and 8 deletions

View File

@@ -44,9 +44,7 @@ files =
#
exclude = torch/include/|torch/csrc/|torch/distributed/elastic/agent/server/api.py|torch/testing/_internal|torch/distributed/fsdp/fully_sharded_data_parallel.py
# Minimum version supported - variable annotations were introduced
# in Python 3.8
python_version = 3.8
python_version = 3.11
#

View File

@@ -1,6 +1,6 @@
# flake8: noqa
import torch
torch.tensor([3], dtype='int32') # E: expected "Optional[dtype]"
torch.tensor([3], dtype='int32') # E: Argument "dtype" to "tensor" has incompatible type "str"; expected "dtype | None" [arg-type]
torch.ones(3, dtype='int32') # E: No overload variant of "ones" matches argument types "int", "str"
torch.zeros(3, dtype='int32') # E: No overload variant of "zeros" matches argument types "int", "str"

View File

@@ -1,4 +1,4 @@
# flake8: noqa
import torch
torch.set_rng_state([1, 2, 3]) # E: Argument 1 to "set_rng_state" has incompatible type "List[int]"; expected "Tensor"
torch.set_rng_state([1, 2, 3]) # E: Argument 1 to "set_rng_state" has incompatible type "list[int]"; expected "Tensor" [arg-type]

View File

@@ -7,7 +7,7 @@ t_sort = t.sort()
t_sort[0][0, 0] == 1.5 # noqa: B015
t_sort.indices[0, 0] == 1 # noqa: B015
t_sort.values[0, 0] == 1.5 # noqa: B015
reveal_type(t_sort) # E: Tuple[{Tensor}, {Tensor}, fallback=torch.return_types.sort]
reveal_type(t_sort) # E: tuple[torch._tensor.Tensor, torch._tensor.Tensor, fallback=torch.return_types.sort]
t_qr = torch.linalg.qr(t)
t_qr[0].shape == [2, 2] # noqa: B015

View File

@@ -65,7 +65,7 @@ try:
LockType = _thread.LockType
except ImportError:
import _dummy_thread
import _dummy_thread # type: ignore[import-not-found]
LockType = _dummy_thread.LockType

View File

@@ -77,7 +77,7 @@ def ismethod(func):
return signature.parameters.get('self', None) is not None
else:
if sys.version_info.major < 3:
spec = inspect.getargspec(func)
spec = inspect.getargspec(func) # type: ignore[attr-defined]
else:
spec = inspect.getfullargspec(func) # type: ignore[union-attr, assignment]
return spec and spec.args and spec.args[0] == 'self'