Skip to content
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

False positive "[TypedDict instance] is not callable" #4715

Closed
l0b0 opened this issue Jul 19, 2021 · 2 comments · Fixed by #4717
Closed

False positive "[TypedDict instance] is not callable" #4715

l0b0 opened this issue Jul 19, 2021 · 2 comments · Fixed by #4717
Assignees
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) typing
Milestone

Comments

@l0b0
Copy link

l0b0 commented Jul 19, 2021

Steps to reproduce

Given a file a.py:

from typing import TypedDict

Link = TypedDict("Link", {"href": str})
Link(href="foo")

Current behavior

Result of pylint a.py:

************* Module a
a.py:4:0: E1102: Link is not callable (not-callable)

------------------------------------
Your code has been rated at -6.67/10

Expected behavior

This should not be an error. TypedDict is a subclass of dict, so line 4 is equivalent to dict(href="foo"). The code also runs fine and passes mypy --strict a.py.

pylint --version output

Result of pylint --version output:

pylint 3.0.0-a4
astroid 2.6.2
Python 3.8.10 (default, Jul  7 2021, 14:29:06) 
[GCC 11.1.0]
@Pierre-Sassoulas Pierre-Sassoulas added the False Positive 🦟 A message is emitted but nothing is wrong with the code label Jul 19, 2021
@cdce8p cdce8p added Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) typing labels Jul 19, 2021
@cdce8p cdce8p self-assigned this Jul 19, 2021
@cdce8p
Copy link
Member

cdce8p commented Jul 19, 2021

Thanks for the bug report! I've opened PRs to address the issue.

You can work around it already though by using the "new" syntax instead.

from typing import TypedDict

class Link(TypedDict):
    href: str

Link(href="foo")

https://docs.python.org/3/library/typing.html#typing.TypedDict

@cdce8p cdce8p added this to the 2.9.4 milestone Jul 19, 2021
@l0b0
Copy link
Author

l0b0 commented Jul 19, 2021

You fixed it and taught me something new. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) typing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants