tensorflow / tensorflow/tensorboard

Replace py2isms with py3

Open
#4,488 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:cleanup
Dominant language
TypeScript
Stars
7.2k
Forks
1.7k
Avg merge
4d 22h
Merged PRs (30d)
1

Description

We have by now firmly and securely dropped Python 2 support. As of
#4361, all our sources set srcs_version = "PY3", so no Bazel-built py2
binaries may depend on these sources (even Google-internally).

There remain many contortions in our code that are vestiges of the
bicompatibility period. Most of these fall under “mostly harmless, but
should be cleaned up incrementally or eventually”.

Off the top of my head:

  • Replace u"xxx" literals with just "xxx" strings (#4409)
  • Replace box = [None] closure access pattern with nonlocal (#4482)
  • Remove now-useless __future__ imports (#4503)
  • Use os.makedirs(exist_ok=True) rather than EEXIST dances
  • Remove fallbacks for sys.stderr.buffer, et al.
  • Remove fallbacks for html.escape (#4515)
  • Remove the argparse_util fallback (#4493)
  • Simplify conditional imports of unittest.mock (#4507)
  • Kill the unittest.mock backport dependency (#4507)
  • Replace all usages of six with the idiomatic Python 3 code (pending: #4510)

Feel free to add more.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names several remaining Python 3 cleanup areas but no specific files or tests. Choose one unchecked item, locate its usages in the sources, and confirm that the selected Python 2 compatibility code is removed without changing supported Python 3 behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.