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:
Nikita Shulga
2022-01-19 15:59:11 -08:00
committed by PyTorch MergeBot
parent 06bc6748a1
commit dc5cda0cca
9 changed files with 16 additions and 39 deletions

View File

@ -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

View File

@ -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
#

View File

@ -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 = '''

View File

@ -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)])

View File

@ -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:

View File

@ -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."""

View File

@ -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):

View File

@ -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

View File

@ -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