machinalis / mypy-django

PEP-484 type hints bindings for the Django web framework
BSD 3-Clause "New" or "Revised" License
223 stars 23 forks source link

Two-line file, both ignored, leads to errors within mypy-django. Errors disappear if one line removed, get worse if the other. #11

Open mwchase opened 6 years ago

mwchase commented 6 years ago

Encountered against the latest checkouts, with mypy==0.521

Two lines:

from django.views import View # type: ignore
from django.db import models  # type: ignore

Errors:

$ MYPYPATH=mypy-django mypy --strict-optional --disallow-untyped-calls test_mypy.py 
mypy-django/django/views/generic/list.pyi:3: error: No library stub file for module 'django.db.models'
mypy-django/django/views/generic/list.pyi:3: note: (Stub files are from https://github.com/python/typeshed)
mypy-django/django/views/generic/list.pyi:4: error: No library stub file for module 'django.db.models.query'

One line:

from django.views import View # type: ignore

Errors:

$ MYPYPATH=mypy-django mypy --strict-optional --disallow-untyped-calls test_mypy.py 
mypy-django/django/views/generic/dates.pyi:4: error: No library stub file for module 'django.db'
mypy-django/django/views/generic/dates.pyi:4: note: (Stub files are from https://github.com/python/typeshed)
mypy-django/django/views/generic/detail.pyi:3: error: No library stub file for module 'django.db'
mypy-django/django/views/generic/edit.pyi:3: error: No library stub file for module 'django.db'
mypy-django/django/views/generic/list.pyi:3: error: No library stub file for module 'django.db.models'
mypy-django/django/views/generic/list.pyi:4: error: No library stub file for module 'django.db.models.query'

This is stripped down from a more reasonably-sized file that actually did things, but it seems to be the imports themselves that triggered the issues.

I think this must be some kind of import-order issue.

(I forget why I was ignoring both lines, but it doesn't seem to really have a tangible effect on the output.)