Skip to content

NotImplemented is not callable #3315

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

Closed
ltworf opened this issue Oct 7, 2019 · 1 comment · Fixed by #4222
Closed

NotImplemented is not callable #3315

ltworf opened this issue Oct 7, 2019 · 1 comment · Fixed by #4222

Comments

@ltworf
Copy link
Contributor

ltworf commented Oct 7, 2019

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?

@srittau
Copy link
Collaborator

srittau commented Oct 7, 2019

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.

hauntsaninja pushed a commit to hauntsaninja/typeshed that referenced this issue Jun 11, 2020
JelleZijlstra pushed a commit that referenced this issue Jun 11, 2020
Fixes #3315

Co-authored-by: hauntsaninja <>
vishalkuo pushed a commit to vishalkuo/typeshed that referenced this issue Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants