-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Handle TypedDict in diff and deps #4510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -199,6 +199,8 @@ def visit_class_def(self, o: ClassDef) -> None: | |||
self.add_type_dependencies(base, target=target) | |||
if o.info.tuple_type: | |||
self.add_type_dependencies(o.info.tuple_type, target=make_trigger(target)) | |||
if o.info.typeddict_type: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am mostly in favor of "unification" of TypedDict
and NamedTuple
, but why can't you just use o.info.replaced.typeddict_type
here? (Then you wouldn't need to change semanal.py
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced
doesn't get serialized, so the right thing to do seemed to be following NamedTuple
and actually doing the replacement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good, just a few minor things.
mypy/server/deps.py
Outdated
elif isinstance(rvalue, CallExpr) and isinstance(rvalue.analyzed, TypedDictExpr): | ||
# Depend on the underlying typeddict type | ||
info = rvalue.analyzed.info | ||
assert(info.typeddict_type is not None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit: spurious parens around the expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One day I will remember that python assert is a statement.
__main__.Point | ||
__main__.p | ||
|
||
[case testTypedDict2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test also that removing or adding a field triggers a TypedDict type. And test that changing totality triggers the type.
test-data/unit/fine-grained.test
Outdated
== | ||
b.py:3: error: Unsupported operand types for + ("int" and "str") | ||
|
||
[case testTypedDictUpdate] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test case has same name as the previous test case.
BaseTypeExpr( | ||
NameExpr(TypedDict [mypy_extensions.TypedDict])) | ||
BaseType( | ||
typing.Mapping[builtins.str, builtins.str]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A consequence of the semanal changes that replace the TypeInfo with the replaced
version.
Required performing a patchup in semanal to *actually* replace the TypeInfo with the 'replaced' version.
55ce1b1
to
6965aa7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates! LGTM now.
* master: (32 commits) Fix some fine-grained cache/fswatcher problems (python#4560) Sync typeshed (python#4559) Add _cached suffix to test cases in fine-grained tests with cache (python#4558) Add back support for simplified fine-grained logging (python#4557) Type checking of class decorators (python#4544) Sync typeshed (python#4556) When loading from a fine-grained cache, use the real path, not the cached (python#4555) Switch all of the fine-grained debug logging to use manager.log (python#4550) Caching for fine-grained incremental mode (python#4483) Fix --warn-return-any for NotImplemented (python#4545) Remove myunit (python#4369) Store line numbers of imports in the cache metadata (python#4533) README.md: Fix a typo (python#4529) Enable generation and caching of fine-grained dependencies from normal runs (python#4526) Move argument parsing for the fine-grained flag into the main arg parsing code (python#4524) Don't warn about unrecognized options starting with 'x_' (python#4522) stubgen: don't append star arg when args list already has varargs appended (python#4518) Handle TypedDict in diff and deps (python#4510) Fix Options.__repr__ to not infinite recurse (python#4514) Fix some fine-grained incremental bugs with newly imported files (python#4502) ...
Required performing a patchup in semanal to actually replace the
TypeInfo with the 'replaced' version.