Skip to content

Commit a88c21d

Browse files
committed
validators: work around a pyrefly issue with scoping
pyrefly was showing errors when a builtin was overriden in file scope. This cause an error when using "compile" imported from re, so this change uses re.compile() instead.
1 parent cb60d30 commit a88c21d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

troposphere/validators/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from __future__ import annotations
66

77
import json
8-
from re import compile
8+
import re
99
from typing import (
1010
TYPE_CHECKING,
1111
Any,
@@ -74,7 +74,7 @@ def integer_range_checker(x: Any) -> Union[str, bytes, SupportsInt, SupportsInde
7474

7575

7676
def integer_list_item(
77-
allowed_values: List[float],
77+
allowed_values: List[int],
7878
) -> Callable[[Any], Union[str, bytes, SupportsInt, SupportsIndex]]:
7979
def integer_list_item_checker(
8080
x: Any,
@@ -140,19 +140,19 @@ def s3_bucket_name(b: str) -> str:
140140

141141
# IP addresses not allowed
142142

143-
ip_re = compile(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
143+
ip_re = re.compile(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
144144
if ip_re.match(b):
145145
raise ValueError("%s is not a valid s3 bucket name" % b)
146146

147-
s3_bucket_name_re = compile(r"^[a-z\d][a-z\d\.-]{1,61}[a-z\d]$")
147+
s3_bucket_name_re = re.compile(r"^[a-z\d][a-z\d\.-]{1,61}[a-z\d]$")
148148
if s3_bucket_name_re.match(b):
149149
return b
150150
else:
151151
raise ValueError("%s is not a valid s3 bucket name" % b)
152152

153153

154154
def elb_name(b: str) -> str:
155-
elb_name_re = compile(
155+
elb_name_re = re.compile(
156156
r"^[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,30}[a-zA-Z0-9]{1})?$"
157157
) # noqa
158158
if elb_name_re.match(b):

0 commit comments

Comments
 (0)