Correct Descriptor Semantics for Initialized Annotations
A shipped Meta Pyrefly contribution that stops annotation-only descriptor inference from misclassifying instance fields initialized in recognized methods. PR #4476 was imported into Meta's internal workflow and shipped upstream as commit 8387bfd.

PR #4476
public PR
8387bfd
upstream commit
2
files changed
APPROVED
Meta Team
01 · Engineering problem
The failure mode
Pyrefly treated annotated instance attributes as class-installed descriptors when their type implemented __get__, even when fields were initialized inside __init__, corrupting type inference.
02 · Technical response
What changed
- 01Traced inference behavior to DeclaredByAnnotation initialized_in_recognized_method signals.
- 02Skipped descriptor construction exclusively for the method-initialized case.
- 03Verified against mypy_primer across Meta's open-source corpus with zero regressions.
03 · Verified outcome
Evidence-backed result
- ✓Shipped upstream in facebook/pyrefly at commit 8387bfded3736532e1b6c1c124264711ea0c50bc.
- ✓Corrected instance attribute descriptor classification across the entire type engine.
04 · Public record
Source evidence
Independent open-source engineering by Patrick Ribbsaeter. Company and project names identify the public repository and maintainer context only. No employment, client, vendor, or partnership relationship is implied unless explicitly stated.