Skip to content

Commit 11a94be

Browse files
authored
Add regression test for fixed bug involving bytes formatting (#15867)
Adds a regression test for #12665, which is a strange bug that was fixed somewhat by accident
1 parent edbfdaa commit 11a94be

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test-data/unit/check-formatting.test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,23 @@ class D(bytes):
484484
'{}'.format(D())
485485
[builtins fixtures/primitives.pyi]
486486

487+
[case testNoSpuriousFormattingErrorsDuringFailedOverlodMatch]
488+
from typing import overload, Callable
489+
490+
@overload
491+
def sub(pattern: str, repl: Callable[[str], str]) -> str: ...
492+
@overload
493+
def sub(pattern: bytes, repl: Callable[[bytes], bytes]) -> bytes: ...
494+
def sub(pattern: object, repl: object) -> object:
495+
pass
496+
497+
def better_snakecase(text: str) -> str:
498+
# Mypy used to emit a spurious error here
499+
# warning about interpolating bytes into an f-string:
500+
text = sub(r"([A-Z])([A-Z]+)([A-Z](?:[^A-Z]|$))", lambda match: f"{match}")
501+
return text
502+
[builtins fixtures/primitives.pyi]
503+
487504
[case testFormatCallFinal]
488505
from typing_extensions import Final
489506

0 commit comments

Comments
 (0)