From aab9676234166b212c31a02a47961375df86aaa2 Mon Sep 17 00:00:00 2001 From: dosisod <39638017+dosisod@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:22:58 -0800 Subject: [PATCH] Update docs, fix failing test --- docs/checks.md | 21 +++++++++++++++++++++ refurb/checks/readability/use_str_func.py | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/checks.md b/docs/checks.md index a63bab5..c3f4668 100644 --- a/docs/checks.md +++ b/docs/checks.md @@ -2159,4 +2159,25 @@ Good: from hashlib import sha512 h = sha512(b"data") +``` + +## FURB183: `use-str-func` + +Categories: `readability` + +If you want to stringify a single value without concatenating anything, use +the `str()` function instead. + +Bad: + +```python +nums = [123, 456] +num = f"{num[0]}") +``` + +Good: + +```python +nums = [123, 456] +num = str(num[0]) ``` \ No newline at end of file diff --git a/refurb/checks/readability/use_str_func.py b/refurb/checks/readability/use_str_func.py index bf98512..fe80625 100644 --- a/refurb/checks/readability/use_str_func.py +++ b/refurb/checks/readability/use_str_func.py @@ -3,8 +3,8 @@ from mypy.nodes import CallExpr, ListExpr, MemberExpr, NameExpr, StrExpr from refurb.checks.common import stringify -from refurb.error import Error from refurb.checks.string.use_fstring_fmt import CONVERSIONS as FURB_119_FUNCS +from refurb.error import Error @dataclass