Lint `f` strings better!
See original GitHub issueRule request
Thesis
Currently we just do not allow people to use f
strings.
But, what if our user just ignores this violation? Now it is possible to do very bad things inside f
strings and we do not cover it at all.
I suggest to add TooComplexFormattedStringViolation
that will be throw in case of:
0. f'{one_name}'
should raise: because we only a single name inside f
string
- Too complex expression inside
f
string: like calling a lot of function, making conditions, etc - Too many expressions used in
f
string f
strings that dont have any values inside like:f'abc'
- Things like
assert f'a {value}'
should raise proper violations (WPS444
in this case), butassert f'{value}'
should not
This is just a discussion at the moment.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:8 (8 by maintainers)
Top Results From Across the Web
consider-using-f-string / C0209 - Pylint
Formatted string literals (f-strings) give a concise, consistent syntax that can replace most use cases for the % formatting operator, str.format() and string....
Read more >Pylint: How to fix "c0209: formatting a regular string which ...
In this post, you will see 3 different ways to fix this "formatting a regular string which could be a f-string (consider-using-f-string)" error....
Read more >PyLint vs f-strings - python - Stack Overflow
1. f-string is introduced in Python 3.6, which python version do you run pylint with? · To be 100% honest. I am not...
Read more >Python 3's f-Strings: An Improved String Formatting Syntax ...
As of Python 3.6, f-strings are a great new way to format strings. Not only are they more readable, more concise, and less...
Read more >PEP 498 – Literal String Interpolation
In Python source code, an f-string is a literal string, prefixed with 'f', ... Guido stated [5] that any solution to better string...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
From my experience, one can easily read code like this
Anything more complex is hard to read like
So:
@ruwaid4 no more than I said before 🤷