Skip to content

Commit

Permalink
Add regression test for fixed bug involving bytes formatting (#15867)
Browse files Browse the repository at this point in the history
Adds a regression test for #12665, which is a strange bug that was fixed
somewhat by accident
  • Loading branch information
AlexWaygood authored Aug 14, 2023
1 parent edbfdaa commit 11a94be
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test-data/unit/check-formatting.test
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,23 @@ class D(bytes):
'{}'.format(D())
[builtins fixtures/primitives.pyi]

[case testNoSpuriousFormattingErrorsDuringFailedOverlodMatch]
from typing import overload, Callable

@overload
def sub(pattern: str, repl: Callable[[str], str]) -> str: ...
@overload
def sub(pattern: bytes, repl: Callable[[bytes], bytes]) -> bytes: ...
def sub(pattern: object, repl: object) -> object:
pass

def better_snakecase(text: str) -> str:
# Mypy used to emit a spurious error here
# warning about interpolating bytes into an f-string:
text = sub(r"([A-Z])([A-Z]+)([A-Z](?:[^A-Z]|$))", lambda match: f"{match}")
return text
[builtins fixtures/primitives.pyi]

[case testFormatCallFinal]
from typing_extensions import Final

Expand Down

0 comments on commit 11a94be

Please sign in to comment.