mypy-django-example
mypy-django-example copied to clipboard
Install all and get errors
Python version: 3.6.8, Linux
pip freeze
output:
Django==2.2.4
django-stubs==1.0.2
mypy==0.720
mypy-extensions==0.4.1
pkg-resources==0.0.0
pytz==2019.2
sqlparse==0.3.0
typed-ast==1.4.0
typing-extensions==3.7.4
mypy --strict-optional -p polls
output:
polls/models.py:8: error: Need type annotation for 'question_text'
polls/models.py:9: error: Need type annotation for 'pub_date'
polls/models.py:23: error: Need type annotation for 'question'
polls/models.py:24: error: Need type annotation for 'choice_text'
polls/models.py:25: error: Need type annotation for 'votes'
polls/views.py:45: error: "Question" has no attribute "choice_set"
polls/views.py:58: error: "Question" has no attribute "id"
I must add #type models.CharField
to polls/models.py:8
. Why it is necessary?