typeddjango / django-stubs

PEP-484 stubs for Django
MIT License
1.58k stars 436 forks source link

match Field TypeVar variance in models.fields.related #2292

Closed asottile closed 2 months ago

asottile commented 2 months ago

previously failing with:

_____________________________ foreign_key_subclass _____________________________
/home/asottile/workspace/django-stubs/tests/typecheck/fields/test_related.yml:90: 
E   pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output: 
E   Actual:
E     myapp/models:7: error: Variance of TypeVar "_ST" incompatible with variance in parent type  [type-var] (diff)
E     myapp/models:7: error: Variance of TypeVar "_GT" incompatible with variance in parent type  [type-var] (diff)
E   Expected:
E     (empty)

I'm not sure how this wasn't a problem before 5.0.4 for us but it certainly is now!

I'm also surprised mypy doesn't report this same error for related.pyi itself -- there must be some special-cased rules that .pyi files don't have to follow

asottile commented 2 months ago

failure looks like a github flake