You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying pytype as an alternative static type checker and it looks quite promising, but the following seems to be quite unpleasant (everything is Python 3.7.3 in a virtual Python environment with pytype installed using pip just for this virtual environment):
fromflaskimportmno, pqr,
stu, vwx# type: ignore
This wrong Python syntax is totally OK according to pytype (pytype main.py). It's even worse - pytype then ignores the whole rest of the file in which these 2 lines reside 😮.
fromflaskimportmno, pqr, \
stu, vwx# type: ignore
This confuses pytype to write out pretty "random" (unrelated) messages like
File "/home/user00/test00/main.py", line 5, in <module>: Couldn't import pyi for 'flask' [pyi-error]
File: "/home/user00/test00/env00/lib/python3.7/site-packages/pytype/typeshed/third_party/2and3/click/core.pyi", line 32
b'def augment_usage_errors('
^
ParseError: Decorator contextmanager not supported
The text was updated successfully, but these errors were encountered:
Thanks for the report! Looks like there are two things going on here.
For
from flask import mno, pqr,
stu, vwx # type: ignore
the # type: ignore makes pytype ignore the syntax error on that line, and the syntax error causes pytype to abort early. Hence no error messages anywhere in the source file. The way to fix this issue would probably be to detect when a syntax error is silenced, and print a warning that the file isn't being type-checked.
the pyi error is caused by #171 - pytype can't handle some third party type stubs. (I'm planning to tackle this issue during the PyCon development sprints starting Monday.) Two possible workarounds are to put # pytype: disable=pyi-error on the first line of the import statement or to run pytype with --disable=pyi-error (which can also be put in a pytype section in setup.cfg).
I'm trying pytype as an alternative static type checker and it looks quite promising, but the following seems to be quite unpleasant (everything is Python 3.7.3 in a virtual Python environment with pytype installed using pip just for this virtual environment):
This wrong Python syntax is totally OK according to pytype (
pytype main.py
). It's even worse - pytype then ignores the whole rest of the file in which these 2 lines reside 😮.This confuses pytype to write out pretty "random" (unrelated) messages like
The text was updated successfully, but these errors were encountered: