Skip to content

add tests for incremental on field keys#2203

Closed
kinto0 wants to merge 1 commit into
facebook:mainfrom
kinto0:export-D91172436
Closed

add tests for incremental on field keys#2203
kinto0 wants to merge 1 commit into
facebook:mainfrom
kinto0:export-D91172436

Conversation

@kinto0

@kinto0 kinto0 commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

Summary:

This stack

This stack modifies the optimization for incremental updates found in the stack containing D90647539.

Original optimization: Use import statements alone to understand which imports a module uses

Problem: import foo will always invalidate foo

This stack will modify this optimization to instead track these dependencies based on usages during solve. Every type depended on from a module will be referenced in solve and we only will need to invalidate an entire module when there is an import *.

This diff

adds tests for field keys incrementality. similar to test_enum_member_change_propagates, when a field or part of a class gets added, removing a type error, we need to ensure dependents get updated. this is necessary because without D91173578, the semantic invalidation will not work

Reviewed By: yangdanny97

Differential Revision: D91172436

Summary:
# This stack

This stack modifies the optimization for incremental updates found in the stack containing D90647539. 

Original optimization: Use import statements alone to understand which imports a module uses

Problem: `import foo` will always invalidate `foo`

This stack will modify this optimization to instead track these dependencies based on usages during solve. Every type depended on from a module will be referenced in solve and we only will need to invalidate an entire module when there is an import *.

# This diff
adds tests for field keys incrementality. similar to test_enum_member_change_propagates, when a field or part of a class gets added, removing a type error, we need to ensure dependents get updated. this is necessary because without D91173578, the semantic invalidation will not work

Reviewed By: yangdanny97

Differential Revision: D91172436
@meta-codesync

meta-codesync Bot commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

@kinto0 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D91172436.

@yangdanny97 yangdanny97 left a comment

Copy link
Copy Markdown
Contributor

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.

@github-actions

Copy link
Copy Markdown

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

openlibrary (https://github.com/internetarchive/openlibrary)
+ ERROR openlibrary/plugins/openlibrary/lists.py:811:43-813:18: Cannot set item in `dict[str, list[dict[Unknown, Unknown]]]` [unsupported-operation]
+ ERROR openlibrary/plugins/openlibrary/lists.py:818:40-88: Cannot set item in `dict[str, list[dict[Unknown, Unknown]]]` [unsupported-operation]
+ ERROR openlibrary/plugins/openlibrary/lists.py:823:42-825:18: Cannot set item in `dict[str, list[dict[Unknown, Unknown]]]` [unsupported-operation]
+ ERROR openlibrary/plugins/upstream/tests/test_merge_authors.py:142:12-52: Object of class `NoneType` has no attribute `key` [missing-attribute]
+ ::error file=openlibrary/plugins/openlibrary/lists.py,line=811,col=43,endLine=813,endColumn=18,title=Pyrefly unsupported-operation::Cannot set item in `dict[str, list[dict[Unknown, Unknown]]]`%0A  Argument `list[Thing | Unknown]` is not assignable to parameter `value` with type `list[dict[Unknown, Unknown]]` in function `dict.__setitem__`
+ ::error file=openlibrary/plugins/openlibrary/lists.py,line=818,col=40,endLine=818,endColumn=88,title=Pyrefly unsupported-operation::Cannot set item in `dict[str, list[dict[Unknown, Unknown]]]`%0A  Argument `list[Thing | Unknown]` is not assignable to parameter `value` with type `list[dict[Unknown, Unknown]]` in function `dict.__setitem__`
+ ::error file=openlibrary/plugins/openlibrary/lists.py,line=823,col=42,endLine=825,endColumn=18,title=Pyrefly unsupported-operation::Cannot set item in `dict[str, list[dict[Unknown, Unknown]]]`%0A  Argument `list[Thing | Unknown]` is not assignable to parameter `value` with type `list[dict[Unknown, Unknown]]` in function `dict.__setitem__`
- ::error file=openlibrary/plugins/upstream/tests/test_merge_authors.py,line=37,col=9,endLine=37,endColumn=12,title=Pyrefly bad-override::Class member `MockSite.get` overrides parent class `Site` in an inconsistent manner%0A  `MockSite.get` has type `BoundMethod[MockSite, (self: MockSite, key: Unknown) -> Unknown]`, which is not assignable to `BoundMethod[MockSite, (self: MockSite, key: Unknown, revision: Unknown | None = None, lazy: bool | Unknown = False) -> Unknown | None]`, the type of `Site.get`
+ ::error file=openlibrary/plugins/upstream/tests/test_merge_authors.py,line=37,col=9,endLine=37,endColumn=12,title=Pyrefly bad-override::Class member `MockSite.get` overrides parent class `Site` in an inconsistent manner%0A  `MockSite.get` has type `BoundMethod[MockSite, (self: MockSite, key: Unknown) -> Thing | Unknown]`, which is not assignable to `BoundMethod[MockSite, (self: MockSite, key: Unknown, revision: Unknown | None = None, lazy: bool | Unknown = False) -> Thing | Unknown | None]`, the type of `Site.get`
+ ::error file=openlibrary/plugins/upstream/tests/test_merge_authors.py,line=142,col=12,endLine=142,endColumn=52,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `key`
@meta-codesync

meta-codesync Bot commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

This pull request has been merged in 77638e9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment