Skip to content

NotImplemented is not callable #3315

Closed

Description

@ltworf

I'm aware of this python/mypy#6710

I understand the points raised here python/mypy#6710

However the current issue is that

raise NotImplemented()

seems perfectly valid to mypy when in fact it isn't, since it's not callable.

So basically, it should have been a NotImplementedError but mypy didn't find it (I found it with pyflakes).

Do you think it is possible to make it an almost-but-non-callable-Any?

Otherwise it could perhaps be mypy to warn about odd uses?

Activity

  1. srittau commented on Oct 7, 2019

    @srittau
    Collaborator

    We could try to make NotImplemented a sub-class of Any and override __call__():

    from typing import Any
    
    class NotImplemented(Any):
        __call__: None
        
    def bar() -> str:
        return NotImplemented()
    
    x: NotImplemented
    x()
    

    Not very elegant and the error message is not correct, but maybe better than nothing?


    Typo in bar(). Does not work.

  2. added a commit that references this issue on Jun 11, 2020
    d17e364
  3. added a commit that references this issue on Jun 11, 2020
    ecb4314
  4. added a commit that references this issue on Jun 26, 2020
    be9196d
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