Skip to content

Commit c1e7a5d

Browse files
committed
- r Use explicit conversion flag
1 parent 1b7a927 commit c1e7a5d

6 files changed

Lines changed: 11 additions & 12 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def to_string(exception: BaseException) -> str:
2-
return f"{type(exception).__name__}: {str(exception)}"
2+
return f"{type(exception).__name__}: {exception!s}"

approvaltests/combination_approvals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def print_combinations(
156156

157157

158158
def args_and_result_formatter(args: list[Any], result: int) -> str:
159-
return f"args: {repr(args)} => {repr(result)}\n"
159+
return f"args: {args!r} => {result!r}\n"
160160

161161

162162
async def print_combinations_async(

approvaltests/reporter_missing_exception.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ def __init__(self, key: str) -> None:
88

99
@override
1010
def __str__(self) -> str:
11-
return f"Could not find {repr(self.value)} in the environment, perhaps you need to configure your reporter."
11+
return f"Could not find {self.value!r} in the environment, perhaps you need to configure your reporter."

ruff.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ ignore = [
1818
"COM812", # Trailing comma missing
1919
"FURB188", # Prefer `str.removeprefix()` over conditionally replacing with slice.
2020
"RET505", # Unnecessary `...` after `return` statement
21-
"RUF010", # Use explicit conversion flag
2221
"SIM114", # Combine `if` branches using logical `or` operator
2322
"SIM118", # Use `key not in dict` instead of `key not in dict.keys()`
2423
"SIM300", # Yoda condition detected

tests/scrubbers/test_scrubbers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_guid() -> None:
6767

6868
def test_combine_scrubbers() -> None:
6969
verify(
70-
f"blah {str(datetime.datetime(year=2000, month=1, day=2))} 2fd78d4a-ad49-447d-96a8-deda585a9aa5",
70+
f"blah {datetime.datetime(year=2000, month=1, day=2)!s} 2fd78d4a-ad49-447d-96a8-deda585a9aa5",
7171
options=Options().with_scrubber(
7272
combine_scrubbers(
7373
scrub_all_guids,

tests/test_scenarios.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def is_leap_year(year: int) -> bool:
1818
@pytest.mark.parametrize("year", [1993, 1992, 1900, 2000])
1919
def test_scenarios_old(year: int) -> None:
2020
verify(
21-
f"is Leap {str(year)}: {str(is_leap_year(year))}",
21+
f"is Leap {year!s}: {is_leap_year(year)!s}",
2222
namer=get_scenario_namer(year),
2323
)
2424

@@ -27,7 +27,7 @@ def test_scenarios_old(year: int) -> None:
2727
@pytest.mark.parametrize("year", [1993, 1992, 1900, 2000])
2828
def test_scenarios(year: int) -> None:
2929
verify(
30-
f"is Leap {str(year)}: {str(is_leap_year(year))}",
30+
f"is Leap {year!s}: {is_leap_year(year)!s}",
3131
options=NamerFactory.with_parameters(year),
3232
)
3333

@@ -39,22 +39,22 @@ def test_manual_scenarios_with_blocking() -> None:
3939
# begin-snippet: multiple-verifies-with-blocking
4040
year = 1992
4141
verify(
42-
f"is Leap {str(year)}: {str(is_leap_year(year))}",
42+
f"is Leap {year!s}: {is_leap_year(year)!s}",
4343
options=NamerFactory.with_parameters(year),
4444
)
4545
year = 1993
4646
verify(
47-
f"is Leap {str(year)}: {str(is_leap_year(year))}",
47+
f"is Leap {year!s}: {is_leap_year(year)!s}",
4848
options=NamerFactory.with_parameters(year),
4949
)
5050
year = 1900
5151
verify(
52-
f"is Leap {str(year)}: {str(is_leap_year(year))}",
52+
f"is Leap {year!s}: {is_leap_year(year)!s}",
5353
options=NamerFactory.with_parameters(year),
5454
)
5555
year = 2000
5656
verify(
57-
f"is Leap {str(year)}: {str(is_leap_year(year))}",
57+
f"is Leap {year!s}: {is_leap_year(year)!s}",
5858
options=NamerFactory.with_parameters(year),
5959
)
6060
# end-snippet
@@ -66,7 +66,7 @@ def test_manual_scenarios() -> None:
6666
gather_all_exceptions_and_throw(
6767
years,
6868
lambda y: verify(
69-
f"is Leap {str(y)}: {str(is_leap_year(y))}",
69+
f"is Leap {y!s}: {is_leap_year(y)!s}",
7070
options=NamerFactory.with_parameters(y),
7171
),
7272
)

0 commit comments

Comments
 (0)