github facebook/pyrefly 0.51.0
Pyrefly v0.51.0

8 hours ago

Status : BETA
Release date: 02 February 2026

Pyrefly v0.51.0 bundles 162 commits from 25 contributors.


✨ New & Improved

Area What’s new
Type Checking - Fixes for incorrect type narrowing in boolean operations with generic functions

- Intersection logic fixed to identify empty intersections (Never) for final classes and populated Enums, as they cannot be subclassed.

- Added support GenericAlias type, including special attributes like __origin__, __args__, and support for the pipe operator

- Added support for checking that class-scoped type variables are not used in self annotations in __init__ methods, per typing spec
Language server - During module resolution, "phantom paths" (non-existent paths checked during import) are now tracked, improving watch mode and import re-resolution

- List addition (+) now propagates type hints to both operands, making assignments like l2: list[Base] = [A()] + [B()] work as expected
Error Handling - Added configuration to debug and/or bypass deep recursion, which is useful for diagnosing stack overflow issues in large or generated codebases

- Multiple error messages have been shortened, clarified, or made more precise for better user experience (e.g., TypedDict, protocol variables, unpacking errors, pydantic, descriptor defaults).
Performance Improvements - Faster suggested standard library imports (did you mean...?)

- Reduced memory usage for type aliases of unions

- Further improvements to tracking for fine-grained dependencies, improving IDE performance during incremental rechecks and accuracy of features like auto-imports

🐛 bug fixes

We closed 21 bug issues this release 👏

  • #2269 - Attribute lookups on classes inheriting from Any now fall back to Any instead of reporting missing-attribute.
  • #2250 - Self is now properly bound in class body expressions.
  • #2236 - fixed issue where --removed-unused-ignores incorrectly removed ignores from other type checkers
  • #2196 - Tuple length checks with isinstance now work correctly with unpacked tuples and type variables
  • #2118 - Legacy TypeVars are now correctly inferred in Callable annotations without assignment
  • And more! #990, #842, #496, #2036, #1917, #1807, #1714, #1680, #2169, #2141, #2211, #2208, #2246, #2267, #2256, #2274

Thank-you to all our contributors who found these bugs and reported them! Did you know this is one of the most helpful contributions you can make to an open-source project? If you find any bugs in Pyrefly we want to know about them! Please open a bug report issue here


📦 Upgrade

pip install --upgrade pyrefly==0.51.0

How to safely upgrade your codebase

Upgrading the version of Pyrefly you're using or a third-party library you depend on can reveal new type errors in your code. Fixing them all at once is often unrealistic. We've written scripts to help you temporarily silence them. After upgrading, follow these steps:

  1. pyrefly check --suppress-errors
  2. run your code formatter of choice
  3. pyrefly check --remove-unused-ignores
  4. Repeat until you achieve a clean formatting run and a clean type check.

This will add # pyrefly: ignore comments to your code, enabling you to silence errors and return to fix them later. This can make the process of upgrading a large codebase much more manageable.

Read more about error suppressions in the Pyefly documentation

🖊️ Contributors this release

@rchen152, @stroxler, @migeed-z, @kinto0, @yangdanny97, @arthaud, @maggiemoss, @connernilsen, @grievejia, @samwgoldman, @rubmary, @fangyi-zhou, @AryanBagade, @bluetech, @ddrcoder, @javabster, @ndmitchell, @praskr-wisdom, @shayne-fletcher, @tsembp, @jvansch1, @tianhan0, @dtolnay

Don't miss a new pyrefly release

NewReleases is sending notifications on new releases.