Skip to content

Add pre-commit hook pyupgrade to auto upgrade Python syntax #1037

@jbampton

Description

@jbampton

"A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language."

https://github.com/asottile/pyupgrade

https://github.com/asottile/pyupgrade?tab=readme-ov-file#python2-and-old-python3x-blocks

Example .pre-commit-config.yaml entry:

  - repo: https://github.com/asottile/pyupgrade
    rev: v3.19.1
    hooks:
      - id: pyupgrade
        args: [--py37-plus]

Availability:

  • --py36-plus will remove Python <= 3.5 only blocks
  • --py37-plus will remove Python <= 3.6 only blocks
    so on and so forth

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions