Skip to content

Commit dc5cda0

Browse files
malfetpytorchmergebot
authored andcommitted
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: #71494 Reviewed By: atalman Differential Revision: D33667509 Pulled By: malfet fbshipit-source-id: ab1f03085cfb9161df77ba5ce373b81f5e7ef3ae (cherry picked from commit 6034316)
1 parent 06bc674 commit dc5cda0

File tree

9 files changed

+17
-40
lines changed

9 files changed

+17
-40
lines changed

mypy-strict.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# files.
77

88
[mypy]
9-
python_version = 3.6
9+
python_version = 3.7
1010
plugins = mypy_plugins/check_mypy_version.py
1111

1212
cache_dir = .mypy_cache/strict

mypy.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ files =
4444
exclude = torch/include/|torch/csrc/|torch/distributed/elastic/agent/server/api.py|torch/testing/_internal
4545

4646
# Minimum version supported - variable annotations were introduced
47-
# in Python 3.6
48-
python_version = 3.6
47+
# in Python 3.7
48+
python_version = 3.7
4949

5050

5151
#

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
sys.exit(-1)
207207

208208
import platform
209-
python_min_version = (3, 6, 2)
209+
python_min_version = (3, 7, 0)
210210
python_min_version_str = '.'.join(map(str, python_min_version))
211211
if sys.version_info < python_min_version:
212212
print("You are using Python {}. Python >={} is required.".format(platform.python_version(),
@@ -408,7 +408,6 @@ def build_deps():
408408
# the list of runtime dependencies required by this built package
409409
install_requires = [
410410
'typing_extensions',
411-
'dataclasses; python_version < "3.7"'
412411
]
413412

414413
missing_pydep = '''

test/test_jit.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
# Torch
8181
from torch import Tensor
8282
from torch._C import TensorType, BoolType, parse_ir, _propagate_shapes
83-
from torch._six import PY37
8483
from torch.autograd import Variable
8584
from torch.jit.annotations import BroadcastingList2, BroadcastingList3, Any # noqa: F401
8685
from torch.nn.utils.rnn import PackedSequence
@@ -6473,8 +6472,7 @@ def func(a, b):
64736472
checkMathWrap("ceil", ret_type="int")
64746473
checkMathWrap("gcd", 2, is_float=False, ret_type="int")
64756474
checkMath("isfinite", 1, ret_type="bool")
6476-
if PY37:
6477-
checkMathWrap("remainder", 2)
6475+
checkMathWrap("remainder", 2)
64786476
checkMathWrap("factorial", 1, is_float=False, ret_type="int", vals=[(i, 0) for i in range(-2, 10)])
64796477

64806478
def test_if_nest_while(self):

tools/fast_nvcc/fast_nvcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def fast_nvcc(
533533
print_command_outputs(results)
534534
if config.table:
535535
write_log_csv(command_parts, results, filename=config.table)
536-
return exit_code([dryrun_data] + results)
536+
return exit_code([dryrun_data] + results) # type: ignore[arg-type, operator]
537537

538538

539539
def our_arg(arg: str) -> bool:

torch/_six.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
# SOFTWARE.
2020

2121
import math
22-
import sys
2322

2423
inf = math.inf
2524
nan = math.nan
2625
string_classes = (str, bytes)
27-
PY37 = sys.version_info[0] == 3 and sys.version_info[1] >= 7
2826

2927
def with_metaclass(meta: type, *bases) -> type:
3028
"""Create a base class with a metaclass."""

torch/futures/__init__.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
from typing import cast, Callable, Generic, List, Optional, Type, TypeVar, Union
22

33
import torch
4-
from torch._six import PY37
54

65
T = TypeVar("T")
76
S = TypeVar("S")
87

9-
if not PY37:
10-
# Workaround for https://github.com/python/typing/issues/449 in Python 3.6
11-
from typing import GenericMeta
12-
13-
class _PyFutureMeta(type(torch._C.Future), GenericMeta): # type: ignore[misc]
14-
pass
15-
else:
16-
class _PyFutureMeta(type(torch._C.Future), type(Generic)): # type: ignore[misc, no-redef]
17-
pass
8+
class _PyFutureMeta(type(torch._C.Future), type(Generic)): # type: ignore[misc, no-redef]
9+
pass
1810

1911
class Future(torch._C.Future, Generic[T], metaclass=_PyFutureMeta):
2012
r"""

torch/jit/_builtins.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import torch
66
import torch.backends.cudnn as cudnn
77

8-
from torch._six import PY37
98
from ..nn.modules.utils import _single, _pair, _triple, _quadruple, _list_with_default
109

1110
from collections import OrderedDict
@@ -142,8 +141,7 @@ def register_all(mod):
142141

143142
_builtin_ops.append((math.gcd, "aten::gcd"))
144143
_builtin_ops.append((math.isfinite, "aten::isfinite"))
145-
if PY37:
146-
_builtin_ops.append((math.remainder, "aten::mathremainder")) # type: ignore[attr-defined]
144+
_builtin_ops.append((math.remainder, "aten::mathremainder")) # type: ignore[attr-defined]
147145

148146
import torch.distributed.autograd as dist_autograd
149147
if dist_autograd.is_available():

torch/utils/data/_typing.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,17 @@
99
from typing import (Any, Dict, Iterator, Generic, List, Set, Tuple, TypeVar, Union,
1010
get_type_hints)
1111
from typing import _eval_type, _tp_cache, _type_check, _type_repr # type: ignore[attr-defined]
12-
13-
try: # Python > 3.6
14-
from typing import ForwardRef # type: ignore[attr-defined]
15-
except ImportError: # Python 3.6
16-
from typing import _ForwardRef as ForwardRef # type: ignore[attr-defined]
12+
from typing import ForwardRef
1713

1814
# TODO: Use TypeAlias when Python 3.6 is deprecated
1915
# Please check [Note: TypeMeta and TypeAlias]
20-
try:
21-
from typing import GenericMeta # Python 3.6
22-
_GenericAlias = GenericMeta
23-
except ImportError: # Python > 3.6
24-
# In case of metaclass conflict due to ABCMeta or _ProtocolMeta
25-
# For Python 3.9, only Protocol in typing uses metaclass
26-
from abc import ABCMeta
27-
from typing import _ProtocolMeta, _GenericAlias # type: ignore[attr-defined, no-redef]
28-
29-
class GenericMeta(_ProtocolMeta, ABCMeta): # type: ignore[no-redef]
30-
pass
16+
# In case of metaclass conflict due to ABCMeta or _ProtocolMeta
17+
# For Python 3.9, only Protocol in typing uses metaclass
18+
from abc import ABCMeta
19+
from typing import _ProtocolMeta, _GenericAlias # type: ignore[attr-defined, no-redef]
20+
21+
class GenericMeta(_ProtocolMeta, ABCMeta): # type: ignore[no-redef]
22+
pass
3123

3224
import torch
3325

0 commit comments

Comments
 (0)