Skip to content

INTERNAL ERROR when importing into a class #10521

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
Kyuuhachi opened this issue May 21, 2021 · 1 comment
Closed

INTERNAL ERROR when importing into a class #10521

Kyuuhachi opened this issue May 21, 2021 · 1 comment

Comments

@Kyuuhachi
Copy link

Crash Report

It seems that mypy doesn't like from x import y statements inside classes. While maybe unusual, from dataclasses import replace is quite handy.

Traceback

Running as mypy --show-traceback a.py, on commit 8e909e4.

a.py:4: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.812
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 3898, in accept
  File "mypy/nodes.py", line 1507, in accept
  File "mypy/checkexpr.py", line 2025, in visit_member_expr
  File "mypy/checkexpr.py", line 2043, in analyze_ordinary_member_access
  File "mypy/checkmember.py", line 126, in analyze_member_access
  File "mypy/checkmember.py", line 143, in _analyze_member_access
  File "mypy/checkmember.py", line 219, in analyze_instance_member_access
  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

a.py:

class A:
	from b import foo

print(A().foo())  # ← INTERNAL ERROR here

b.py:

def foo(self):
	return ""

Your Environment

  • Mypy version used: 8e909e4
  • Mypy command-line flags: mypy --show-traceback a.py
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.9.5
  • Operating system and version: Arch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants