Skip to content

Now lambda is counted as a valid context in handle_cannot_determine_type #11215

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

Merged
merged 2 commits into from
Sep 28, 2021
Merged

Now lambda is counted as a valid context in handle_cannot_determine_type #11215

merged 2 commits into from
Sep 28, 2021

Conversation

sobolevn
Copy link
Member

Closes #11212

Previously mypy was ignoring lambda scope in handle_cannot_determine_type.
I guess it was done to fix some lambda related crashes.

I've also noticed one crash with this new solution in existing test. I happened because when right or part is unreachable, there's not binder.frame for it. So, I've made a temporary scope of it.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

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

graphql-core (https://github.com/graphql-python/graphql-core.git)
+ tests/execution/test_union_interface.py:69: error: unused "type: ignore" comment
+ tests/execution/test_union_interface.py:75: error: unused "type: ignore" comment
+ tests/execution/test_union_interface.py:76: error: unused "type: ignore" comment
+ tests/execution/test_union_interface.py:77: error: unused "type: ignore" comment
+ tests/execution/test_union_interface.py:87: error: unused "type: ignore" comment
+ tests/execution/test_union_interface.py:88: error: unused "type: ignore" comment
+ tests/execution/test_union_interface.py:89: error: unused "type: ignore" comment
+ tests/execution/test_union_interface.py:100: error: unused "type: ignore" comment
+ tests/execution/test_union_interface.py:101: error: unused "type: ignore" comment
+ tests/execution/test_union_interface.py:102: error: unused "type: ignore" comment
+ tests/execution/test_union_interface.py:127: error: unused "type: ignore" comment
+ tests/execution/test_union_interface.py:128: error: unused "type: ignore" comment
+ tests/execution/test_union_interface.py:129: error: unused "type: ignore" comment

@sobolevn
Copy link
Member Author

From mypy_primer: mypy no longer raises an error in cases like:

LifeType = GraphQLInterfaceType(
    "Life", lambda: {"progeny": GraphQLField(GraphQLList(LifeType))}  # type: ignore
)

Seems like a good thing to me.

@JelleZijlstra JelleZijlstra merged commit d37c2be into python:master Sep 28, 2021
JukkaL added a commit that referenced this pull request Dec 9, 2021
JukkaL added a commit that referenced this pull request Dec 9, 2021
…determine_type` (#11215)" (#11694)

This reverts commit d37c2be.

Lambdas can't be safely deferred. There are various subtle assumptions about
lambdas not being deferred in different parts of the codebase, and figuring out
how to do this safely is almost certainly not worth the trouble. This would be
very difficult to validate, since lambda deferral would probably happen very
rarely in practice.
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
…determine_type` (python#11215)" (python#11694)

This reverts commit d37c2be.

Lambdas can't be safely deferred. There are various subtle assumptions about
lambdas not being deferred in different parts of the codebase, and figuring out
how to do this safely is almost certainly not worth the trouble. This would be
very difficult to validate, since lambda deferral would probably happen very
rarely in practice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Cannot determine type of ..." when using decorators
2 participants