A semi-static Python type checker that imports modules to understand dynamic constructs and enable plugin extensions.
Pyanalyze is a semi-static type checker for Python that detects type errors in code before it reaches production. It differs from traditional static type checkers by importing the modules it analyzes, enabling it to understand dynamic Python constructs that other tools might reject. This approach also allows for extensible plugins that can interact directly with the code being checked.
Python developers and teams who need more accurate type checking for codebases with dynamic patterns, and those who want to extend type checking with custom rules for specific functions or libraries.
Developers choose pyanalyze over alternatives because it handles dynamic Python code more effectively through runtime import analysis, offers a flexible plugin system for custom validation, and provides interactive error fixing to streamline the debugging process.
A Python type checker
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
By importing modules during checking, pyanalyze understands runtime behaviors and dynamic constructs that static checkers like mypy might miss, as highlighted in the README's emphasis on handling dynamic Python code.
Allows custom signatures to inspect function arguments, enabling validation of domain-specific logic such as SQL query safety, demonstrated in the README's example with database.run_query().
The `-f` flag provides an interactive prompt to examine and fix errors individually, streamlining debugging workflows directly from the command line.
Supports configuration via both command-line options and pyproject.toml files, easing integration into diverse development setups as documented in the configuration guide.
Importing modules can execute code, risking unintended side effects if scripts lack proper `if __name__ == '__main__':` blocks, a caveat explicitly warned in the README.
Requires manual adjustment of PYTHONPATH for successful imports, adding setup overhead in complex or containerized environments, which the README acknowledges may be necessary.
Uses custom `# static analysis: ignore` comments instead of the standard `# type: ignore`, causing compatibility issues with other tools and workflows, as noted in the error ignoring section.
The README admits that support for some Python typing features is incomplete, potentially limiting its use for codebases relying on advanced type hints or full spec compliance.