Skip to content

Permit subscripting additional builtin classes - #1572

Merged
jacobtylerwalls merged 3 commits into
pylint-dev:mainfrom
jacobtylerwalls:enumerate-subscript
May 23, 2022
Merged

jacobtylerwalls merged 3 commits into
pylint-dev:mainfrom
jacobtylerwalls:enumerate-subscript

Conversation

@jacobtylerwalls

@jacobtylerwalls jacobtylerwalls commented May 22, 2022 •

Copy link
Copy Markdown
Member

Description

Treat other classes such as enumerate and staticmethod identically to list, dict, tuple, set, frozenset.

>>> enumerate[2]  # not sure why, but...
enumerate[2]
>>> type(enumerate[2])
<class 'types.GenericAlias'>

Type of Changes

Type
✓ ✨ New feature

Related Issue

Noticed while working on #1567.

Treat other clasess such as enumerate and staticmethod identically to list, dict, tuple, set, frozenset.
@jacobtylerwalls jacobtylerwalls added this to the 2.12.0 milestone May 22, 2022
@coveralls

coveralls commented May 22, 2022 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 2371212303

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 91.907%

Files with Coverage Reduction New Missed Lines %
astroid/nodes/scoped_nodes/scoped_nodes.py 1 92.4%
astroid/interpreter/_import/spec.py 3 98.25%
Totals Coverage Status
Change from base Build 2367082861: 0.02%
Covered Lines: 9221
Relevant Lines: 10033

💛 - Coveralls

@jacobtylerwalls jacobtylerwalls added the Enhancement ✨ Improvement to a component label May 22, 2022
@jacobtylerwalls jacobtylerwalls mentioned this pull request May 23, 2022
2 tasks done

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@DanielNoord

Copy link
Copy Markdown
Collaborator

Not sure if we should call this "dubious". Seems to be a conscious decision, see:
python/cpython#83662 and python/cpython#19421

Strangely I don't see enumerate discussed in the PEP so perhaps this is indeed "dubious" I don't know.

Comment thread ChangeLog Outdated
Comment thread tests/unittest_brain.py Outdated
@jacobtylerwalls
jacobtylerwalls merged commit 8d5cefa into pylint-dev:main May 23, 2022
@jacobtylerwalls
jacobtylerwalls deleted the enumerate-subscript branch May 23, 2022 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement ✨ Improvement to a component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants