-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[python] Migrate to f-strings in python-package/lightgbm/sklearn.py #4188
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
76c51de
Migrate to f-strings in python-package/lightgbm/sklearn.py
14f2b7e
Apply suggestions from code review
akshitadixit dadcd8a
Update python-package/lightgbm/sklearn.py
akshitadixit 66ea376
Apply suggestions from code review
akshitadixit 3a449e5
Add suggestions from code review
3795edc
Merge branch 'fstrings-patch-1' of https://github.com/akshitadixit/Li…
7c5836c
resolve conflicts
70c677d
Apply suggestions from code review
akshitadixit 968825b
Update sklearn.py
akshitadixit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the following lines within this PR as well
LightGBM/python-package/lightgbm/sklearn.py
Lines 535 to 536 in 211ef78
LightGBM/python-package/lightgbm/sklearn.py
Lines 997 to 998 in 211ef78
' ' * x
)LightGBM/python-package/lightgbm/sklearn.py
Line 655 in 211ef78
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@StrikerRUS do I only change the
' '*x
part or do I also modify the concatenation taking place there into an f-string as below?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally I thought about only
' '*x
part, but just saw that @jameslamb would prefer modifying concatenation as well: #4144 (comment). So, please modify it with concatenation.BTW, there are some other places where concatenation can be eliminated with f-strings:
LightGBM/python-package/lightgbm/sklearn.py
Lines 705 to 711 in 211ef78
LightGBM/python-package/lightgbm/sklearn.py
Lines 825 to 831 in 211ef78
LightGBM/python-package/lightgbm/sklearn.py
Lines 898 to 902 in 211ef78
LightGBM/python-package/lightgbm/sklearn.py
Lines 990 to 992 in 211ef78
But I don't think we should replace concatenation with f-strings there because concatenation is more readable in those cases in my opinion. @jameslamb WDYT?
Also, please check the following comment about padding #4144 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I agree with you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I infer that no concatenations be migrated then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, cases like the ones @StrikerRUS mentioned (where
.format()
was used to replace a shared template like_lgbmmodel_doc_fit
or where there are just variables being added to each other but not string literals) do not need to be changed for this pull request