Skip to content

Commit d253045

Browse files
committed
Merge branch 'main' of https://github.com/bufbuild/protovalidate-python into renovate/python-dependencies
2 parents f9cced4 + 55db449 commit d253045

103 files changed

Lines changed: 11459 additions & 269 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CONTRIBUTING.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,14 @@ Next, install dependencies. You will need:
2323

2424
* [uv](https://docs.astral.sh/uv/)
2525

26-
We use a Makefile to test and lint our code, so you'll also need a few non-Python tools:
26+
Some tasks require additional non-Python tools:
2727

28-
* GNU Make (to use the Makefile): part of the `build-essential` package on
29-
Debian-derived Linux distributions (including Ubuntu), and part of
30-
`xcode-select --install` on Macs.
3128
* Go (for the conformance test runner): often available in your system package
3229
manager (`apt`, `dnf`, `brew`, etc.), but most reliable when [installed
3330
directly from upstream](https://go.dev/doc/install).
3431

35-
With Go and GNU Make installed, you can verify that your changes pass tests and
36-
lint checks by running `make`. For a list of other useful commands, run `make
37-
help`.
32+
With Go installed, you can verify that your changes pass tests and
33+
lint checks by running `uv run poe check`. For a list of other useful commands, run `uv run poe`.
3834

3935
### Reporting Bugs
4036

.github/workflows/ci.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ jobs:
2727
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
2828
with:
2929
go-version: stable
30-
# We use this to install `buf`, and the `buf` version is controlled by the Makefile.
31-
cache-dependency-path: Makefile
30+
# We use this to install certain tools defined in poe tasks
31+
cache-dependency-path: poe_tasks.toml
3232
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
3333
with:
3434
python-version: ${{ matrix.python-version }}
35-
- run: make install
36-
- run: make test
37-
- run: make conformance
35+
- run: uv sync
36+
- run: uv run poe test
37+
- run: uv run poe test-conformance
3838

3939
lint:
4040
runs-on: ubuntu-latest
@@ -43,15 +43,15 @@ jobs:
4343
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
4444
with:
4545
go-version: stable
46-
# We use this to install `buf`, and the `buf` version is controlled by the Makefile.
47-
cache-dependency-path: Makefile
46+
# We use this to install certain tools defined in poe tasks
47+
cache-dependency-path: poe_tasks.toml
4848
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
4949
with:
5050
python-version: ${{ matrix.python-version }}
51-
- run: make install
52-
- run: make lint
53-
- run: make format
54-
# When running with matrix.resolution == lowest-direct, we expect uv.lock to change, but we don't want that file checked in.
55-
- run: make checkgenerate
51+
- run: uv sync --locked
52+
- run: uv run poe lint
53+
- run: uv run poe format
54+
- run: uv run poe generate
5655
env:
5756
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
57+
- run: uv run poe diffcheck

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# tools, see ./Makefile
2-
/.tmp/
3-
41
# python writes compiled bytecode to .pyc files in __pycache__ directories
52
__pycache__
63

Makefile

Lines changed: 0 additions & 97 deletions
This file was deleted.

packages/protovalidate-proto/buf.gen.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
version: v2
2-
managed:
3-
enabled: true
2+
clean: true
43
plugins:
54
# NOTE: v26.0 is the earliest version supporting protobuf==5.
65
- remote: buf.build/protocolbuffers/python:v26.0
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2023-2026 Buf Technologies, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package buf.validate.conformance.cases;
18+
19+
import "buf/validate/validate.proto";
20+
21+
message BoolNone {
22+
bool val = 1;
23+
}
24+
message BoolConstTrue {
25+
bool val = 1 [(buf.validate.field).bool.const = true];
26+
}
27+
message BoolConstFalse {
28+
bool val = 1 [(buf.validate.field).bool.const = false];
29+
}
30+
message BoolExample {
31+
bool val = 1 [(buf.validate.field).bool.example = true];
32+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// Copyright 2023-2026 Buf Technologies, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package buf.validate.conformance.cases;
18+
19+
import "buf/validate/validate.proto";
20+
21+
message BytesNone {
22+
bytes val = 1;
23+
}
24+
message BytesConst {
25+
bytes val = 1 [(buf.validate.field).bytes.const = "foo"];
26+
}
27+
message BytesIn {
28+
bytes val = 1 [(buf.validate.field).bytes = {
29+
in: [
30+
"bar",
31+
"baz"
32+
]
33+
}];
34+
}
35+
message BytesNotIn {
36+
bytes val = 1 [(buf.validate.field).bytes = {
37+
not_in: [
38+
"fizz",
39+
"buzz"
40+
]
41+
}];
42+
}
43+
message BytesLen {
44+
bytes val = 1 [(buf.validate.field).bytes.len = 3];
45+
}
46+
message BytesMinLen {
47+
bytes val = 1 [(buf.validate.field).bytes.min_len = 3];
48+
}
49+
message BytesMaxLen {
50+
bytes val = 1 [(buf.validate.field).bytes.max_len = 5];
51+
}
52+
message BytesMinMaxLen {
53+
bytes val = 1 [(buf.validate.field).bytes = {
54+
min_len: 3
55+
max_len: 5
56+
}];
57+
}
58+
message BytesEqualMinMaxLen {
59+
bytes val = 1 [(buf.validate.field).bytes = {
60+
min_len: 5
61+
max_len: 5
62+
}];
63+
}
64+
message BytesPattern {
65+
bytes val = 1 [(buf.validate.field).bytes.pattern = "^[\\x00-\\x7F]+$"];
66+
}
67+
message BytesPrefix {
68+
bytes val = 1 [(buf.validate.field).bytes.prefix = "\x99"];
69+
}
70+
message BytesContains {
71+
bytes val = 1 [(buf.validate.field).bytes.contains = "bar"];
72+
}
73+
message BytesSuffix {
74+
bytes val = 1 [(buf.validate.field).bytes.suffix = "buz\x7a"];
75+
}
76+
message BytesIP {
77+
bytes val = 1 [(buf.validate.field).bytes.ip = true];
78+
}
79+
message BytesNotIP {
80+
bytes val = 1 [(buf.validate.field).bytes.ip = false];
81+
}
82+
message BytesIPv4 {
83+
bytes val = 1 [(buf.validate.field).bytes.ipv4 = true];
84+
}
85+
message BytesNotIPv4 {
86+
bytes val = 1 [(buf.validate.field).bytes.ipv4 = false];
87+
}
88+
message BytesIPv6 {
89+
bytes val = 1 [(buf.validate.field).bytes.ipv6 = true];
90+
}
91+
message BytesNotIPv6 {
92+
bytes val = 1 [(buf.validate.field).bytes.ipv6 = false];
93+
}
94+
message BytesIPv6Ignore {
95+
bytes val = 1 [
96+
(buf.validate.field).bytes.ipv6 = true,
97+
(buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE
98+
];
99+
}
100+
message BytesUUID {
101+
bytes val = 1 [(buf.validate.field).bytes.uuid = true];
102+
}
103+
message BytesNotUUID {
104+
bytes val = 1 [(buf.validate.field).bytes.uuid = false];
105+
}
106+
message BytesUUIDIgnore {
107+
bytes val = 1 [
108+
(buf.validate.field).bytes.uuid = true,
109+
(buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE
110+
];
111+
}
112+
message BytesExample {
113+
bytes val = 1 [(buf.validate.field).bytes.example = "\x99"];
114+
}

0 commit comments

Comments
 (0)