-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationslinterRelated to the linterRelated to the linter
Description
Given:
def foo(
arg2: str = f'51 character {x} stringgggggggggggggggggggggggggggggggggggggggggggg',
) -> None: ...Here, the number of characters after the replacement field is > 50 which is what we flag and fix:
src/PYI053.pyi:3:35: PYI053 [*] String and bytes literals longer than 50 characters are not permitted
|
1 | def foo(
2 | arg1: str = '51 character stringggggggggggggggggggggggggggggggg',
3 | arg2: str = f'51 character {x} stringgggggggggggggggggggggggggggggggggggggggggggg',
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053
4 | ) -> None: ...
|
= help: Replace with `...`
ℹ Safe fix
1 1 | def foo(
2 2 | arg1: str = '51 character stringggggggggggggggggggggggggggggggg',
3 |- arg2: str = f'51 character {x} stringgggggggggggggggggggggggggggggggggggggggggggg',
3 |+ arg2: str = f'51 character {x}...',
4 4 | ) -> None: ...
Found 1 error.
[*] 1 fixable with the --fix option.
This is not ideal and it raises an interesting question - how to count the characters for an f-string containing replacement fields?
f"one{expr}one"(6 total or 3 and 3)"one" f"one{expr}one"(9 total or 3, 3, 3)f"one{expr}one" f"one{expr}one"(12 total or 3, 3, 3, 3)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationslinterRelated to the linterRelated to the linter