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

Add use-sequence-for-iteration checker #4835

Merged
merged 3 commits into from Aug 13, 2021

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Aug 12, 2021

Type of Changes

Type
✨ New feature

Description

Part of #4776 (comment)
It is more efficient to iterate over sequence types than sets.

# old
for x in {1, 2, 3}:  # [use-sequence-for-iteration]
    pass
# better
for x in (1, 2, 3):
    pass

@coveralls
Copy link

Pull Request Test Coverage Report for Build 1125844000

  • 10 of 10 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.004%) to 92.647%

Totals Coverage Status
Change from base Build 1125375963: 0.004%
Covered Lines: 13318
Relevant Lines: 14375

💛 - Coveralls

@cdce8p cdce8p marked this pull request as draft August 13, 2021 00:01
@cdce8p cdce8p added this to the 2.10.0 milestone Aug 13, 2021
@cdce8p cdce8p added the Enhancement ✨ Improvement to a component label Aug 13, 2021
@cdce8p
Copy link
Member Author

cdce8p commented Aug 13, 2021

@Pierre-Sassoulas This would be the first new check for #4776. What do you think?

--
My plan is to do a followup were I limit consider-using-tuple to only lists. That way we prevent double warnings. Especially considering use-sequence-for-iteration is enabled by default.

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.

LGTM !

@cdce8p cdce8p marked this pull request as ready for review August 13, 2021 17:33
@cdce8p cdce8p merged commit 61b4db0 into pylint-dev:main Aug 13, 2021
@cdce8p cdce8p deleted the feature-sequence_for_iteration branch August 13, 2021 17:34
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.

None yet

3 participants