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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,5 @@ contributors:
* Joshua Cannon: contributor

* Giuseppe Valente: contributor

* cdce8p: contributor
4 changes: 3 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Release date: TBA
* Fix bug that lead to duplicate messages when using ``--jobs 2`` or more.

Close #3584

* Adds option ``check-protected-access-in-special-methods`` in the ClassChecker to activate/deactivate
``protected-access`` message emission for single underscore prefixed attribute in special methods.

Expand Down Expand Up @@ -62,6 +62,8 @@ Release date: TBA

* Fix minor documentation issues

* Fix false-positive ``unsubscriptable-object`` message for ``typing.Union`` and ``typing.Optional``. Closes #3882

What's New in Pylint 2.6.0?
===========================

Expand Down
2 changes: 2 additions & 0 deletions doc/whatsnew/2.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ Other Changes
* Fix vulnerable regular expressions in ``pyreverse``. The ambiguities of vulnerable regular expressions are removed, making the repaired regular expressions safer and faster matching.

.. _the migration guide in isort documentation: https://timothycrosley.github.io/isort/docs/upgrade_guides/5.0.0/#known_standard_library

* Fix false-positive ``unsubscriptable-object`` message for ``typing.Union`` and ``typing.Optional``. Closes #3882
3 changes: 3 additions & 0 deletions pylint/checkers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,9 @@ def _supports_protocol(
return True
if protocol_callback(value):
return True
if isinstance(value, astroid.FunctionDef):
if value.name in ("Optional", "Union"):
return True

if (
isinstance(value, _bases.Proxy)
Expand Down