-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Closed
Labels
better-engineeringRelatively self-contained tasks for better engineering contributorsRelatively self-contained tasks for better engineering contributorsmodule: buildBuild system issuesBuild system issuesmodule: internalsRelated to internal abstractions in c10 and ATenRelated to internal abstractions in c10 and ATentriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🚀 The feature, motivation and pitch
PyTorch now supports Python 3.8+ only.
Lines 216 to 222 in ca84508
import platform | |
python_min_version = (3, 8, 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(), | |
python_min_version_str)) | |
sys.exit(-1) |
But there are still many legacy Python syntaxes in the codebase. Such as:
Redundant object
inherence:
- class A(object):
+ class A:
...
super
call:
class A:
pass
class B(A):
def __init__(self):
- super(B, self).__init__()
+ super().__init__()
string format:
- '%s' % x
+ f"{x}"
- '{}'.format(x)
+ f"{x}"
There is a tool pyupgrade
that can automatically update the code. The migration can be easily done by:
pyupgraede --py38-plus $(find torch -name '*.py' -o -name '*.pyi')
lintrunner -a
It would be nice if you consider pre-commit
integration to apply this for future code changes.
Alternatives
No response
Additional context
No response
cc @malfet @seemethere @ezyang @bhosmer @smessmer @ljk53 @bdhirsh
Coderx7, Skylion007, saryeHaddadi and bryant1410
Metadata
Metadata
Assignees
Labels
better-engineeringRelatively self-contained tasks for better engineering contributorsRelatively self-contained tasks for better engineering contributorsmodule: buildBuild system issuesBuild system issuesmodule: internalsRelated to internal abstractions in c10 and ATenRelated to internal abstractions in c10 and ATentriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module