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

error: Cannot determine type of 'f3' #7552

Closed
wugifer opened this issue Sep 23, 2019 · 1 comment
Closed

error: Cannot determine type of 'f3' #7552

wugifer opened this issue Sep 23, 2019 · 1 comment

Comments

@wugifer
Copy link

wugifer commented Sep 23, 2019

When I mix codes with 'import loop', 'class decorator', sometimes mypy cannot determine my function type:

$ mypy level1.py
level2.py:3: error: Cannot determine type of 'f3'

but run python ok:

$ python3 level1.py
$

Below are my codes:

$ cat level1.py
import  level2

$ cat level2.py
import level3

f3 = level3.f3

$ cat level3.py
from level4 import v4

class C3(object):
    def deco(self, func):
        def new_func():
            pass

        return new_func

obj = C3()

@obj.deco
def f3():
    pass

$ cat level4.py
import level2

v4 = 4

I have do some tests, here are the results:

  • level4.py removes 'v4=4', level3.py changes to 'import level4', mypy ok
  • level4.py removes 'import level2', mypy ok
  • level2.py changes to 'from level3 import f3', mypy ok
  • level3.py changes to non-class decorator, mypy ok
@ilevkivskyi
Copy link
Member

Thanks for reporting! I think this is a duplicate of #6356

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