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

[python] added f-strings to helpers/parameter_generator.py #4146

Merged
merged 7 commits into from
May 12, 2021
Merged

[python] added f-strings to helpers/parameter_generator.py #4146

merged 7 commits into from
May 12, 2021

Conversation

NovusEdge
Copy link
Contributor

No description provided.

@NovusEdge
Copy link
Contributor Author

#4136

@jameslamb jameslamb requested review from jameslamb and removed request for guolinke March 30, 2021 17:42
@jameslamb jameslamb changed the title added f-strings to helpers/parameter_generator.py [python] added f-strings to helpers/parameter_generator.py May 11, 2021
@jameslamb
Copy link
Collaborator

I merged in the latest changes from the master branch to this PR tonight, following the steps described in #4144 (review).

I also patched a few small mistakes in 63ebdaf.

Importantly, the linting errors observed in #4146 (comment) were a result of incorrect escaping of literal curly braces. I learned tonight, from https://docs.python.org/3/library/string.html#format-string-syntax, that you should use a {{ to indicate a literal { (and }} for a literal }) in an f-string.

x = "hello"
f"{x}, {{curly braces}}"

# 'hello, {curly braces}'

I also ran python helpers/parameter_generator.py to be sure that the changes don't change the output produced by that script.

@StrikerRUS I think this is now ready for review.

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good to me, but since I added a few changes I don't think my approval should count towards a merge.

helpers/parameter_generator.py Show resolved Hide resolved
helpers/parameter_generator.py Outdated Show resolved Hide resolved
helpers/parameter_generator.py Outdated Show resolved Hide resolved
helpers/parameter_generator.py Outdated Show resolved Hide resolved
helpers/parameter_generator.py Outdated Show resolved Hide resolved
helpers/parameter_generator.py Outdated Show resolved Hide resolved
helpers/parameter_generator.py Outdated Show resolved Hide resolved
helpers/parameter_generator.py Outdated Show resolved Hide resolved
helpers/parameter_generator.py Outdated Show resolved Hide resolved
helpers/parameter_generator.py Outdated Show resolved Hide resolved
@StrikerRUS
Copy link
Collaborator

Ah, missed one suggestion:

str_to_write += " std::string tmp_str = \"\";\n"

This string is not needed to be converted into f-string. But I think we can change outer " quotes to ' ones to remove escaping in this PR.

jameslamb and others added 4 commits May 11, 2021 13:16
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
@jameslamb
Copy link
Collaborator

Ah, missed one suggestion:

str_to_write += " std::string tmp_str = \"\";\n"

This string is not needed to be converted into f-string. But I think we can change outer " quotes to ' ones to remove escaping in this PR.

ok. Updated in 62f3380

@StrikerRUS StrikerRUS merged commit 8937022 into microsoft:master May 12, 2021
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants