Skip to content

Commit d0c9779

Browse files
author
Steve Ayers
committed
Feedback
1 parent 62fcaf5 commit d0c9779

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

protovalidate/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from collections.abc import Callable
1516
from dataclasses import dataclass
16-
from typing import Callable, Optional
17+
from typing import Optional
1718

1819

1920
@dataclass

protovalidate/internal/extra_func.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import math
1616
import re
1717
import typing
18+
from collections.abc import Callable
1819
from urllib import parse as urlparse
1920

2021
import celpy
@@ -1555,7 +1556,7 @@ def __peek(self, char: str) -> bool:
15551556
return self._index < len(self._string) and self._string[self._index] == char
15561557

15571558

1558-
def get_matches_func(matcher: typing.Optional[typing.Callable[[str, str], bool]]):
1559+
def get_matches_func(matcher: typing.Optional[Callable[[str, str], bool]]):
15591560
if matcher is None:
15601561
matcher = protovalidate_matches
15611562

protovalidate/internal/matches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def matches(text: str, pattern: str) -> bool:
4848
function via the Config.
4949
5050
Raises:
51-
celpy.CELEvalError: If pattern contains invalid re2 syntax.
51+
celpy.CELEvalError: If pattern contains invalid re2 syntax or if an re.error is raised during matching.
5252
"""
5353
# Simulate re2 by failing on any patterns not compatible with re2 syntax
5454
for invalid_pattern in invalid_patterns:

protovalidate/internal/rules.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import dataclasses
1616
import datetime
1717
import typing
18+
from collections.abc import Callable
1819

1920
import celpy
2021
from celpy import celtypes
@@ -44,7 +45,7 @@ def unwrap(msg: message.Message) -> celtypes.Value:
4445
return field_to_cel(msg, msg.DESCRIPTOR.fields_by_name["value"])
4546

4647

47-
_MSG_TYPE_URL_TO_CTOR: dict[str, typing.Callable[..., celtypes.Value]] = {
48+
_MSG_TYPE_URL_TO_CTOR: dict[str, Callable[..., celtypes.Value]] = {
4849
"google.protobuf.Duration": make_duration,
4950
"google.protobuf.Timestamp": make_timestamp,
5051
"google.protobuf.StringValue": unwrap,

0 commit comments

Comments
 (0)