Release date: September 28, 2026
Pyrefly v1.3.2 is a patch release that fixes regressions in how Pyrefly infers the type of a variable after it is assigned a value of type Any.
馃悰 Bug fixes
- #4846: Fixed several regressions from v1.3.0 in type inference after a variable is reassigned to
Any:- Assigning an implicit
Any(a value with no known type, such as the result of an unannotated function or an unresolved import) to an annotated variable once again producesUnknown. It no longer turns into an explicitAny. - When a variable annotated as
Optional[T]orT | Noneis narrowed toNoneand then reassigned inside that branch, Pyrefly no longer adds the annotation'sNoneback after the branch. For example,x: Any | Nonefollowed byif x is None: x = get_any()now givesAnyinstead ofAny | None. - When a variable's annotation is a union that contains
Any, assigningAnyto it now narrows the variable toAny. For example,x: Any | Nonefollowed byx = x or get_any()now givesAnyinstead ofAny | None, so later attribute access no longer reports a falsemissing-attributeerror onNone.
- Assigning an implicit
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==1.3.2How 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:
pyrefly check --suppress-errors- Run your code formatter of choice
pyrefly check --remove-unused-ignores- 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 Pyrefly documentation.