Skip to content

Commit 7aab55c

Browse files
author
Ronen Hilewicz
committed
Support protovalidate
1 parent 26fe7bd commit 7aab55c

15 files changed

+1098
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ __pycache__
77
.pytest_cache
88
.vscode
99
.coverage
10+
.python-version

magefiles/magefile.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func gen(bufImage, fileSources string) error {
9999
for bufImage, clientFiles := range files {
100100
err = buf.Run(
101101
buf.AddArg("generate"),
102+
buf.AddArg("--include-imports"),
102103
buf.AddArg("--template"),
103104
buf.AddArg(filepath.Join("buf", "buf.gen.yaml")),
104105
buf.AddArg(bufImage),

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ packages = [
3030

3131
[tool.poetry.dependencies]
3232
python = ">=3.8"
33-
grpcio = ">=1.58.0"
33+
grpcio = "^1.49.0"
3434
typing-extensions = ">=3.10.0"
35+
protobuf = "^4.21.0"
36+
protovalidate = { version = "^0.3.0", python = ">=3.11"}
3537

3638
[tool.poetry.dev-dependencies]
37-
black = "^23.10.1"
38-
isort = "^5.10.1"
39+
black = "^23.11.0"
40+
isort = "^5.10.0"
41+
pyright = "^1.1.0"
3942

4043
[tool.mypy]
4144
explicit_package_bases = true

src/buf/validate/expression_pb2.py

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/buf/validate/expression_pb2.pyi

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from google.protobuf.internal import containers as _containers
2+
from google.protobuf import descriptor as _descriptor
3+
from google.protobuf import message as _message
4+
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union
5+
6+
DESCRIPTOR: _descriptor.FileDescriptor
7+
8+
class Constraint(_message.Message):
9+
__slots__ = ("id", "message", "expression")
10+
ID_FIELD_NUMBER: _ClassVar[int]
11+
MESSAGE_FIELD_NUMBER: _ClassVar[int]
12+
EXPRESSION_FIELD_NUMBER: _ClassVar[int]
13+
id: str
14+
message: str
15+
expression: str
16+
def __init__(self, id: _Optional[str] = ..., message: _Optional[str] = ..., expression: _Optional[str] = ...) -> None: ...
17+
18+
class Violations(_message.Message):
19+
__slots__ = ("violations",)
20+
VIOLATIONS_FIELD_NUMBER: _ClassVar[int]
21+
violations: _containers.RepeatedCompositeFieldContainer[Violation]
22+
def __init__(self, violations: _Optional[_Iterable[_Union[Violation, _Mapping]]] = ...) -> None: ...
23+
24+
class Violation(_message.Message):
25+
__slots__ = ("field_path", "constraint_id", "message", "for_key")
26+
FIELD_PATH_FIELD_NUMBER: _ClassVar[int]
27+
CONSTRAINT_ID_FIELD_NUMBER: _ClassVar[int]
28+
MESSAGE_FIELD_NUMBER: _ClassVar[int]
29+
FOR_KEY_FIELD_NUMBER: _ClassVar[int]
30+
field_path: str
31+
constraint_id: str
32+
message: str
33+
for_key: bool
34+
def __init__(self, field_path: _Optional[str] = ..., constraint_id: _Optional[str] = ..., message: _Optional[str] = ..., for_key: bool = ...) -> None: ...
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2+
"""Client and server classes corresponding to protobuf-defined services."""
3+
import grpc
4+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
@generated by mypy-protobuf. Do not edit manually!
3+
isort:skip_file
4+
Copyright 2023 Buf Technologies, Inc.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
"""
18+
import abc
19+
import collections.abc
20+
import grpc
21+
import grpc.aio
22+
import typing
23+
24+
_T = typing.TypeVar('_T')
25+
26+
class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta):
27+
...
28+
29+
class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore
30+
...

src/buf/validate/priv/private_pb2.py

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/buf/validate/priv/private_pb2.pyi

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from google.protobuf import descriptor_pb2 as _descriptor_pb2
2+
from google.protobuf.internal import containers as _containers
3+
from google.protobuf import descriptor as _descriptor
4+
from google.protobuf import message as _message
5+
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union
6+
7+
DESCRIPTOR: _descriptor.FileDescriptor
8+
FIELD_FIELD_NUMBER: _ClassVar[int]
9+
field: _descriptor.FieldDescriptor
10+
11+
class FieldConstraints(_message.Message):
12+
__slots__ = ("cel",)
13+
CEL_FIELD_NUMBER: _ClassVar[int]
14+
cel: _containers.RepeatedCompositeFieldContainer[Constraint]
15+
def __init__(self, cel: _Optional[_Iterable[_Union[Constraint, _Mapping]]] = ...) -> None: ...
16+
17+
class Constraint(_message.Message):
18+
__slots__ = ("id", "message", "expression")
19+
ID_FIELD_NUMBER: _ClassVar[int]
20+
MESSAGE_FIELD_NUMBER: _ClassVar[int]
21+
EXPRESSION_FIELD_NUMBER: _ClassVar[int]
22+
id: str
23+
message: str
24+
expression: str
25+
def __init__(self, id: _Optional[str] = ..., message: _Optional[str] = ..., expression: _Optional[str] = ...) -> None: ...
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2+
"""Client and server classes corresponding to protobuf-defined services."""
3+
import grpc
4+

0 commit comments

Comments
 (0)