{"library":"pyupgrade","title":"pyupgrade","description":"pyupgrade is an active Python tool (version 3.21.2) designed to automatically upgrade code syntax for newer language versions. It streamlines the process of adopting modern Python features, improving code readability and efficiency. It's primarily used as a command-line utility or integrated into development workflows via pre-commit hooks, with new versions released continuously to support the latest Python syntax.","language":"python","status":"active","last_verified":"Sat Apr 11","install":{"commands":["pip install pyupgrade"],"cli":{"name":"pyupgrade","version":"usage: pyupgrade [-h] [--exit-zero-even-if-changed] [--keep-percent-format]"}},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"# my_module.py\nimport os\nfrom typing import List\n\ndef old_function(name):\n    print(\"Hello, %s!\" % name)\n\nclass OldClass(object):\n    def __init__(self, value):\n        self.value = value\n\ndef process_items(items: List[int]) -> List[int]:\n    return [x * 2 for x in items]\n\n# Run pyupgrade from the command line:\n# pyupgrade --py38-plus my_module.py\n# This will update the file in place to, for example, use f-strings and remove object inheritance.","lang":"python","description":"To quickly upgrade a Python file, first save your code, then run `pyupgrade` from your terminal, specifying the target Python version using a `--pyN-plus` flag. This example updates `my_module.py` to Python 3.8+ syntax, converting old string formatting, removing redundant `(object)` inheritance, and updating type hints.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}