Skip to content

Instantly share code, notes, and snippets.

@sloria
Last active August 14, 2022 13:26
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sloria/b4a5fc2281f86a5733af198d609c5ab3 to your computer and use it in GitHub Desktop.
Save sloria/b4a5fc2281f86a5733af198d609c5ab3 to your computer and use it in GitHub Desktop.
Checklist for dropping Python 2 in my libraries
  • Add pyupgrade to .pre-commit-config.yaml.

If supporting py35, use --py3-plus instead of --py37-plus.

- repo: https://github.com/asottile/pyupgrade
  rev: ...latest version...
  hooks:
  - id: pyupgrade
    args: [--py37-plus]
  • Run pre-commit (usually tox -e lint in my projects).
  • Remove unnecessary __future__ imports.
  • Update setup.py: remove classifiers and add/update python_requires
    python_requires=">=3.7",
  • Remove conditional installs e.g. 'flake8-bugbear==19.8.0; python_version >= "3.5"' from setup.py and pre-commit-config.yaml.
  • Update tox.ini and CI config (azure-pipelines.yml or .travis.yml).
  • Update installation/requirements and contributing docs.
  • Update pyproject.yml (black) if it exists.
  • Remove compatibility code: compat.py, sys.version_info checks, try:..except ImportError:
  • Use keyword-only arguments where sensible.
  • Update changelog.
@sloria
Copy link
Author

sloria commented Sep 16, 2019

Thanks @hugovk. I don't use six in my projects, but good reminder about sys.version_info and try-excepts. Updated the list with a note about those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment