Skip to content

Code upgrades for python >= 3.7 #4131

Closed

Description

@phoenix-meadowlark

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).

Activity

  1. added
    infrastructure
    integrations/tensorflow
    bindings/python
    on Dec 8, 2020
  2. GMNGeoffrey commented on May 18, 2021

    @GMNGeoffrey
    Member

    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.

  3. GMNGeoffrey commented on Jul 22, 2021

    @GMNGeoffrey
    Member

    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

  4. self-assigned this
    on Jun 8, 2022
  5. added 7 commits that reference this issue on Jun 9, 2022
    d6015b3
    b09be1a
    0849b6c
    5faf790
    1b4ae38
    7578c15
    5654287
  6. added a commit that references this issue on Jun 13, 2022
    a34c7ac
  7. Repository owner moved this from In Progress to Done in IREE - ARCHIVED (do not update)on Jun 13, 2022
  8. moved this to Done in IREEon Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bindings/pythoninfrastructureintegrations/tensorflow

Type

No type

Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions