diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-09-21 09:01:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-21 09:01:31 +0200 |
commit | 95b530d5b776c7716eb81125e065cf4eadd7ff7c (patch) | |
tree | 67511a5888758011ef3579c4e2578a77da774703 /tests/functional/c | |
parent | b3336c77378f88eb1428d6ff5b6e78bba1177f40 (diff) | |
download | pylint-git-95b530d5b776c7716eb81125e065cf4eadd7ff7c.tar.gz |
Make ``consider-using-f-string`` skip `format()` with backslash (#5055)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/functional/c')
-rw-r--r-- | tests/functional/c/consider/consider_using_f_string.py | 13 | ||||
-rw-r--r-- | tests/functional/c/consider/consider_using_f_string.txt | 48 |
2 files changed, 36 insertions, 25 deletions
diff --git a/tests/functional/c/consider/consider_using_f_string.py b/tests/functional/c/consider/consider_using_f_string.py index 825f3517c..1d5400d5a 100644 --- a/tests/functional/c/consider/consider_using_f_string.py +++ b/tests/functional/c/consider/consider_using_f_string.py @@ -1,6 +1,6 @@ """Test to see if a f-string would be possible and consider-using-f-string should be raised""" # pylint: disable=unused-variable, invalid-name, missing-function-docstring, pointless-statement -# pylint: disable=expression-not-assigned, repeated-keyword +# pylint: disable=expression-not-assigned, repeated-keyword, too-many-locals PARAM_1 = PARAM_2 = PARAM_3 = 1 PARAM_LIST = [PARAM_1, PARAM_2, PARAM_3] @@ -35,6 +35,11 @@ def print_good(): print("%(Param_1)s %(Param_2)s" % PARAM_DICT) print("%(Param_1)s %(Param_2)s" % return_dict()) print("{a[Param_1]}{a[Param_2]}".format(a=PARAM_DICT)) + print("{}".format("\n")) + print("{}".format("\n".join(i for i in "string"))) + print("%s" % "\n") + print("%s" % "\n".join(i for i in "string")) + def print_bad(): print("String %f" % PARAM_1) # [consider-using-f-string] @@ -63,6 +68,10 @@ def statement_good(): "%(Param_1)s %(Param_2)s" % PARAM_DICT "%(Param_1)s %(Param_2)s" % return_dict() "{a[Param_1]}{a[Param_2]}".format(a=PARAM_DICT) + "{}".format("\n") + "{}".format("\n".join(i for i in "string")) + "%s" % "\n" + "%s" % "\n".join(i for i in "string") def statement_bad(): "String %f" % PARAM_1 # [consider-using-f-string] @@ -92,6 +101,8 @@ def assignment_good(): L = "%(Param_1)s %(Param_2)s" % return_dict() M = "{a[Param_1]}{a[Param_2]}".format(a=PARAM_DICT) N = "{Param}".format + O = "%s" % "\n" + P = "%s" % "\n".join(i for i in "string") def assignment_bad(): diff --git a/tests/functional/c/consider/consider_using_f_string.txt b/tests/functional/c/consider/consider_using_f_string.txt index db8f98112..65363cea4 100644 --- a/tests/functional/c/consider/consider_using_f_string.txt +++ b/tests/functional/c/consider/consider_using_f_string.txt @@ -1,30 +1,30 @@ -consider-using-f-string:40:10:print_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:41:10:print_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:42:10:print_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:43:10:print_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:44:10:print_bad:Formatting a regular string which could be a f-string:HIGH consider-using-f-string:45:10:print_bad:Formatting a regular string which could be a f-string:HIGH consider-using-f-string:46:10:print_bad:Formatting a regular string which could be a f-string:HIGH consider-using-f-string:47:10:print_bad:Formatting a regular string which could be a f-string:HIGH consider-using-f-string:48:10:print_bad:Formatting a regular string which could be a f-string:HIGH consider-using-f-string:49:10:print_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:68:4:statement_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:69:4:statement_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:70:4:statement_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:71:4:statement_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:72:4:statement_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:73:4:statement_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:74:4:statement_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:75:4:statement_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:76:4:statement_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:50:10:print_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:51:10:print_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:52:10:print_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:53:10:print_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:54:10:print_bad:Formatting a regular string which could be a f-string:HIGH consider-using-f-string:77:4:statement_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:98:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:99:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:100:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:101:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:102:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:103:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:104:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:105:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:106:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH -consider-using-f-string:107:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:78:4:statement_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:79:4:statement_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:80:4:statement_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:81:4:statement_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:82:4:statement_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:83:4:statement_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:84:4:statement_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:85:4:statement_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:86:4:statement_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:109:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:110:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:111:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:112:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:113:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:114:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:115:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:116:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:117:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH +consider-using-f-string:118:8:assignment_bad:Formatting a regular string which could be a f-string:HIGH |