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

chore: %-formatting to f-string #144

Merged
merged 4 commits into from
Feb 22, 2021
Merged

chore: %-formatting to f-string #144

merged 4 commits into from
Feb 22, 2021

Conversation

phanak-sap
Copy link
Contributor

Because we have minimal Python version listed as 3.6, we can safely move to PEP 498 -- Literal String Interpolation.

f-strings are less verbose, more powerful (it is expression, e.g. can call functions) and quicker than old school string formatters.

Converted using https://github.com/ikamensh/flynt

This one is basically a warning for potentional performance loss,
for scenarios when log message is not really logged. With 3 instances
of such problem in pyodata and the perf loss being neglegable, IMHO is better
to not mix old and new style of formatting. Therefore disabling the warning.

See more:
pylint-dev/pylint#2395
pylint-dev/pylint#1788
https://stackoverflow.com/questions/34619790/pylint-message-logging-format-interpolation
@codecov-io
Copy link

codecov-io commented Feb 20, 2021

Codecov Report

Merging #144 (9257753) into master (6a4eb3b) will not change coverage.
The diff coverage is 48.86%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #144   +/-   ##
=======================================
  Coverage   92.55%   92.55%           
=======================================
  Files           6        6           
  Lines        2660     2660           
=======================================
  Hits         2462     2462           
  Misses        198      198           
Impacted Files Coverage Δ
pyodata/v2/model.py 93.32% <40.27%> (ø)
pyodata/v2/service.py 90.47% <85.71%> (ø)
pyodata/client.py 100.00% <100.00%> (ø)
pyodata/vendor/SAP.py 100.00% <100.00%> (ø)

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 6a4eb3b...9257753. Read the comment docs.

@filak-sap
Copy link
Contributor

Hi Peter, thank you very much for the time to create this fabulous PR. Unfortunately I have a bad news for you - the linting rule should not be disabled but must be respected and log messages must not be formatted with f-strings. Yeah, neither format is correct - I did it wrong. However, I cannot approve this PR because of the second commit for disabling of the pylint rule.

@phanak-sap
Copy link
Contributor Author

phanak-sap commented Feb 22, 2021

Hi @filak-sap - so you prefer mixing of string formatting styles? It is easy to revert it back, but the "rule" is just a warning, perf effect of switching to f-string is negligible and the ball ("do it correctly") is actually on the standard logging library in this case. You can check the URLs from the commit message, I thought about the situation before the commit; one argument for disable was that we have already some rules disabled anyway... so I don't quite understand why this additional disabled rule should be a problem.

My view is that having all string formatted in the same way is consisted, cleaner and therefore more readable. If the performance loss would be any substantial, it would be also understandable to not disable, but this is not a case.

I see more of problem that currently the linter job does not fail if PR would have old-style formatting, so the mixing is still possible even after PR.

@jfilak
Copy link
Contributor

jfilak commented Feb 22, 2021

@jfilak
Copy link
Contributor

jfilak commented Feb 22, 2021

All is good, switch to f-string but don't turn off that warning and don't use f-strings in log mesages.

@phanak-sap
Copy link
Contributor Author

OK, done. Expected this to be squashed.

@filak-sap filak-sap merged commit 9a3694d into SAP:master Feb 22, 2021
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