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

Fix for py39 - unsubscriptable-object #3905

Closed
wants to merge 2 commits into from
Closed

Fix for py39 - unsubscriptable-object #3905

wants to merge 2 commits into from

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Oct 18, 2020

Description

This PR fixes an issue where typing.Optional and typing.Union where falsely flagged with unsubscriptable-object.

This error seems to be the result of a changed inference value:

# py38
Instance of typing._SpecialForm

# py39
FunctionDef.Union(...)
FunctionDef.Optional(...)

Since I'm new to pylint, this might not be the best place to fix it and I saw that #3894 also addresses this issue in a different spot. Please let me know if I should change something or if you like to continue with the other PR.

Steps

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature or an important bug fix, add a What's New entry in doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

Related Issue

Closes: #3882
This PR partially addresses #3895

@coveralls
Copy link

coveralls commented Oct 18, 2020

Coverage Status

Coverage decreased (-0.006%) to 90.832% when pulling be3230a on cdce8p:fix-py39-unsubscriptable-object into fed4438 on PyCQA:master.

@JulienPalard
Copy link
Contributor

I had another take on this one here: #3890 but it's my 1st contrib to pylint, I don't know which one is better.

* Error occurred for typing.Optional and typing.Union
@amyreese
Copy link

I think the solution in #3890 is a more correct fix, and resolves this for more than just typing.Optional and typing.Union.

@cdce8p
Copy link
Member Author

cdce8p commented Oct 29, 2020

@jreese I'm fine with that, as long as the issue is solved 😄 Please close this PR if you don't need it anymore

@hippo91
Copy link
Contributor

hippo91 commented Oct 30, 2020

@cdce8p thanks for your submission. IMHO the PR #3890 is indeed a more correct fix for the problem. That's why i close this PR but once again thanks for your work and please do not hesitate to submit another one. We need volunteers!

@hippo91 hippo91 closed this Oct 30, 2020
@hippo91 hippo91 self-assigned this Oct 30, 2020
@cdce8p cdce8p deleted the fix-py39-unsubscriptable-object branch October 30, 2020 23:25
@ssbarnea
Copy link
Contributor

While this bugs seams closed, the sad reality is that the last release was 6 months ago, so py39 users cannot benefit from the bugs fix.

Any change to tag a new release?

@hippo91
Copy link
Contributor

hippo91 commented Dec 12, 2020

@ssbarnea we are working on it. By the way the last pylint release was only 4 months ago.

@ssbarnea
Copy link
Contributor

@hippo91 Thanks for the update and please excuse my bad math, there were quite long months for most of us.

The problems I am facing is that these error reproduce only on py39 but that is more and more popular and because I use pre-commit (tool, not hook), I do not have any way to restrict which python version it will use when running on developer machine. The result is an unpredictable behavior with no know temporary workaround.

If the fix is already on master adding a pre-release tag would enable pre-commit users to bump it without even having a full release. In fact it may be possible to do something without a tag but is very ugly, it requires putting a specific revision instead of a tag for version.

@hippo91
Copy link
Contributor

hippo91 commented Dec 13, 2020

@ssbarnea no worry about the previous release date.
The fix concerning this problem has indeed been merged but there are still other bugs to deal with in order to make pylint compatible with python3.9. Fortunately those bugs have corresponding PR so, theoretically it wont be too long before the new release.

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 this pull request may close these issues.

[Python 3.9] Value 'Optional' is unsubscriptable (unsubscriptable-object) (also Union)
6 participants