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

Pyupgrade Alternatives

Similar projects and alternatives to pyupgrade

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a better pyupgrade alternative or higher similarity.

Suggest an alternative to pyupgrade

Reviews and mentions

Posts with mentions or reviews of pyupgrade. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2021-10-15.
  • Ask HN: Did somebody have success with the migration of Python 2.7 to Java/C#? | 2021-10-15
    From my advice, try to stay on Python.

    I am currently doing the opposite. Moving an old Java stack to Python/Django. Been able to do so under 9 months. I think upgrading to Python 3 should be doable. What's the version of your Django stack? You just need to try to reach Django 2.2. And if you are at Django 1.1, 90% of your code can be upgraded to Python 3. Nothing fancy. You just need to use libraries such as pyupgrade [0] to automatically upgrade your code, combined with black [1], flake [2],... Everything is done in less than 20 commits. From there you jump to 2.2 which supports Python 3.6+ .

    It will be very difficult to implement all the goodies given by Django ORM/SQLAlchemy. But ... You if Java/C# is the tech that you feel confortable with, no problem. You have to use it. But, I really think it's easier to understand the "business domain" of Python code than Java/C#.


  • Chickity-check yo self before you wreck yo self! | 2021-07-06
    --- # .pre-commit-config.yaml # ======================== # # pre-commit clean # pre-commit install # pre-commit install-hooks # # precommit hooks installation # # - pre-commit autoupdate # # - pre-commit run black # # continuous integration # ====================== # # - pre-commit run --all-files # repos: - repo: rev: v4.0.1 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: debug-statements - id: check-merge-conflict - id: sort-simple-yaml - id: fix-encoding-pragma args: ["--remove"] - id: forbid-new-submodules - id: mixed-line-ending args: ["--fix=lf"] description: Forces to replace line ending by the UNIX 'lf' character. - id: check-added-large-files args: ["--maxkb=500"] - id: no-commit-to-branch args: [--branch, master] - id: check-yaml - id: check-json files: ^tests/app/ - id: pretty-format-json args: ["--no-sort-keys", "--autofix"] files: ^tests/app/ - repo: meta hooks: - id: check-hooks-apply - id: check-useless-excludes - repo: rev: 21.5b1 hooks: - id: black language_version: python3.9 - repo: rev: 1.7.0 hooks: - id: bandit description: Security oriented static analyser for python code exclude: tests/|scripts/ args: - -s - B101 - repo: rev: v2.1.0 hooks: - id: codespell name: codespell description: Checks for common misspellings in text files. entry: codespell language: python types: [text] - repo: rev: v2.19.4 hooks: - id: pyupgrade
  • What happens if we don't migrate Python 2 code to python 3 | 2021-05-06
    Then you can convert all the old syntax used for compatibility purpose to a brand new one, using pyupgrade: It allows to pass the list of supported Python versions in config file, so after running this tool all the old code will be converted to the most modern supported syntax. After that you should again run all the tests and check your application behaviour on the staging environment.
  • Looking for automated tool that "inverts" 2to3 and futurize | 2021-05-04
  • PyUpgrade – Automatically upgrade to newer Python syntax | 2021-02-10
  • Flynt: Convert old Python string formatting to f-strings | 2021-02-09
    pyupgrade seems to do lots of useful stuff; thx for link!

    I guess you need the `--py36-plus` CLI option to reproduce the desired behaviour

    thought that might result in lots of other edits to the source, this in particular seems unwarranted "foo".encode("utf-8") --> "foo".encode() because the default encoding in py3+ is utf-8. What happened to explicit is better than implicit?


Basic pyupgrade repo stats
9 days ago

asottile/pyupgrade is an open source project licensed under MIT License which is an OSI approved license.

Find remote Python jobs at our new job board There are 10 new remote jobs listed recently.
Are you hiring? Post a new remote job listing for free.