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

If .mypy_cache exists "AttributeError: attribute 'mro' of 'TypeInfo' undefined" #14353

Closed
JMarkin opened this issue Dec 28, 2022 · 0 comments · Fixed by #14885
Closed

If .mypy_cache exists "AttributeError: attribute 'mro' of 'TypeInfo' undefined" #14353

JMarkin opened this issue Dec 28, 2022 · 0 comments · Fixed by #14885

Comments

@JMarkin
Copy link

JMarkin commented Dec 28, 2022

Crash Report

If .mypy_cache doesn't exists mypy . works, but every next run when .mypy_cache exists give me AttributeError.
Master branch has with problem.

Traceback

mypy_reproduce/__init__.py:31: error: Argument 2 to "Use" has incompatible type "List[str]"; expected "SupportsLenAndGetItem[_T]"  [arg-type]
./mypy_reproduce/__init__.py:37: 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.991
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 4665, in accept
  File "mypy/nodes.py", line 1841, in accept
  File "mypy/checkexpr.py", line 410, in visit_call_expr
  File "mypy/checkexpr.py", line 530, in visit_call_expr_inner
  File "mypy/checkexpr.py", line 1181, in check_call_expr_with_callee_type
  File "mypy/checkexpr.py", line 1264, in check_call
  File "mypy/checkexpr.py", line 1406, in check_callable_call
  File "mypy/checkexpr.py", line 1731, in infer_function_type_arguments
  File "mypy/checkexpr.py", line 1788, in infer_function_type_arguments_pass2
  File "mypy/infer.py", line 54, in infer_function_type_arguments
  File "mypy/constraints.py", line 147, in infer_constraints_for_callable
  File "mypy/constraints.py", line 190, in infer_constraints
  File "mypy/constraints.py", line 269, in _infer_constraints
  File "mypy/types.py", line 1792, in accept
  File "mypy/constraints.py", line 982, in visit_callable_type
  File "mypy/constraints.py", line 1006, in infer_against_overloaded
  File "mypy/constraints.py", line 1140, in find_matching_overload_item
  File "mypy/subtypes.py", line 1376, in is_callable_compatible
  File "mypy/subtypes.py", line 1655, in unify_generic_callable
  File "mypy/constraints.py", line 187, in infer_constraints
  File "mypy/constraints.py", line 269, in _infer_constraints
  File "mypy/types.py", line 1283, in accept
  File "mypy/constraints.py", line 865, in visit_instance
  File "mypy/constraints.py", line 187, in infer_constraints
  File "mypy/constraints.py", line 269, in _infer_constraints
  File "mypy/types.py", line 1283, in accept
  File "mypy/constraints.py", line 702, in visit_instance
  File "mypy/nodes.py", line 2991, in has_base
AttributeError: attribute 'mro' of 'TypeInfo' undefined
./mypy_reproduce/__init__.py:37: : note: use --pdb to drop into pdb

mypy_reproduce/__init__.py:31: error: Argument 2 to "Use" has incompatible type "List[str]"; expected "SupportsLenAndGetItem[_T]"  [arg-type]
./mypy_reproduce/__init__.py:37: 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: 1.0.0+dev.632304f90923ba38483d94de3cf58d486966f4f0
Traceback (most recent call last):
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry
    main()
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/main.py", line 95, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/main.py", line 174, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/build.py", line 194, in build
    result = _build(
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/build.py", line 277, in _build
    graph = dispatch(sources, manager, stdout)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/build.py", line 2920, in dispatch
    process_graph(graph, manager)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/build.py", line 3317, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/build.py", line 3418, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/build.py", line 2317, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checker.py", line 472, in check_first_pass
    self.accept(d)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checker.py", line 580, in accept
    stmt.accept(self)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/nodes.py", line 1121, in accept
    return visitor.visit_class_def(self)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checker.py", line 2154, in visit_class_def
    self.accept(defn.defs)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checker.py", line 580, in accept
    stmt.accept(self)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/nodes.py", line 1202, in accept
    return visitor.visit_block(self)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checker.py", line 2593, in visit_block
    self.accept(s)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checker.py", line 580, in accept
    stmt.accept(self)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/nodes.py", line 1289, in accept
    return visitor.visit_assignment_stmt(self)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checker.py", line 2641, in visit_assignment_stmt
    self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checker.py", line 2845, in check_assignment
    rvalue_type = self.expr_checker.accept(rvalue, type_context=type_context)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checkexpr.py", line 4777, in accept
    typ = node.accept(self)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/nodes.py", line 1871, in accept
    return visitor.visit_call_expr(self)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checkexpr.py", line 424, in visit_call_expr
    return self.visit_call_expr_inner(e, allow_none_return=allow_none_return)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checkexpr.py", line 544, in visit_call_expr_inner
    ret_type = self.check_call_expr_with_callee_type(
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checkexpr.py", line 1195, in check_call_expr_with_callee_type
    ret_type, callee_type = self.check_call(
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checkexpr.py", line 1278, in check_call
    return self.check_callable_call(
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checkexpr.py", line 1431, in check_callable_call
    callee = self.infer_function_type_arguments(
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checkexpr.py", line 1761, in infer_function_type_arguments
    (callee_type, inferred_args) = self.infer_function_type_arguments_pass2(
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/checkexpr.py", line 1818, in infer_function_type_arguments_pass2
    inferred_args = infer_function_type_arguments(
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/infer.py", line 54, in infer_function_type_arguments
    constraints = infer_constraints_for_callable(
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/constraints.py", line 171, in infer_constraints_for_callable
    c = infer_constraints(callee.arg_types[i], actual_type, SUPERTYPE_OF)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/constraints.py", line 214, in infer_constraints
    return _infer_constraints(template, actual, direction)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/constraints.py", line 293, in _infer_constraints
    return template.accept(ConstraintBuilderVisitor(actual, direction))
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/types.py", line 1831, in accept
    return visitor.visit_callable_type(self)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/constraints.py", line 1011, in visit_callable_type
    return self.infer_against_overloaded(self.actual, template)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/constraints.py", line 1035, in infer_against_overloaded
    item = find_matching_overload_item(overloaded, template)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/constraints.py", line 1169, in find_matching_overload_item
    if mypy.subtypes.is_callable_compatible(
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/subtypes.py", line 1386, in is_callable_compatible
    unified = unify_generic_callable(left, right, ignore_return=ignore_return)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/subtypes.py", line 1670, in unify_generic_callable
    c = mypy.constraints.infer_constraints(
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/constraints.py", line 211, in infer_constraints
    res = _infer_constraints(template, actual, direction)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/constraints.py", line 293, in _infer_constraints
    return template.accept(ConstraintBuilderVisitor(actual, direction))
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/types.py", line 1319, in accept
    return visitor.visit_instance(self)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/constraints.py", line 892, in visit_instance
    return infer_constraints(template, actual.upper_bound, self.direction)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/constraints.py", line 211, in infer_constraints
    res = _infer_constraints(template, actual, direction)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/constraints.py", line 293, in _infer_constraints
    return template.accept(ConstraintBuilderVisitor(actual, direction))
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/types.py", line 1319, in accept
    return visitor.visit_instance(self)
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/constraints.py", line 727, in visit_instance
    elif self.direction == SUPERTYPE_OF and instance.type.has_base(template.type.fullname):
  File "/var/cache/kron-cache/pypoetry/virtualenvs/mypy-reproduce-vVFCMVnz-py3.10/lib/python3.10/site-packages/mypy/nodes.py", line 3313, in __getattribute__
    raise AssertionError(object.__getattribute__(self, "msg"))
AssertionError: De-serialization failure: TypeInfo not fixed
./mypy_reproduce/__init__.py:37: : note: use --pdb to drop into pdb

To Reproduce
https://github.com/JMarkin/mypy_reproduce

Your Environment

  • Mypy version used: 0.991 and 1.0.0+dev.632304f90923ba38483d94de3cf58d486966f4f0
  • Mypy command-line flags: empty
  • Mypy configuration options from mypy.ini (and other config files): empty
  • Python version used: Python 3.10.9
  • Operating system and version: Linux 6.0.6-xanmod1-1
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.

3 participants