Skip to main content

Introduction

Pyrefly is a static typechecker for Python that helps you catch type-related errors before your code runs. It analyzes your Python code to ensure type consistency throughout your codebase, making your applications more reliable and easier to maintain. Pyrefly supports both IDE integration and CLI usage, giving you flexibility in how you incorporate type checking into your workflow.

Benefits of Type Checking

Adding type annotations to your Python code and using a typechecker like Pyrefly provides several important benefits:

  • Catch bugs early - Identify type-related errors during development rather than at runtime
  • Improve code quality - Type annotations serve as living documentation, making your code more readable and self-documenting
  • Enhance developer experience - Get better IDE support with accurate autocomplete, refactoring tools, and inline documentation
  • Safer refactoring - Make large-scale changes with confidence, knowing the typechecker will catch incompatible type usage
  • Better collaboration - Types create clear contracts between different parts of your codebase, making it easier for teams to work together

Try Pyrefly

Here's a simple example showing how Pyrefly can catch type errors:


In this example, Pyrefly flags the second call to greet() because we're passing an integer (42) where a string is expected, helping you catch this issue before your code runs. To learn more about Python typing and how to use it effectively, check out our Python Typing for Beginners page.

Next Steps

Ready to get started with Pyrefly? Check out these resources:

Configuration

Once you've installed Pyrefly, you can customize its behavior:

Migrating from Other Typecheckers

If you're currently using a different Python typechecker, we have guides to help you migrate to Pyrefly:

Error Kinds

Pyrefly provides detailed explanations for all the errors it can detect:

  • Error Kinds - A comprehensive list of all Pyrefly errors with their explanations

Advanced Topics

As you become more familiar with Pyrefly, explore these advanced topics: