Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression test for fixed bug involving bytes formatting #15867

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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