Skip to content

Commit

Permalink
fix self check
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Sep 27, 2024
1 parent b6a5b27 commit 3c0dcd5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pyanalyze/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from .signature import (
ANY_SIGNATURE,
CallContext,
ConcreteSignature,
ImplReturn,
OverloadedSignature,
ParameterKind,
Expand Down Expand Up @@ -2238,7 +2239,11 @@ def get_default_argspecs() -> Dict[object, Signature]:

def check_regex(pattern: Union[str, bytes]) -> Optional[CanAssignError]:
try:
re.compile(pattern)
# TODO allow this without the useless isinstance()
if isinstance(pattern, str):
re.compile(pattern)
else:
re.compile(pattern)
except re.error as e:
return CanAssignError(
f"Invalid regex pattern: {e}", error_code=ErrorCode.invalid_regex
Expand Down Expand Up @@ -2275,7 +2280,7 @@ def _re_impl_with_pattern(ctx: CallContext) -> Value:

def get_default_argspecs_with_cache(
asc: "pyanalyze.arg_spec.ArgSpecCache",
) -> Dict[object, Signature]:
) -> Dict[object, ConcreteSignature]:
sigs = {}
for func in (
re.compile,
Expand Down

0 comments on commit 3c0dcd5

Please sign in to comment.