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

BF: RF f-string uses in logger to %-interpolations #6886

Merged
merged 1 commit into from
Jul 26, 2022

Conversation

yarikoptic
Copy link
Member

f-strings should not be used for logger since if any of the .format-ed
content contains some %, it would then be incorrectly or causing a crash
%-polated by the logger. Although some of the "fixed" cases would be ok
(we know that it was an int etc) for consistency and to avoid needed
"is this particular use safe?" checks, better to avoid f-strings in
logger in general

@yarikoptic yarikoptic added the semver-internal Changes only affect the internal API label Jul 24, 2022
@codecov
Copy link

codecov bot commented Jul 24, 2022

Codecov Report

Merging #6886 (564027c) into maint (b0500a5) will increase coverage by 0.95%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##            maint    #6886      +/-   ##
==========================================
+ Coverage   90.25%   91.21%   +0.95%     
==========================================
  Files         354      354              
  Lines       46116    46116              
==========================================
+ Hits        41622    42064     +442     
+ Misses       4494     4052     -442     
Impacted Files Coverage Δ
datalad/cmd.py 94.09% <80.00%> (ø)
datalad/runner/runnerthreads.py 97.45% <100.00%> (ø)
datalad/tests/utils.py 66.76% <0.00%> (+9.73%) ⬆️
datalad/tests/test_tests_utils.py 92.34% <0.00%> (+92.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b0500a5...564027c. Read the comment docs.

Copy link
Member

@mih mih left a comment

Choose a reason for hiding this comment

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

I agree. The performance aspect is also not to be forgotten.

datalad/cmd.py Outdated
self.return_code = self.generator.return_code
self.runner = None

except CommandError as command_error:
# The command exited with a non-zero return code
lgr.error(f"{self}: command error: {command_error}")
lgr.error("%s: command error: command_error", self, command_error)
Copy link
Member Author

Choose a reason for hiding this comment

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

dang, I did I screw up here, travis picked it up in https://app.travis-ci.com/github/datalad/datalad/jobs/577595841#L3864

f-strings should not be used for logger since if any of the .format-ed
content contains some %, it would then be incorrectly or causing a crash
%-polated by the logger.  Although some of the "fixed" cases would be ok
(we know that it was an int etc) for consistency and to avoid needed
"is this particular use safe?" checks, better to avoid f-strings in
logger in general
@yarikoptic yarikoptic force-pushed the bf-no-f-strings-logger branch from b5edd7c to 564027c Compare July 25, 2022 13:28
@yarikoptic yarikoptic merged commit c3a77fa into datalad:maint Jul 26, 2022
@yarikoptic yarikoptic deleted the bf-no-f-strings-logger branch October 14, 2022 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-internal Changes only affect the internal API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants