-
Notifications
You must be signed in to change notification settings - Fork 259
Description
Bug Report
Description
Pyrefly consistently infers id as int type across my entire project, even when explicitly defined as CharField(primary_key=True) in abstract models.
Observations
Screenshot 1: CharField inheritance - Works correctly (no errors)
Both StrIdMixin and StrIdChildModel inherit CharField as primary key.
test_str()with string operations: No errors showntest_int()with integer operations: Correctly shows errors with# error:comments
Screenshot 2: CharField inheritance - Does NOT work (false errors)
TuidMixin also defines id = CharField(...) with primary_key=True.
- Pyrefly shows errors on string operations
- Treats
idasintinstead ofstr
Problem
I'm not sure what conditions cause the difference, but in my project, Pyrefly consistently infers id as int regardless of the actual CharField definition. The behavior is inconsistent between the two cases shown.
My workaround is if TYPE_CHECKING: pk: str
Environment
- Pyrefly version: 0.49
- Django version: 6
Expected
CharField primary key should always be typed as str, consistently across all abstract model inheritance patterns.