Skip to content

Commit

Permalink
Update for editions (#174)
Browse files Browse the repository at this point in the history
Updates protovalidate, adds support for new ignore semantics. The PR is
huge but it's mostly gencode; the actual CEL code wasn't too
substantially altered.

~~Unfortunately I could not get the tests to pass 100%. There is a minor
wrinkle where, I _believe_, the behavior of `has(x.y)` and `x.y` needs
to differ (specifically with proto3 optional) but it can not due to the
way the interpreter works. It _seems_ like this only impacts some rather
small edge cases so I guess we might be able to live with it in the
interim. I've just added said tests to the nonconforming list.~~
**Update:** The issues still exist upstream (assuming the issue is valid
and not a mistake on my part) but we are now working around it, and
tests now pass 100% (sans the existing failures.)

All other tests pass and I _believe_ my fixes are correct. The e-mail
check was corrected to not support bracketed emails as was done with the
Go version.
  • Loading branch information
jchadwick-buf authored Aug 5, 2024
1 parent 86e4937 commit 4c035d0
Show file tree
Hide file tree
Showing 75 changed files with 4,721 additions and 1,927 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export PATH := $(BIN):$(PATH)
export GOBIN := $(abspath $(BIN))
# Set to use a different Python interpreter. For example, `PYTHON=python make test`.
PYTHON ?= python3
CONFORMANCE_ARGS ?= --strict --expected_failures=tests/conformance/nonconforming.yaml
CONFORMANCE_ARGS ?= --strict --expected_failures=tests/conformance/nonconforming.yaml --timeout 10s
ADD_LICENSE_HEADER := $(BIN)/license-header \
--license-type apache \
--copyright-holder "Buf Technologies, Inc." \
--year-range "2023"
PROTOVALIDATE_VERSION ?= v0.5.6
PROTOVALIDATE_VERSION ?= v0.7.1

.PHONY: help
help: ## Describe useful make targets
Expand Down
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ verify_ssl = true
name = "pypi"

[packages]
cel-python = "==0.1.*"
protobuf = "==4.*"
cel-python = "==0.1.5"
protobuf = "==5.*"

[dev-packages]
pytest = "*"
Expand Down
152 changes: 72 additions & 80 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: v1
plugins:
- plugin: buf.build/protocolbuffers/python:v23.2
- plugin: buf.build/protocolbuffers/python:v27.2
out: gen
- plugin: buf.build/protocolbuffers/pyi:v23.2
- plugin: buf.build/protocolbuffers/pyi:v27.2
out: gen
2 changes: 2 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by buf. DO NOT EDIT.
version: v1
24 changes: 17 additions & 7 deletions gen/buf/validate/conformance/cases/bool_pb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@

# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: buf/validate/conformance/cases/bool.proto
# Protobuf Python Version: 5.27.2
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import runtime_version as _runtime_version
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
_runtime_version.Domain.PUBLIC,
5,
27,
2,
'',
'buf/validate/conformance/cases/bool.proto'
)
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()
Expand All @@ -33,13 +44,12 @@
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'buf.validate.conformance.cases.bool_pb2', _globals)
if _descriptor._USE_C_DESCRIPTORS == False:

DESCRIPTOR._options = None
_BOOLCONSTTRUE.fields_by_name['val']._options = None
_BOOLCONSTTRUE.fields_by_name['val']._serialized_options = b'\272H\004j\002\010\001'
_BOOLCONSTFALSE.fields_by_name['val']._options = None
_BOOLCONSTFALSE.fields_by_name['val']._serialized_options = b'\272H\004j\002\010\000'
if not _descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options = None
_globals['_BOOLCONSTTRUE'].fields_by_name['val']._loaded_options = None
_globals['_BOOLCONSTTRUE'].fields_by_name['val']._serialized_options = b'\272H\004j\002\010\001'
_globals['_BOOLCONSTFALSE'].fields_by_name['val']._loaded_options = None
_globals['_BOOLCONSTFALSE'].fields_by_name['val']._serialized_options = b'\272H\004j\002\010\000'
_globals['_BOOLNONE']._serialized_start=106
_globals['_BOOLNONE']._serialized_end=134
_globals['_BOOLCONSTTRUE']._serialized_start=136
Expand Down
6 changes: 3 additions & 3 deletions gen/buf/validate/conformance/cases/bool_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ from typing import ClassVar as _ClassVar, Optional as _Optional
DESCRIPTOR: _descriptor.FileDescriptor

class BoolNone(_message.Message):
__slots__ = ["val"]
__slots__ = ("val",)
VAL_FIELD_NUMBER: _ClassVar[int]
val: bool
def __init__(self, val: bool = ...) -> None: ...

class BoolConstTrue(_message.Message):
__slots__ = ["val"]
__slots__ = ("val",)
VAL_FIELD_NUMBER: _ClassVar[int]
val: bool
def __init__(self, val: bool = ...) -> None: ...

class BoolConstFalse(_message.Message):
__slots__ = ["val"]
__slots__ = ("val",)
VAL_FIELD_NUMBER: _ClassVar[int]
val: bool
def __init__(self, val: bool = ...) -> None: ...
Loading

0 comments on commit 4c035d0

Please sign in to comment.