Skip to content
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

Repro test case for phantom errors in #709 #802

Closed
wants to merge 1 commit into from

Conversation

flaeppe
Copy link
Member

@flaeppe flaeppe commented Jan 3, 2022

I found a repro case for some(?) phantom errors mentioned in #709 (comment). Not at all sure about why they happen like this, or how to resolve them properly. Thought it might be useful for someone else with better insight.

Worth noting from the error is that it only seem to happen for return types imported e.g. from typing import ... as there's no error for the queryset methods having -> "ModelQuerySet": or -> str:

Related issues

Refs #709


Here's the error output of the failing test (from_queryset_queryset_imported_from_other_module):

=================================== FAILURES ===================================
______________ from_queryset_queryset_imported_from_other_module _______________
/home/runner/work/django-stubs/django-stubs/tests/typecheck/managers/querysets/test_from_queryset.yml:31: 
E   pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output: 
E   Actual:
E     ...
E     main:5: note: Revealed type is "Any"          (diff)
E    main:6: note: Revealed type is "builtins.str"
E    main:7: note: Revealed type is "myapp.querysets.ModelQuerySet"
E    main:8: note: Revealed type is "myapp.querysets.ModelQuerySet[myapp.models.MyModel*]"
E     myapp/models:10: error: Name "Iterable" is not defined (diff)
E     myapp/models:10: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Iterable") (diff)
E   Expected:
E     ...
E     main:5: note: Revealed type is "typing.Iterable[Any]" (diff)
E    main:6: note: Revealed type is "builtins.str"
E    main:7: note: Revealed type is "myapp.querysets.ModelQuerySet"
E    main:8: note: Revealed type is "myapp.querysets.ModelQuerySet[myapp.models.MyModel*]"
E   Alignment of first line difference:
E     E: ...te: Revealed type is "typing.Iterable[Any]"
E     A: ...te: Revealed type is "Any"
E                                 ^

@flaeppe
Copy link
Member Author

flaeppe commented Jan 15, 2022

Superseded by #820

@flaeppe flaeppe closed this Jan 15, 2022
@flaeppe flaeppe deleted the fix/709 branch January 15, 2022 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant