Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible types at # type: ignore #81

Open
jolaf opened this issue Sep 5, 2019 · 2 comments
Open

Incompatible types at # type: ignore #81

jolaf opened this issue Sep 5, 2019 · 2 comments

Comments

@jolaf
Copy link

jolaf commented Sep 5, 2019

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.

@jolaf jolaf changed the title Incompatible types as # type: ignore Incompatible types at # type: ignore Sep 5, 2019
@Stewori
Copy link
Owner

Stewori commented Sep 5, 2019

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.

@Stewori
Copy link
Owner

Stewori commented Sep 6, 2019

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 #78 (comment) I won't fix this before end of next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants