Skip to content

consider-using-join raised for code equivalent to ", ".join("a", "b", "c") #6639

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

Closed
Pierre-Sassoulas opened this issue May 18, 2022 · 1 comment · Fixed by #7481
Closed
Labels
Enhancement ✨ Improvement to a component Good first issue Friendly and approachable by new contributors Hacktoberfest Help wanted 🙏 Outside help would be appreciated, good for new contributors High effort 🏋 Difficult solution or problem to solve Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented May 18, 2022

Current problem

For

result = ''
for number in ['1', '2', '3']:
    result += number  # [consider-using-join]

Where the final result would be "".join(['1', '2', '3']) we already raise a consider-using-join. Sometime function that could be join instead are sneakier, for example:

result = ''
for number in ['1', '2', '3']:
    result += f"{number}, "
result = result[:-2]

Could be ", ".join(['1', '2', '3']).

Desired solution

consider-using-join detecting possible join using a non-empty string.

@Pierre-Sassoulas Pierre-Sassoulas added Enhancement ✨ Improvement to a component Help wanted 🙏 Outside help would be appreciated, good for new contributors Good first issue Friendly and approachable by new contributors High effort 🏋 Difficult solution or problem to solve labels May 18, 2022
@Pierre-Sassoulas Pierre-Sassoulas changed the title consider-using-join raised for code equivalent to ", ".join("a", "b', "c") consider-using-join raised for code equivalent to ", ".join("a", "b", "c") May 18, 2022
@Scofield1
Copy link

Try this

a = ['1', '2', '3'] result = "".join(a) print(result)

@Pierre-Sassoulas Pierre-Sassoulas added the Needs PR This issue is accepted, sufficiently specified and now needs an implementation label Jun 24, 2022
lggruspe added a commit to lggruspe/pylint that referenced this issue Sep 20, 2022
@jacobtylerwalls jacobtylerwalls added this to the 2.16.0 milestone Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Good first issue Friendly and approachable by new contributors Hacktoberfest Help wanted 🙏 Outside help would be appreciated, good for new contributors High effort 🏋 Difficult solution or problem to solve Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants