Skip to content

Mypy internal error with attrs frozen classes with property overrides attribute #7918

Closed

Description

@ibrque

Bug:

import attr

@attr.s(frozen=False)
class A:
    x: int = attr.ib(init=False)

@attr.s(frozen=True)
class B(A):
    @property
    def x(self) -> int:
        return 2
  • I got error: INTERNAL ERROR
  • I expect run mypy without internal errors

python 3.6.8
mypy version: 0.750+dev.84126ab9985844d8cda3809688034af895fdaf7c

  • mypy flags
ignore_missing_imports = True
disallow_incomplete_defs = True
disallow_untyped_calls = True
disallow_untyped_defs = False
  • Traceback
Traceback (most recent call last):
  File "mypy", line 10, in <module>
    sys.exit(console_entry())
  File "mypy/__main__.py", line 8, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "mypy/main.py", line 93, in main
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "mypy/build.py", line 167, in build
    sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr, extra_plugins
  File "mypy/build.py", line 235, in _build
    graph = dispatch(sources, manager, stdout)
  File "mypy/build.py", line 2620, in dispatch
    process_graph(graph, manager)
  File "mypy/build.py", line 2929, in process_graph
    process_stale_scc(graph, scc, manager)
  File "mypy/build.py", line 3022, in process_stale_scc
    mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
  File "mypy/semanal_main.py", line 77, in semantic_analysis_for_scc
    process_top_levels(graph, scc, patches)
  File "mypy/semanal_main.py", line 202, in process_top_levels
    patches)
  File "mypy/semanal_main.py", line 330, in semantic_analyze_target
    active_type=active_type)
  File "mypy/semanal.py", line 378, in refresh_partial
    self.refresh_top_level(node)
  File "mypy/semanal.py", line 389, in refresh_top_level
    self.accept(d)
  File "mypy/semanal.py", line 4639, in accept
    node.accept(self)
  File "mypy/nodes.py", line 927, in accept
    return visitor.visit_class_def(self)
  File "mypy/semanal.py", line 1022, in visit_class_def
    self.analyze_class(defn)
  File "mypy/semanal.py", line 1099, in analyze_class
    self.analyze_class_body_common(defn)
  File "mypy/semanal.py", line 1108, in analyze_class_body_common
    self.apply_class_plugin_hooks(defn)
  File "mypy/semanal.py", line 1154, in apply_class_plugin_hooks
    hook(ClassDefContext(defn, decorator, self))
  File "mypy/plugins/attrs.py", line 295, in attr_class_maker_callback
    _make_frozen(ctx, attributes)
  File "mypy/plugins/attrs.py", line 627, in _make_frozen
    assert isinstance(node, Var)
AssertionError: 

Activity

  1. ilevkivskyi commented on Nov 10, 2019

    @ilevkivskyi
    Member

    I think this is actually a duplicate of #6715 (although the original code is a bit different).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions