# Buggy code
def check_method_override_for_base_with_name(
    self, defn: Union[FuncBase, Decorator], name: str, base: TypeInfo
) -> None:
    base_attr = base.names.get(name)
    if base_attr:
        # The name of the method is defined in the base class.

        # Point errors at the 'def' line (important for backward compatibility
        # of type ignores).
        if not isinstance(defn, Decorator):
            context = defn
        else:
            context = defn.func

        # Construct the type of the overriding method.
        if isinstance(defn, FuncBase):
            typ = self.function_type(defn)  # type: Type
            override_class_or_static = defn.is_class or defn.is_static
        else:
            assert defn.var.is_ready
            assert defn.var.type is not None
            typ = defn.var.type
            override_class_or_static = defn.func.is_class or defn.func.is_static
        if isinstance(typ, FunctionLike) and not is_static(context):
            typ = bind_self(typ, self.scope.active_self_type())
        # Map the overridden method type to subtype context so that
        # it can be checked for compatibility.
        original_type = base_attr.type
        original_node = base_attr.node
        if original_type is None:
            if isinstance(original_node, FuncBase):
                original_type = self.function_type(original_node)
            elif isinstance(original_node, Decorator):
                original_type = self.function_type(original_node.func)
            else:
                assert False, str(base_attr.node)
        if isinstance(original_node, FuncBase):
            original_class_or_static = original_node.is_class or original_node.is_static
        elif isinstance(original_node, Decorator):
            fdef = original_node.func
            original_class_or_static = fdef.is_class or fdef.is_static
        else:
            original_class_or_static = False  # a variable can't be class or static
        if isinstance(original_type, AnyType) or isinstance(typ, AnyType):
            pass
        elif isinstance(original_type, FunctionLike) and isinstance(typ, FunctionLike):
            if isinstance(
                base_attr.node, (FuncDef, OverloadedFuncDef, Decorator)
            ) and not is_static(base_attr.node):
                bound = bind_self(original_type, self.scope.active_self_type())
            else:
                bound = original_type
            original = map_type_from_supertype(bound, defn.info, base)
            # Check that the types are compatible.
            # TODO overloaded signatures
            self.check_override(
                typ,
                cast(FunctionLike, original),
                defn.name(),
                name,
                base.name(),
                original_class_or_static,
                override_class_or_static,
                context,
            )
        elif is_equivalent(original_type, typ):
            # Assume invariance for a non-callable attribute here. Note
            # that this doesn't affect read-only properties which can have
            # covariant overrides.
            #
            # TODO: Allow covariance for read-only attributes?
            pass
        else:
            self.msg.signature_incompatible_with_supertype(
                defn.name(), name, base.name(), context
            )


# Traceback (AssertionError)
pymc3/model.py:672: error: Decorated property not supported
pymc3/variational/opvi.py:1556: error: Decorated property not supported
pymc3/variational/flows.py:193: error: Decorated property not supported
pymc3/__init__.py:25: error: Name 'utils' already defined (by an import)
pymc3/data.py:226: error: Need type annotation for 'RNG'
Traceback (most recent call last):
File "/Users/rpg/Library/Python/3.7/bin/mypy", line 11, in <module>
sys.exit(console_entry())
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/__main__.py", line 7, in console_entry
main(None)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/main.py", line 91, in main
res = type_check_only(sources, bin_dir, options, flush_errors, fscache)  # noqa
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/main.py", line 148, in type_check_only
fscache=fscache)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/build.py", line 177, in build
flush_errors, fscache)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/build.py", line 350, in _build
graph = dispatch(sources, manager)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/build.py", line 2560, in dispatch
process_graph(graph, manager)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/build.py", line 2853, in process_graph
process_stale_scc(graph, scc, manager)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/build.py", line 2976, in process_stale_scc
graph[id].type_check_first_pass()
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/build.py", line 2151, in type_check_first_pass
self.type_checker().check_first_pass()
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/checker.py", line 253, in check_first_pass
self.accept(d)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/checker.py", line 352, in accept
stmt.accept(self)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/nodes.py", line 808, in accept
return visitor.visit_class_def(self)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/checker.py", line 1368, in visit_class_def
self.accept(defn.defs)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/checker.py", line 352, in accept
stmt.accept(self)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/nodes.py", line 873, in accept
return visitor.visit_block(self)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/checker.py", line 1514, in visit_block
self.accept(s)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/checker.py", line 352, in accept
stmt.accept(self)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/nodes.py", line 443, in accept
return visitor.visit_overloaded_func_def(self)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/checker.py", line 385, in visit_overloaded_func_def
self._visit_overloaded_func_def(defn)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/checker.py", line 409, in _visit_overloaded_func_def
self.check_method_override(defn)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/checker.py", line 1198, in check_method_override
self.check_method_or_accessor_override_for_base(defn, base)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/checker.py", line 1208, in check_method_or_accessor_override_for_base
self.check_method_override_for_base_with_name(defn, name, base)
File "/Users/rpg/Library/Python/3.7/lib/python/site-packages/mypy/checker.py", line 1252, in check_method_override_for_base_with_name
assert False, str(base_attr.node)
AssertionError: Var(sampler_vars)

