I love f-strings. I just wish tools like pylint would shut up when I pass f-strings to the logging module. I as the developer understand and accept the extra nanosecond of processor time to parse the string that might not be logged anywhere!
Using percent formatting is superior in many ways:
- errors that occur in formatting a message will be logged instead of raising an exception into your application
- error reporting services like Sentry can properly aggregate events
- interpolation won't occur if you don't have the logging level enabled
- it's recommend by the Python docs: https://docs.python.org/3/howto/logging-cookbook.html#use-of...
if logger.isEnabledFor(logging.DEBUG):
logger.debug(f'{expensive_func()}')I don't want it to scream on a missing docstring for every single thing. I do want to be able to use a, b and x as variables. No, this root var is not a constant, don't ask me for uppercase. Etc.
$ pylint pylint_sucks_at_partials.py
************* Module pylint_sucks_at_partials
pylint_sucks_at_partials.py:7:0: C0103: Constant name
"add5" doesn't conform to UPPER_CASE naming style
(invalid-name)
The program in question: #!/usr/bin/env python
""" proving pylint still sucks at partials """
from functools import partial
from operator import add
add5 = partial(add, 5)
if __name__ == '__main__':
import sys
print(add5(int(sys.argv[1])))