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

use-maxsplit-arg false positive when index is incremented inside a loop #4664

Closed
jacobtylerwalls opened this issue Jul 3, 2021 · 1 comment · Fixed by #4666
Closed

use-maxsplit-arg false positive when index is incremented inside a loop #4664

jacobtylerwalls opened this issue Jul 3, 2021 · 1 comment · Fixed by #4666
Assignees
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@jacobtylerwalls
Copy link
Member

Steps to reproduce

Given a file a.py:

source = 'A.B.C.D.E.F.G'
other_iterable = range(5)
i = 0
for j in other_iterable:
    print(source.split('.')[i])
    i += 1

Current behavior

Result of pylint a.py:

split.py:5: [C0207(use-maxsplit-arg), ] Use source.split('.', maxsplit=1)[0] instead

Expected behavior

no messages, since maxsplit=1 produces a different result.

pylint --version output

pylint 2.9.3
astroid 2.6.2
Python 3.8.10 (v3.8.10:3d8993a744, May  3 2021, 08:55:58) 
@yushao2 yushao2 self-assigned this Jul 3, 2021
@yushao2 yushao2 added the False Positive 🦟 A message is emitted but nothing is wrong with the code label Jul 3, 2021
@yushao2
Copy link
Collaborator

yushao2 commented Jul 3, 2021

Thanks for reporting this! I'm able to reproduce this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants