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

Improve brain for typing.Callable + typing.Type #1192

Merged
merged 2 commits into from
Sep 29, 2021

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Sep 28, 2021

Description

Similar to typing.Tuple - typing.Callable is a special alias as well. Added some brain logic to help infer it correctly.

Type of Changes

Type
βœ“ πŸ› Bug fix

Related Issue

Ref: pylint-dev/pylint#3507 (comment)
Ref: pylint-dev/pylint#5087
Pylint PR with additional tests: pylint-dev/pylint#5089
Pylint PR for additional typing tests: pylint-dev/pylint#5090

@cdce8p cdce8p changed the title Improve inferrence of typing.Callable Improve brain for typing.Callable + typing.Type Sep 28, 2021
@@ -232,9 +232,7 @@ def _looks_like_typing_alias(node: Call) -> bool:
and node.func.name == "_alias"
and (
# _alias function works also for builtins object such as list and dict
isinstance(node.args[0], Attribute)
or isinstance(node.args[0], Name)
and node.args[0].name != "type"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed that type was excluded as well. This was originally added with #921, I couldn't however find a good reason to keep it that way. It works as expected even for type. Could be that the type brain improved since then, idk.

I did run the acceptance test that caused headaches a while back. Worked without problems.

pytest -m acceptance -k "test_libmodule[typing.py]"

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup alongside the fix !

@cdce8p cdce8p merged commit 795cb78 into pylint-dev:main Sep 29, 2021
@cdce8p cdce8p deleted the brain_typing-callable branch September 29, 2021 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Brain 🧠 Needs a brain tip
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants