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

string_processing: Handle overloaded operators when splitting long strings #2334

Open
bbugyi200 opened this issue Jun 13, 2021 · 4 comments
Open
Labels
C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. F: linebreak How should we split up lines? F: strings Related to our handling of strings S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: enhancement New feature or request

Comments

@bbugyi200
Copy link
Contributor

I'm not sure how often pathlib.Path is used with the augmented assignment operator rather than the regular one (/) nor do I know how often the string would be long enough that it would need to be split but all that aside, /= can definitely appear with strings on the right-hand of the assignment operator too:

from pathlib import Path
x = Path.cwd()
x /= "directory/subdirectory/file.txt"

Originally posted by @jack1142 in #2312 (comment)

@bbugyi200 bbugyi200 changed the title I'm not sure how often pathlib.Path is used with the augmented assignment operator rather than the regular one (/) nor do I know how often the string would be long enough that it would need to be split but all that aside, /= can definitely appear with strings on the right-hand of the assignment operator too: Handle overloaded operators when splitting long strings Jun 13, 2021
@felix-hilden felix-hilden added F: linebreak How should we split up lines? F: strings Related to our handling of strings T: enhancement New feature or request labels Jun 13, 2021
@felix-hilden
Copy link
Collaborator

Thanks for reporting! I think since these keep coming, we ought to consider the full set of possible operators.

@bbugyi200
Copy link
Contributor Author

bbugyi200 commented Jun 13, 2021

@jack1142 Raises a good point here. This issue of no current support for long string splitting with the /= operator extends to many other operators that are not traditionally supported by strings. In other words, since essentially any operator can be overloaded to support strings, we need to support them all.

@bbugyi200
Copy link
Contributor Author

@felix-hilden Beat me by 19 seconds ;).

@ichard26 ichard26 added the S: accepted The changes in this design / enhancement issue have been accepted and can be implemented label Jun 13, 2021
@JelleZijlstra
Copy link
Collaborator

To be more concrete, the problem here is:

% black --line-length=20  --preview -c 'x /= "directory subdirectory file.txt"'
x /= "directory subdirectory file.txt"

This should split up the string literal to make it fit in 20 characters.

@JelleZijlstra JelleZijlstra added the C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. label Dec 19, 2022
@JelleZijlstra JelleZijlstra changed the title Handle overloaded operators when splitting long strings string_processing: Handle overloaded operators when splitting long strings Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. F: linebreak How should we split up lines? F: strings Related to our handling of strings S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants