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.
|
||||
|
||||
[mypy]
|
||||
python_version = 3.6
|
||||
python_version = 3.7
|
||||
plugins = mypy_plugins/check_mypy_version.py
|
||||
|
||||
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
|
||||
|
||||
# Minimum version supported - variable annotations were introduced
|
||||
# in Python 3.6
|
||||
python_version = 3.6
|
||||
# in Python 3.7
|
||||
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)
|
||||
|
||||
import platform
|
||||
python_min_version = (3, 6, 2)
|
||||
python_min_version = (3, 7, 0)
|
||||
python_min_version_str = '.'.join(map(str, python_min_version))
|
||||
if sys.version_info < python_min_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
|
||||
install_requires = [
|
||||
'typing_extensions',
|
||||
'dataclasses; python_version < "3.7"'
|
||||
]
|
||||
|
||||
missing_pydep = '''
|
||||
|
@ -80,7 +80,6 @@ from jit.test_sparse import TestSparse # noqa: F401
|
||||
# Torch
|
||||
from torch import Tensor
|
||||
from torch._C import TensorType, BoolType, parse_ir, _propagate_shapes
|
||||
from torch._six import PY37
|
||||
from torch.autograd import Variable
|
||||
from torch.jit.annotations import BroadcastingList2, BroadcastingList3, Any # noqa: F401
|
||||
from torch.nn.utils.rnn import PackedSequence
|
||||
@ -6473,7 +6472,6 @@ a")
|
||||
checkMathWrap("ceil", ret_type="int")
|
||||
checkMathWrap("gcd", 2, is_float=False, ret_type="int")
|
||||
checkMath("isfinite", 1, ret_type="bool")
|
||||
if PY37:
|
||||
checkMathWrap("remainder", 2)
|
||||
checkMathWrap("factorial", 1, is_float=False, ret_type="int", vals=[(i, 0) for i in range(-2, 10)])
|
||||
|
||||
|
@ -533,7 +533,7 @@ def fast_nvcc(
|
||||
print_command_outputs(results)
|
||||
if 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:
|
||||
|
@ -19,12 +19,10 @@
|
||||
# SOFTWARE.
|
||||
|
||||
import math
|
||||
import sys
|
||||
|
||||
inf = math.inf
|
||||
nan = math.nan
|
||||
string_classes = (str, bytes)
|
||||
PY37 = sys.version_info[0] == 3 and sys.version_info[1] >= 7
|
||||
|
||||
def with_metaclass(meta: type, *bases) -> type:
|
||||
"""Create a base class with a metaclass."""
|
||||
|
@ -1,19 +1,11 @@
|
||||
from typing import cast, Callable, Generic, List, Optional, Type, TypeVar, Union
|
||||
|
||||
import torch
|
||||
from torch._six import PY37
|
||||
|
||||
T = TypeVar("T")
|
||||
S = TypeVar("S")
|
||||
|
||||
if not PY37:
|
||||
# Workaround for https://github.com/python/typing/issues/449 in Python 3.6
|
||||
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]
|
||||
class _PyFutureMeta(type(torch._C.Future), type(Generic)): # type: ignore[misc, no-redef]
|
||||
pass
|
||||
|
||||
class Future(torch._C.Future, Generic[T], metaclass=_PyFutureMeta):
|
||||
|
@ -5,7 +5,6 @@ import warnings
|
||||
import torch
|
||||
import torch.backends.cudnn as cudnn
|
||||
|
||||
from torch._six import PY37
|
||||
from ..nn.modules.utils import _single, _pair, _triple, _quadruple, _list_with_default
|
||||
|
||||
from collections import OrderedDict
|
||||
@ -142,7 +141,6 @@ def _get_builtin_table():
|
||||
|
||||
_builtin_ops.append((math.gcd, "aten::gcd"))
|
||||
_builtin_ops.append((math.isfinite, "aten::isfinite"))
|
||||
if PY37:
|
||||
_builtin_ops.append((math.remainder, "aten::mathremainder")) # type: ignore[attr-defined]
|
||||
|
||||
import torch.distributed.autograd as dist_autograd
|
||||
|
@ -9,24 +9,16 @@ import sys
|
||||
from typing import (Any, Dict, Iterator, Generic, List, Set, Tuple, TypeVar, Union,
|
||||
get_type_hints)
|
||||
from typing import _eval_type, _tp_cache, _type_check, _type_repr # type: ignore[attr-defined]
|
||||
|
||||
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]
|
||||
from typing import ForwardRef
|
||||
|
||||
# TODO: Use TypeAlias when Python 3.6 is deprecated
|
||||
# Please check [Note: TypeMeta and TypeAlias]
|
||||
try:
|
||||
from typing import GenericMeta # Python 3.6
|
||||
_GenericAlias = GenericMeta
|
||||
except ImportError: # Python > 3.6
|
||||
# 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]
|
||||
# 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
|
||||
|
||||
import torch
|
||||
|
Reference in New Issue
Block a user