You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regex patterns with concatenated raw strings are inferred as Pattern[LiteralString] instead of Pattern[str] #2129
After upgrading from 0.48.0 to 0.48.1, I now see a warning with code like this:
importrepattern=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].
Activity
yangdanny97 commentedon Feb 13, 2026
I believe this is a case of #2370, the
AnyStrin re.compile should only be allowed to resolve to str or bytes, not LiteralStringTypeVarresolves to subtype instead of constraint #2370