Skip to content

Regex patterns with concatenated raw strings are inferred as Pattern[LiteralString] instead of Pattern[str] #2129

@correctmost

Description

@correctmost

Describe the Bug

After upgrading from 0.48.0 to 0.48.1, I now see a warning with code like this:

import re

pattern = re.compile(r'hi' + r'hi')
re.match(pattern, '')  # No matching overload found for function `re.match` called with arguments: (Pattern[LiteralString], Literal['']) [no-matching-overload]

Pyright, ty, mypy, and zuban infer the pattern variable as Pattern[str] instead of Pattern[LiteralString].

Version info

ab249da

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIEAtsbgE4AuABHTADrofGoMMx3omAXhYxCAY1w1oMABR0A5AAsICpgGoWy1QEoOrQlR7ils7r37oANEwUK96EFZABXBtDglyiEAGImAKruUBAMpExgLuji7rjocBwcmDBgEfRGDAD66C5U2Pyy%2BIhMEOgMOkwAtAB8THAMdIgcTC2iDC4CEWwgAHK5%2BY1MwPgAvt0cTiBkrGBQpIQMUlAU-gAKpDNzdRg4BEyS6JAA5h08EHGEHP4AyjAwTEq8xHCIAPSv0ylzhPRHrzDoV6YXDiOCvA7HU6xQFpOhMVAAN1Q0FQ2Fg%2BzikLoZziTFwxGhni4pAYSjilQR-Dg50EIm6AGZCABGABM40cI2cqBiEEpADEZBQ0Fg8EQyCARkA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions