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