You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
consider-using-f-string produces worse quality code in some cases, for example consider the following format string:
"Timing of '{name}' took {secs}s/{total_secs}s (started {start_time})".format(
name=name,
secs=delta.total_seconds(),
total_secs=self._config.timeout_seconds,
start_time=self._start_time.strftime("%H:%M:%S %Z").strip(),
)
Any variant of using an f-string to remove the consider-using-f-string warning does one of the following:
causes more local variables to be created (possibly blowing the max-locals limit)
is less readable (as the context of what the pieces are intended for is lost, e.g. took {secs}s/{total_secs}s is significantly more readable than took {delta.total_seconds()}s/{self._config.timeout_seconds}s
splits the context over multiple lines, making it harder to read the context
Thank you for searching for other issue related to that @doublethefish 😄. For reference if someone happen to see this issue following a search, in the example given it's possible to do:
template="Timing of '{name}' took {secs}s/{total_secs}s (started {start_time})"template.format(
name=name,
secs=delta.total_seconds(),
total_secs=self._config.timeout_seconds,
start_time=self._start_time.strftime("%H:%M:%S %Z").strip(),
)
Bug description
consider-using-f-string
produces worse quality code in some cases, for example consider the following format string:Any variant of using an f-string to remove the
consider-using-f-string
warning does one of the following:took {secs}s/{total_secs}s
is significantly more readable thantook {delta.total_seconds()}s/{self._config.timeout_seconds}s
Configuration
No response
Command used
Pylint output
Expected behavior
Only emit the warning for invocations of str.format that are below a certain complexity i.e. 5 parameters.
Additionally only emit the warning when the conformed string is
Pylint version
OS / Environment
n/a but
Alpine Linux 9b0fb0d01a22 5.10.47-linuxkit #1 SMP PREEMPT Sat Jul 3 21:50:16 UTC 2021 aarch64 Linux
bash
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: