A codemod that automatically converts implicit optional type hints in Python code to be PEP 484 compliant.
no_implicit_optional is a Python codemod tool that automatically fixes implicit optional type hints in code to comply with PEP 484 standards. It converts arguments with default values of `None` from implicit forms (e.g., `x: int = None`) to explicit ones like `Optional[int] = None` or `int | None = None`. This helps developers adapt to stricter type checking enforced by tools like mypy and pyright.
Python developers using type hints and static type checkers like mypy or pyright, especially those transitioning to `--strict` mode or updating legacy codebases.
It automates a tedious and error-prone refactoring task, saving time and ensuring consistency across codebases. The tool supports modern Python syntax (PEP 604) and integrates easily into existing workflows.
A codemod to make your implicit optional type hints PEP 484 compliant.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses libcst to reliably transform code, minimizing human error in updating thousands of type hints across a codebase, as evidenced by its focus on PEP 484 compliance.
Offers the --use-union-or flag to generate PEP 604's X | None syntax, keeping code aligned with the latest Python standards for future compatibility.
Can be installed via pip or run with pipx, making it straightforward to apply to entire directories without complex setup, per the README's simple running instructions.
Encourages using git before running, promoting best practices for change management and rollback safety, as highlighted in the warnings.
Modifies source files in-place without a built-in dry-run option, which could lead to unintended changes if not carefully version-controlled, posing a risk despite warnings.
Only addresses implicit optional type hints; it doesn't help with other type annotation issues or broader code refactoring needs, limiting its utility to a specific problem.
The --use-union-or flag requires Python 3.10+ or specific future imports, restricting its use in legacy projects targeting older versions, as noted in the README.