mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Update min python version to 3.7 in setup.py and mypy configs (#71494)
Summary: As Python-3.6 have reached EOL Pull Request resolved: https://github.com/pytorch/pytorch/pull/71494 Reviewed By: atalman Differential Revision: D33667509 Pulled By: malfet fbshipit-source-id: ab1f03085cfb9161df77ba5ce373b81f5e7ef3ae (cherry picked from commit 60343166d97b1eb1649b29a78ad390d39926b642)
This commit is contained in:
committed by
PyTorch MergeBot
parent
06bc6748a1
commit
dc5cda0cca
@ -6,7 +6,7 @@
|
|||||||
# files.
|
# files.
|
||||||
|
|
||||||
[mypy]
|
[mypy]
|
||||||
python_version = 3.6
|
python_version = 3.7
|
||||||
plugins = mypy_plugins/check_mypy_version.py
|
plugins = mypy_plugins/check_mypy_version.py
|
||||||
|
|
||||||
cache_dir = .mypy_cache/strict
|
cache_dir = .mypy_cache/strict
|
||||||
|
4
mypy.ini
4
mypy.ini
@ -44,8 +44,8 @@ files =
|
|||||||
exclude = torch/include/|torch/csrc/|torch/distributed/elastic/agent/server/api.py|torch/testing/_internal
|
exclude = torch/include/|torch/csrc/|torch/distributed/elastic/agent/server/api.py|torch/testing/_internal
|
||||||
|
|
||||||
# Minimum version supported - variable annotations were introduced
|
# Minimum version supported - variable annotations were introduced
|
||||||
# in Python 3.6
|
# in Python 3.7
|
||||||
python_version = 3.6
|
python_version = 3.7
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
3
setup.py
3
setup.py
@ -206,7 +206,7 @@ if sys.platform == 'win32' and sys.maxsize.bit_length() == 31:
|
|||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
import platform
|
import platform
|
||||||
python_min_version = (3, 6, 2)
|
python_min_version = (3, 7, 0)
|
||||||
python_min_version_str = '.'.join(map(str, python_min_version))
|
python_min_version_str = '.'.join(map(str, python_min_version))
|
||||||
if sys.version_info < python_min_version:
|
if sys.version_info < python_min_version:
|
||||||
print("You are using Python {}. Python >={} is required.".format(platform.python_version(),
|
print("You are using Python {}. Python >={} is required.".format(platform.python_version(),
|
||||||
@ -408,7 +408,6 @@ def build_deps():
|
|||||||
# the list of runtime dependencies required by this built package
|
# the list of runtime dependencies required by this built package
|
||||||
install_requires = [
|
install_requires = [
|
||||||
'typing_extensions',
|
'typing_extensions',
|
||||||
'dataclasses; python_version < "3.7"'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
missing_pydep = '''
|
missing_pydep = '''
|
||||||
|
@ -80,7 +80,6 @@ from jit.test_sparse import TestSparse # noqa: F401
|
|||||||
# Torch
|
# Torch
|
||||||
from torch import Tensor
|
from torch import Tensor
|
||||||
from torch._C import TensorType, BoolType, parse_ir, _propagate_shapes
|
from torch._C import TensorType, BoolType, parse_ir, _propagate_shapes
|
||||||
from torch._six import PY37
|
|
||||||
from torch.autograd import Variable
|
from torch.autograd import Variable
|
||||||
from torch.jit.annotations import BroadcastingList2, BroadcastingList3, Any # noqa: F401
|
from torch.jit.annotations import BroadcastingList2, BroadcastingList3, Any # noqa: F401
|
||||||
from torch.nn.utils.rnn import PackedSequence
|
from torch.nn.utils.rnn import PackedSequence
|
||||||
@ -6473,8 +6472,7 @@ a")
|
|||||||
checkMathWrap("ceil", ret_type="int")
|
checkMathWrap("ceil", ret_type="int")
|
||||||
checkMathWrap("gcd", 2, is_float=False, ret_type="int")
|
checkMathWrap("gcd", 2, is_float=False, ret_type="int")
|
||||||
checkMath("isfinite", 1, ret_type="bool")
|
checkMath("isfinite", 1, ret_type="bool")
|
||||||
if PY37:
|
checkMathWrap("remainder", 2)
|
||||||
checkMathWrap("remainder", 2)
|
|
||||||
checkMathWrap("factorial", 1, is_float=False, ret_type="int", vals=[(i, 0) for i in range(-2, 10)])
|
checkMathWrap("factorial", 1, is_float=False, ret_type="int", vals=[(i, 0) for i in range(-2, 10)])
|
||||||
|
|
||||||
def test_if_nest_while(self):
|
def test_if_nest_while(self):
|
||||||
|
@ -533,7 +533,7 @@ def fast_nvcc(
|
|||||||
print_command_outputs(results)
|
print_command_outputs(results)
|
||||||
if config.table:
|
if config.table:
|
||||||
write_log_csv(command_parts, results, filename=config.table)
|
write_log_csv(command_parts, results, filename=config.table)
|
||||||
return exit_code([dryrun_data] + results)
|
return exit_code([dryrun_data] + results) # type: ignore[arg-type, operator]
|
||||||
|
|
||||||
|
|
||||||
def our_arg(arg: str) -> bool:
|
def our_arg(arg: str) -> bool:
|
||||||
|
@ -19,12 +19,10 @@
|
|||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
import math
|
import math
|
||||||
import sys
|
|
||||||
|
|
||||||
inf = math.inf
|
inf = math.inf
|
||||||
nan = math.nan
|
nan = math.nan
|
||||||
string_classes = (str, bytes)
|
string_classes = (str, bytes)
|
||||||
PY37 = sys.version_info[0] == 3 and sys.version_info[1] >= 7
|
|
||||||
|
|
||||||
def with_metaclass(meta: type, *bases) -> type:
|
def with_metaclass(meta: type, *bases) -> type:
|
||||||
"""Create a base class with a metaclass."""
|
"""Create a base class with a metaclass."""
|
||||||
|
@ -1,20 +1,12 @@
|
|||||||
from typing import cast, Callable, Generic, List, Optional, Type, TypeVar, Union
|
from typing import cast, Callable, Generic, List, Optional, Type, TypeVar, Union
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch._six import PY37
|
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
S = TypeVar("S")
|
S = TypeVar("S")
|
||||||
|
|
||||||
if not PY37:
|
class _PyFutureMeta(type(torch._C.Future), type(Generic)): # type: ignore[misc, no-redef]
|
||||||
# Workaround for https://github.com/python/typing/issues/449 in Python 3.6
|
pass
|
||||||
from typing import GenericMeta
|
|
||||||
|
|
||||||
class _PyFutureMeta(type(torch._C.Future), GenericMeta): # type: ignore[misc]
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
class _PyFutureMeta(type(torch._C.Future), type(Generic)): # type: ignore[misc, no-redef]
|
|
||||||
pass
|
|
||||||
|
|
||||||
class Future(torch._C.Future, Generic[T], metaclass=_PyFutureMeta):
|
class Future(torch._C.Future, Generic[T], metaclass=_PyFutureMeta):
|
||||||
r"""
|
r"""
|
||||||
|
@ -5,7 +5,6 @@ import warnings
|
|||||||
import torch
|
import torch
|
||||||
import torch.backends.cudnn as cudnn
|
import torch.backends.cudnn as cudnn
|
||||||
|
|
||||||
from torch._six import PY37
|
|
||||||
from ..nn.modules.utils import _single, _pair, _triple, _quadruple, _list_with_default
|
from ..nn.modules.utils import _single, _pair, _triple, _quadruple, _list_with_default
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
@ -142,8 +141,7 @@ def _get_builtin_table():
|
|||||||
|
|
||||||
_builtin_ops.append((math.gcd, "aten::gcd"))
|
_builtin_ops.append((math.gcd, "aten::gcd"))
|
||||||
_builtin_ops.append((math.isfinite, "aten::isfinite"))
|
_builtin_ops.append((math.isfinite, "aten::isfinite"))
|
||||||
if PY37:
|
_builtin_ops.append((math.remainder, "aten::mathremainder")) # type: ignore[attr-defined]
|
||||||
_builtin_ops.append((math.remainder, "aten::mathremainder")) # type: ignore[attr-defined]
|
|
||||||
|
|
||||||
import torch.distributed.autograd as dist_autograd
|
import torch.distributed.autograd as dist_autograd
|
||||||
if dist_autograd.is_available():
|
if dist_autograd.is_available():
|
||||||
|
@ -9,25 +9,17 @@ import sys
|
|||||||
from typing import (Any, Dict, Iterator, Generic, List, Set, Tuple, TypeVar, Union,
|
from typing import (Any, Dict, Iterator, Generic, List, Set, Tuple, TypeVar, Union,
|
||||||
get_type_hints)
|
get_type_hints)
|
||||||
from typing import _eval_type, _tp_cache, _type_check, _type_repr # type: ignore[attr-defined]
|
from typing import _eval_type, _tp_cache, _type_check, _type_repr # type: ignore[attr-defined]
|
||||||
|
from typing import ForwardRef
|
||||||
try: # Python > 3.6
|
|
||||||
from typing import ForwardRef # type: ignore[attr-defined]
|
|
||||||
except ImportError: # Python 3.6
|
|
||||||
from typing import _ForwardRef as ForwardRef # type: ignore[attr-defined]
|
|
||||||
|
|
||||||
# TODO: Use TypeAlias when Python 3.6 is deprecated
|
# TODO: Use TypeAlias when Python 3.6 is deprecated
|
||||||
# Please check [Note: TypeMeta and TypeAlias]
|
# Please check [Note: TypeMeta and TypeAlias]
|
||||||
try:
|
# In case of metaclass conflict due to ABCMeta or _ProtocolMeta
|
||||||
from typing import GenericMeta # Python 3.6
|
# For Python 3.9, only Protocol in typing uses metaclass
|
||||||
_GenericAlias = GenericMeta
|
from abc import ABCMeta
|
||||||
except ImportError: # Python > 3.6
|
from typing import _ProtocolMeta, _GenericAlias # type: ignore[attr-defined, no-redef]
|
||||||
# In case of metaclass conflict due to ABCMeta or _ProtocolMeta
|
|
||||||
# For Python 3.9, only Protocol in typing uses metaclass
|
|
||||||
from abc import ABCMeta
|
|
||||||
from typing import _ProtocolMeta, _GenericAlias # type: ignore[attr-defined, no-redef]
|
|
||||||
|
|
||||||
class GenericMeta(_ProtocolMeta, ABCMeta): # type: ignore[no-redef]
|
class GenericMeta(_ProtocolMeta, ABCMeta): # type: ignore[no-redef]
|
||||||
pass
|
pass
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user