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

fix % in to f String #12405

Conversation

Aditya3425-Fst
Copy link

#12360
Summary:
This pull request addresses the conversion of "%" symbols into f-strings for improved readability and maintainability.

Changes Made:

Replaced "%" formatting with f-strings for string interpolation.
Updated relevant code blocks to adhere to the Python 3.6 and later syntax.
Benefits:

Enhanced code clarity: f-strings provide a more concise and readable syntax for string formatting.
Improved maintainability: The use of f-strings aligns with modern Python practices, making the codebase more up-to-date.
Testing:

Ensured that the changes do not introduce any functional issues.
Conducted thorough testing to validate the correctness of the converted f-strings.
Additional Notes:

No changes to the logic or functionality of the code, only a syntactic enhancement.
Compatible with Python 3.6 and later versions.

Please review the changes, and feel free to provide feedback or ask for further clarification if needed.

Copy link

welcome bot commented Jan 31, 2024

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴

@cbrnr
Copy link
Contributor

cbrnr commented Feb 2, 2024

Thanks for taking a stab! There are several things that should be addressed:

  1. Please remove the previous statements instead of commenting them out.
  2. Make sure no lines exceed 88 characters.
  3. If there is only one object to print, there is no need to keep the tuple (e.g. "%s" % (x,) should be f"{x}" and not f"{x,}").

Copy link
Member

@mscheltienne mscheltienne left a comment

Choose a reason for hiding this comment

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

Looking at the 2 first files, I'm spotting several typos in capital letters or spacing. Could you go through your proposed changes again and fix those first?

Comment on lines +269 to +270
# "Invalid parameter %s for estimator %s. "
f"Invalid parameter{name}for estimator{self}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# "Invalid parameter %s for estimator %s. "
f"Invalid parameter{name}for estimator{self}"
f"Invalid parameter {name} for estimator {self}. "

Comment on lines +197 to +198
# " %s with constructor %s doesn't "
f"{cls} with constructor {init_signature} doesn't follow this convention."
Copy link
Member

@mscheltienne mscheltienne Feb 5, 2024

Choose a reason for hiding this comment

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

Suggested change
# " %s with constructor %s doesn't "
f"{cls} with constructor {init_signature} doesn't follow this convention."
f" {cls} with constructor {init_signature} doesn't follow this convention."

Copy link
Member

Choose a reason for hiding this comment

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

There's also 2 spaces after "doesn't"

Copy link
Member

Choose a reason for hiding this comment

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

fixed in the suggested change.

Comment on lines +102 to +103
# warn("SVD error (%s), attempting to use GESVD instead of GESDD" % (exp,))
warn(f"SVD error ({exp}), attempting to use GESVD instend of GESDD")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# warn("SVD error (%s), attempting to use GESVD instead of GESDD" % (exp,))
warn(f"SVD error ({exp}), attempting to use GESVD instend of GESDD")
warn(f"SVD error ({exp}), attempting to use GESVD instend of GESDD")

Comment on lines +280 to +281
# "Invalid parameter %s for estimator %s. "
f"Invalid parameter {key}for estimator{self.__class__.__name__} for estimator"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# "Invalid parameter %s for estimator %s. "
f"Invalid parameter {key}for estimator{self.__class__.__name__} for estimator"
f"Invalid parameter {key} for estimator {self.__class__.__name__}. "

Comment on lines +293 to +294
# return "%s(%s)" % (class_name, self.__class__.__name__)
return f"{class_name}({self.__class__.__name__})"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# return "%s(%s)" % (class_name, self.__class__.__name__)
return f"{class_name}({self.__class__.__name__})"
return f"{class_name}({params.read().strip()})"

Comment on lines +664 to +665
# msg = "Coil too close (dist = %g mm)" % (min_dist * 1000,)
msg = f"coil too close (dist = {(min_dist * 1000,)}mm)"
Copy link
Member

Choose a reason for hiding this comment

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

This one does not remove the trailing zeroes as %g does.

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.

4 participants