# Fixed code
def check_method_override_for_base_with_name(
    self, defn: Union[FuncDef, OverloadedFuncDef, Decorator], name: str, base: TypeInfo
) -> bool:
    """Check if overriding an attribute `name` of `base` with `defn` is valid.

    Return True if the supertype node was not analysed yet, and `defn` was deferred.
    """
    base_attr = base.names.get(name)
    if base_attr:
        # The name of the method is defined in the base class.

        # Point errors at the 'def' line (important for backward compatibility
        # of type ignores).
        if not isinstance(defn, Decorator):
            context = defn
        else:
            context = defn.func

        # Construct the type of the overriding method.
        if isinstance(defn, (FuncDef, OverloadedFuncDef)):
            typ = self.function_type(defn)  # type: Type
            override_class_or_static = defn.is_class or defn.is_static
        else:
            assert defn.var.is_ready
            assert defn.var.type is not None
            typ = defn.var.type
            override_class_or_static = defn.func.is_class or defn.func.is_static
        if isinstance(typ, FunctionLike) and not is_static(context):
            typ = bind_self(typ, self.scope.active_self_type())
        # Map the overridden method type to subtype context so that
        # it can be checked for compatibility.
        original_type = base_attr.type
        original_node = base_attr.node
        if original_type is None:
            if self.pass_num < self.last_pass:
                # If there are passes left, defer this node until next pass,
                # otherwise try reconstructing the method type from available information.
                self.defer_node(defn, defn.info)
                return True
            elif isinstance(original_node, (FuncDef, OverloadedFuncDef)):
                original_type = self.function_type(original_node)
            elif isinstance(original_node, Decorator):
                original_type = self.function_type(original_node.func)
            else:
                assert False, str(base_attr.node)
        if isinstance(original_node, (FuncDef, OverloadedFuncDef)):
            original_class_or_static = original_node.is_class or original_node.is_static
        elif isinstance(original_node, Decorator):
            fdef = original_node.func
            original_class_or_static = fdef.is_class or fdef.is_static
        else:
            original_class_or_static = False  # a variable can't be class or static
        if isinstance(original_type, AnyType) or isinstance(typ, AnyType):
            pass
        elif isinstance(original_type, FunctionLike) and isinstance(typ, FunctionLike):
            if isinstance(
                base_attr.node, (FuncDef, OverloadedFuncDef, Decorator)
            ) and not is_static(base_attr.node):
                bound = bind_self(original_type, self.scope.active_self_type())
            else:
                bound = original_type
            original = map_type_from_supertype(bound, defn.info, base)
            # Check that the types are compatible.
            # TODO overloaded signatures
            self.check_override(
                typ,
                cast(FunctionLike, original),
                defn.name(),
                name,
                base.name(),
                original_class_or_static,
                override_class_or_static,
                context,
            )
        elif is_equivalent(original_type, typ):
            # Assume invariance for a non-callable attribute here. Note
            # that this doesn't affect read-only properties which can have
            # covariant overrides.
            #
            # TODO: Allow covariance for read-only attributes?
            pass
        else:
            self.msg.signature_incompatible_with_supertype(
                defn.name(), name, base.name(), context
            )
    return False