Skip to content

INTERNAL ERROR on class scoped import of a decorated function #12474

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

Closed
karajan1001 opened this issue Mar 28, 2022 · 2 comments · Fixed by #12724
Closed

INTERNAL ERROR on class scoped import of a decorated function #12474

karajan1001 opened this issue Mar 28, 2022 · 2 comments · Fixed by #12724

Comments

@karajan1001
Copy link

Crash Report

After version 0.940, In #12023 and #12199, mypy disabled class scoped import. But, I found in a decorated function it will still raise an INTERNAL ERROR

Traceback

(Insert traceback and other messages from mypy here -- use `--show-traceback`.)
$ mypy . --show-traceback
./a.py:4: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.942
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 3978, in accept
  File "mypy/nodes.py", line 1670, in accept
  File "mypy/checkexpr.py", line 2087, in visit_member_expr
  File "mypy/checkexpr.py", line 2105, in analyze_ordinary_member_access
  File "mypy/checkmember.py", line 130, in analyze_member_access
  File "mypy/checkmember.py", line 147, in _analyze_member_access
  File "mypy/checkmember.py", line 231, in analyze_instance_member_access
  File "mypy/checkmember.py", line 385, in analyze_member_var_access
  File "mypy/checkmember.py", line 559, in analyze_var
  File "mypy/maptype.py", line 20, in map_instance_to_supertype
AttributeError: attribute 'type_vars' of 'TypeInfo' undefined
./a.py:4: : note: use --pdb to drop into pdb

To Reproduce

$ cat a.py
class A:
	from b import foo

print(A().foo())  # ← INTERNAL ERROR here
$ cat b.py
def c(func):
    return func


@c
def foo(self):
	return ""
$ mypy .
./a.py:4: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
If this issue continues with mypy master, please report a bug at https://github.com/python/mypy/issues
version: 0.942
./a.py:4: : note: please use --show-traceback to print a traceback when reporting a bug

Your Environment

  • Mypy version used: 0.942
  • Mypy command-line flags: no flag
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.8.8
  • Operating system and version: macOS 12.3
@AlexWaygood
Copy link
Member

Cc. @hauntsaninja

@dzcode
Copy link
Contributor

dzcode commented May 3, 2022

I've put up a PR to fix this at #12724

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

Successfully merging a pull request may close this issue.

4 participants