Skip to content

No warning for instantiating abstract class in function #9207

Closed
@Holt59

Description

@Holt59
  • Are you reporting a bug, or opening a feature request?

BUG

  • Please insert below the code you are checking with mypy,
import abc

class A(abc.ABC):
    @abc.abstractmethod
    def f(self): pass

# Cannot instantiate abstract class 'A' with abstract attribute 'f'
a = A()

# Cannot instantiate abstract class 'A' with abstract attribute 'f'
al = lambda: A()

# No warnings
def af():
    return A()

https://mypy-play.net/?mypy=latest&python=3.8&gist=fbc0513ec90bda028634ade70ff698e2

  • What is the actual behavior/output?

See comments above.

  • What is the behavior/output you expect?

I expect the "Cannot instantiate abstract class [...]" warning in all three cases.

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