Set min supported Python version to 3.8 (#93155)

Also, grep for `if sys.version_info .cond. (3, 8)` and replaces them with appropriate action.

This is a last in a series of PRs that moved CI/CD away from testing PyTorch behavior against Python-3.7.

Fixes https://github.com/pytorch/pytorch/issues/80513

Pull Request resolved: https://github.com/pytorch/pytorch/pull/93155
Approved by: https://github.com/huydhn
This commit is contained in:
Nikita Shulga
2023-01-29 18:28:46 +00:00
committed by PyTorch MergeBot
parent 0dceaf07cd
commit 5976f0bdfe
31 changed files with 58 additions and 625 deletions

View File

@ -22,6 +22,7 @@ from typing import ( # noqa: F401
Any,
Callable,
Dict,
Final,
Generic,
List,
Optional,
@ -42,11 +43,6 @@ from torch._C import Future as CFuture
from torch._sources import fake_range, get_source_lines_and_file, parse_def
from torch.futures import Future
if sys.version_info[:2] > (3, 7):
from typing import Final
else:
from typing_extensions import Final
LockType: Type
try:
import _thread
@ -1216,12 +1212,7 @@ def _get_named_tuple_properties(obj):
def _create_named_tuple(
t, unqual_name: str, field_names: List[str], defaults: Tuple[Any, ...]
):
# mypy: namedtuple() expects a string literal as the first argument
if sys.version_info < (3, 7, 0):
TupleType = collections.namedtuple(unqual_name, field_names) # type: ignore[no-redef, misc]
TupleType.__new__.__defaults__ = defaults # type: ignore[attr-defined]
else:
TupleType = collections.namedtuple(unqual_name, field_names, defaults=defaults) # type: ignore[call-arg, no-redef, misc]
TupleType = collections.namedtuple(unqual_name, field_names, defaults=defaults) # type: ignore[call-arg, no-redef, misc]
return TupleType(*t)