Incompatible types at # type: ignore
The following code:
from pytypes import TypeChecker
def f() -> None: # type: ignore # blah
pass
with TypeChecker():
f()
fails as follows:
$ python3 Test.py
/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py:2534: UserWarning: the system profiling hook has changed unexpectedly
warn('the system profiling hook has changed unexpectedly')
Traceback (most recent call last):
File "Test.py", line 7, in <module>
f()
File "Test.py", line 3, in f
def f() -> None: # type: ignore # blah
TypeError: __main__.f declares incompatible types:
Via hints: (Tuple[], NoneType)
Via comment: None
The problem disappears if # blah is removed.
Not a solution as this is actually a symptom of pytypes being unaware of ignore:
You can work around this by setting pytypes.strict_annotation_collision_check = False.
Ah, sorry; I recognized that this workaround wouldn't do it because pytypes still asserts that a concurrent type string to a type annotation would yield the same type. It would be an easy fix to disable this or to allow an opt-out of this check. However for the reason explained in https://github.com/Stewori/pytypes/issues/78#issuecomment-528878913 I won't fix this before end of next week.