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

Detect inline implicit string concatenation #435

Closed
wants to merge 13 commits into from

Conversation

r-downing
Copy link
Contributor

As specified here #156 - this adds a check for inline implicit string concatenation as a new error B036

E.g.

["a", "b" "c"]

becomes

["a", "bc"]

This grabs the segment of the original source and parses it with libcst to see if it's a ConcatenatedString. Had to modify some unittests that manually fed in the AST to also feed in the source lines.

bugbear.py Outdated Show resolved Hide resolved
bugbear.py Outdated Show resolved Hide resolved
@cooperlees
Copy link
Collaborator

My only worry here is libcst is a big depedency to add ... We been light on (and could prob remove attrs with dataclasses these days - but I forget what we use) dependencies on purpose and wanted to be a pure python project for runtime simplicity. libcst is compiled but the right library for this job none the less.

I'd like to see how other contributors + maintainers feel about bringing this dependency in. It brings in many benefits, but now could slow our move to new Python runtimes and brings in the potential for people having wheel install issues + build the extension etc. etc.

@JelleZijlstra
Copy link
Collaborator

I agree with your intuition that it's better to keep flake8-bugbear pure Python. It's good to minimize dependencies.

We could reconsider if there are more lints that we want to add but that are only achievable with libcst.

@cooperlees
Copy link
Collaborator

Is there a feasible pure python way to implement these checks? If not, I think we should close this PR. I thank you for the efforts tho. Jelle and I (plus other maintainers) bear the pain of black and other projects having compiled dependencies. They lead to a lot of Issues opened. As it's really just me and Jelle here, I'd like to avoid that overhead.

I wonder if someone has started a dedicated libcst based flake8-plugin so people can choose a compiled plugin if they want. If so, maybe the check can go there.

@r-downing r-downing closed this Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants