Skip to content

fix Support bare class names for in-based narrowing #937#2291

Closed
asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
asukaminato0721:937
Closed

fix Support bare class names for in-based narrowing #937#2291
asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
asukaminato0721:937

Conversation

@asukaminato0721
Copy link
Contributor

Summary

Fixes #937

in-based narrowing treats bare class objects in list/tuple/set literals as narrowable values (via ClassDef -> type[...] and direct type[...]), and added a small class-object equality case for not in.

Test Plan

Added a regression test covering type[object] narrowed by x in (int, float).

@meta-cla meta-cla bot added the cla signed label Feb 3, 2026
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Diff from mypy_primer, showing the effect of this PR on open source code:

zulip (https://github.com/zulip/zulip)
+ ERROR zerver/lib/bulk_create.py:199:40-57: Argument `set[Stream | UserProfile]` is not assignable to parameter `objs` with type `Iterable[Stream]` in function `django.db.models.manager.Manager.bulk_update` [bad-argument-type]
+ ERROR zerver/lib/bulk_create.py:199:40-57: Argument `set[Stream | UserProfile]` is not assignable to parameter `objs` with type `Iterable[UserProfile]` in function `django.db.models.manager.Manager.bulk_update` [bad-argument-type]
+ ::error file=zerver/lib/bulk_create.py,line=199,col=40,endLine=199,endColumn=57,title=Pyrefly bad-argument-type::Argument `set[Stream | UserProfile]` is not assignable to parameter `objs` with type `Iterable[Stream]` in function `django.db.models.manager.Manager.bulk_update`
+ ::error file=zerver/lib/bulk_create.py,line=199,col=40,endLine=199,endColumn=57,title=Pyrefly bad-argument-type::Argument `set[Stream | UserProfile]` is not assignable to parameter `objs` with type `Iterable[UserProfile]` in function `django.db.models.manager.Manager.bulk_update`

asynq (https://github.com/quora/asynq)
- ERROR asynq/decorators.py:272:18-27: Expected a callable, got `object` [not-callable]
+ ERROR asynq/decorators.py:279:11-13: Argument `classmethod[Unknown, Ellipsis, Unknown] | staticmethod[Ellipsis, Unknown] | Unknown` is not assignable to parameter with type `(...) -> Unknown` [bad-argument-type]
- ::error file=asynq/decorators.py,line=272,col=18,endLine=272,endColumn=27,title=Pyrefly not-callable::Expected a callable, got `object`
+ ::error file=asynq/decorators.py,line=279,col=11,endLine=279,endColumn=13,title=Pyrefly bad-argument-type::Argument `classmethod[Unknown, Ellipsis, Unknown] | staticmethod[Ellipsis, Unknown] | Unknown` is not assignable to parameter with type `(...) -> Unknown`

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ ERROR src/hydra_zen/structured_configs/_implementations.py:1315:20-1323:14: Returned type `list[Unknown] | tuple[Unknown, ...]` is not assignable to declared return type `_T` [bad-return]
+ ::error file=src/hydra_zen/structured_configs/_implementations.py,line=1315,col=20,endLine=1323,endColumn=14,title=Pyrefly bad-return::Returned type `list[Unknown] | tuple[Unknown, ...]` is not assignable to declared return type `_T`

@meta-codesync
Copy link

meta-codesync bot commented Feb 5, 2026

@grievejia has imported this pull request. If you are a Meta employee, you can view this in D92349969.

Copy link
Contributor

@stroxler stroxler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

Copy link
Contributor

@stroxler stroxler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync
Copy link

meta-codesync bot commented Feb 10, 2026

@grievejia merged this pull request in 676728f.

@asukaminato0721 asukaminato0721 deleted the 937 branch February 10, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support bare class names for in-based narrowing

4 participants