Repository navigation
Description
This issue documents code upgrades that can be made if support for python 3.6 is dropped. The LTS support of python in Ubuntu and Debian is as follows:
| distribution | version | python version | end of life |
|---|---|---|---|
| Ubuntu | 18.04 | 3.6 | 2028 |
| Ubuntu | 20.04 | 3.8 | TBD |
| Debian | 9 | 3.5 | 2022 |
| Debian | 10 | 3.7 | 2024 |
Use postponed type annotations.
All TODOs for this are put at the top of the file because from __future__ import annotations needs to be put at the top of the file until python 3.10.
This allows us to remove the awkward "ClassName" type annotations that are sometimes required to reference not-yet-defined classes. (e.g. in the case of a method that returns an instance of its class).
Consider using a dataclass.
dataclasses have a lot of nice properties (...and a few not-so-nice properties).
Use capture_output=True.
This is a simpler way of specifying PIPE for stdout and stderr. Technically not the same as using check_output (as it captures stderr as well), but close enough for our purposes (and I migrated all instances of check_output to run anyway).
Replace universal_newlines= with text=.
universal_newlines=True is a confusing way of saying "treat the output of this process as text (instead of as a binary stream)". It can be avoided by using the text= kwarg.
Remove redundant OrderedDict.
Dictionaries are guaranteed to be ordered as of 3.7. (They were very likely to be ordered in 3.6, but it was still technically an implementation detail).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
Use recommended python3.6 APIs and document 3.7 upgrades (#4134)
GMNGeoffrey commentedon May 18, 2021
Note that for scripts and such I think it would be fine to use dataclasses. There's a backport to Python 3.6, and requiring additional dependencies for developer/CI scripts seems fine.
GMNGeoffrey commentedon Jul 22, 2021
TF has dropped support for Python 3.6, so we're probably going to need to upgrade when we next bump our tf-nightly pip. Probably better to get ahead of that. https://groups.google.com/a/tensorflow.org/g/discuss/c/-bpWukv6r1s
Apply code upgrades for python >= 3.7
Apply code upgrades for python >= 3.7
Apply code upgrades for python >= 3.7
Apply code upgrades for python >= 3.7
Apply code upgrades for python >= 3.7
Apply code upgrades for python >= 3.7
Apply code upgrades for python >= 3.7
Apply code upgrades for python >= 3.7 (#9401)