diff --git a/example/proto_pydanticv1/demo_gen_code.py b/example/proto_pydanticv1/demo_gen_code.py index 6780e0c..5a1fb49 100644 --- a/example/proto_pydanticv1/demo_gen_code.py +++ b/example/proto_pydanticv1/demo_gen_code.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 1.10.7 import typing from datetime import datetime diff --git a/example/proto_pydanticv1/demo_gen_code_by_p2p.py b/example/proto_pydanticv1/demo_gen_code_by_p2p.py index 9dcc7cb..e2abeae 100644 --- a/example/proto_pydanticv1/demo_gen_code_by_p2p.py +++ b/example/proto_pydanticv1/demo_gen_code_by_p2p.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 1.10.7 import typing from datetime import datetime, timedelta diff --git a/example/proto_pydanticv1/demo_gen_code_by_pgv.py b/example/proto_pydanticv1/demo_gen_code_by_pgv.py index d9d371f..f3640c2 100644 --- a/example/proto_pydanticv1/demo_gen_code_by_pgv.py +++ b/example/proto_pydanticv1/demo_gen_code_by_pgv.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 1.10.7 import typing from datetime import datetime, timedelta diff --git a/example/proto_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py b/example/proto_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py index bae2e7b..4f789a7 100644 --- a/example/proto_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py +++ b/example/proto_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 1.10.7 import typing from datetime import datetime diff --git a/example/proto_pydanticv1/demo_gen_code_by_text_comment_pyi.py b/example/proto_pydanticv1/demo_gen_code_by_text_comment_pyi.py index bae2e7b..4f789a7 100644 --- a/example/proto_pydanticv1/demo_gen_code_by_text_comment_pyi.py +++ b/example/proto_pydanticv1/demo_gen_code_by_text_comment_pyi.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 1.10.7 import typing from datetime import datetime diff --git a/example/proto_pydanticv1/example/example_proto/common/p2p_validate_pb2.py b/example/proto_pydanticv1/example/example_proto/common/p2p_validate_pb2.py index 173948f..c133de1 100644 --- a/example/proto_pydanticv1/example/example_proto/common/p2p_validate_pb2.py +++ b/example/proto_pydanticv1/example/example_proto/common/p2p_validate_pb2.py @@ -22,10 +22,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.common.p2p_validate_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - google_dot_protobuf_dot_descriptor__pb2.MessageOptions.RegisterExtension(ignored) - google_dot_protobuf_dot_descriptor__pb2.OneofOptions.RegisterExtension(required) - google_dot_protobuf_dot_descriptor__pb2.FieldOptions.RegisterExtension(rules) - DESCRIPTOR._options = None _globals['_FIELDRULES']._serialized_start=165 _globals['_FIELDRULES']._serialized_end=1190 diff --git a/example/proto_pydanticv1/example/example_proto/common/single_p2p.py b/example/proto_pydanticv1/example/example_proto/common/single_p2p.py index df2df9c..45dd4db 100644 --- a/example/proto_pydanticv1/example/example_proto/common/single_p2p.py +++ b/example/proto_pydanticv1/example/example_proto/common/single_p2p.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 1.10.7 from enum import IntEnum diff --git a/example/proto_pydanticv1/example/example_proto/common/single_pb2.py b/example/proto_pydanticv1/example/example_proto/common/single_pb2.py index 74759b1..d031f8c 100644 --- a/example/proto_pydanticv1/example/example_proto/common/single_pb2.py +++ b/example/proto_pydanticv1/example/example_proto/common/single_pb2.py @@ -19,7 +19,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.common.single_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None _globals['_DEMOENUM']._serialized_start=114 _globals['_DEMOENUM']._serialized_end=152 diff --git a/example/proto_pydanticv1/example/example_proto/common/validate_pb2.py b/example/proto_pydanticv1/example/example_proto/common/validate_pb2.py index ba2aa7f..2135f88 100644 --- a/example/proto_pydanticv1/example/example_proto/common/validate_pb2.py +++ b/example/proto_pydanticv1/example/example_proto/common/validate_pb2.py @@ -22,11 +22,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.common.validate_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - google_dot_protobuf_dot_descriptor__pb2.MessageOptions.RegisterExtension(disabled) - google_dot_protobuf_dot_descriptor__pb2.MessageOptions.RegisterExtension(ignored) - google_dot_protobuf_dot_descriptor__pb2.OneofOptions.RegisterExtension(required) - google_dot_protobuf_dot_descriptor__pb2.FieldOptions.RegisterExtension(rules) - DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b'\n\032io.envoyproxy.pgv.validateZ2github.com/envoyproxy/protoc-gen-validate/validate' _globals['_KNOWNREGEX']._serialized_start=4561 diff --git a/example/proto_pydanticv1/example/example_proto/demo/demo_p2p.py b/example/proto_pydanticv1/example/example_proto/demo/demo_p2p.py index 00e45f8..78f7712 100644 --- a/example/proto_pydanticv1/example/example_proto/demo/demo_p2p.py +++ b/example/proto_pydanticv1/example/example_proto/demo/demo_p2p.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 1.10.7 import typing from datetime import datetime diff --git a/example/proto_pydanticv1/example/example_proto/demo/demo_pb2.py b/example/proto_pydanticv1/example/example_proto/demo/demo_pb2.py index 956637b..a7dd10f 100644 --- a/example/proto_pydanticv1/example/example_proto/demo/demo_pb2.py +++ b/example/proto_pydanticv1/example/example_proto/demo/demo_pb2.py @@ -22,7 +22,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.demo.demo_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None _MAPMESSAGE_USERMAPENTRY._options = None _MAPMESSAGE_USERMAPENTRY._serialized_options = b'8\001' diff --git a/example/proto_pydanticv1/example/example_proto/p2p_validate/demo_p2p.py b/example/proto_pydanticv1/example/example_proto/p2p_validate/demo_p2p.py index acc6eb0..2ccb400 100644 --- a/example/proto_pydanticv1/example/example_proto/p2p_validate/demo_p2p.py +++ b/example/proto_pydanticv1/example/example_proto/p2p_validate/demo_p2p.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 1.10.7 import typing from datetime import datetime, timedelta diff --git a/example/proto_pydanticv1/example/example_proto/p2p_validate/demo_pb2.py b/example/proto_pydanticv1/example/example_proto/p2p_validate/demo_pb2.py index e95fc27..381cfb6 100644 --- a/example/proto_pydanticv1/example/example_proto/p2p_validate/demo_pb2.py +++ b/example/proto_pydanticv1/example/example_proto/p2p_validate/demo_pb2.py @@ -24,7 +24,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.p2p_validate.demo_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None _FLOATTEST.fields_by_name['const_test']._options = None _FLOATTEST.fields_by_name['const_test']._serialized_options = b'\212C\007\n\005\r\000\000\200?' diff --git a/example/proto_pydanticv1/example/example_proto/validate/demo_p2p.py b/example/proto_pydanticv1/example/example_proto/validate/demo_p2p.py index 5fbba7d..443b98c 100644 --- a/example/proto_pydanticv1/example/example_proto/validate/demo_p2p.py +++ b/example/proto_pydanticv1/example/example_proto/validate/demo_p2p.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 1.10.7 import typing from datetime import datetime, timedelta diff --git a/example/proto_pydanticv1/example/example_proto/validate/demo_pb2.py b/example/proto_pydanticv1/example/example_proto/validate/demo_pb2.py index 31f9c0d..37588be 100644 --- a/example/proto_pydanticv1/example/example_proto/validate/demo_pb2.py +++ b/example/proto_pydanticv1/example/example_proto/validate/demo_pb2.py @@ -24,7 +24,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.validate.demo_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None _FLOATTEST.fields_by_name['const_test']._options = None _FLOATTEST.fields_by_name['const_test']._serialized_options = b'\372B\007\n\005\r\000\000\200?' diff --git a/example/proto_pydanticv2/demo_gen_code.py b/example/proto_pydanticv2/demo_gen_code.py index 79990f9..d832ee0 100644 --- a/example/proto_pydanticv2/demo_gen_code.py +++ b/example/proto_pydanticv2/demo_gen_code.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 2.0.3 import typing from datetime import datetime diff --git a/example/proto_pydanticv2/demo_gen_code_by_p2p.py b/example/proto_pydanticv2/demo_gen_code_by_p2p.py index 18bbb41..4191f64 100644 --- a/example/proto_pydanticv2/demo_gen_code_by_p2p.py +++ b/example/proto_pydanticv2/demo_gen_code_by_p2p.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 2.0.3 import typing from datetime import datetime, timedelta diff --git a/example/proto_pydanticv2/demo_gen_code_by_pgv.py b/example/proto_pydanticv2/demo_gen_code_by_pgv.py index 24be7a9..49c19ef 100644 --- a/example/proto_pydanticv2/demo_gen_code_by_pgv.py +++ b/example/proto_pydanticv2/demo_gen_code_by_pgv.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 2.0.3 import typing from datetime import datetime, timedelta diff --git a/example/proto_pydanticv2/demo_gen_code_by_text_comment_protobuf_field.py b/example/proto_pydanticv2/demo_gen_code_by_text_comment_protobuf_field.py index eef6326..47f3780 100644 --- a/example/proto_pydanticv2/demo_gen_code_by_text_comment_protobuf_field.py +++ b/example/proto_pydanticv2/demo_gen_code_by_text_comment_protobuf_field.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 2.0.3 import typing from datetime import datetime diff --git a/example/proto_pydanticv2/demo_gen_code_by_text_comment_pyi.py b/example/proto_pydanticv2/demo_gen_code_by_text_comment_pyi.py index eef6326..47f3780 100644 --- a/example/proto_pydanticv2/demo_gen_code_by_text_comment_pyi.py +++ b/example/proto_pydanticv2/demo_gen_code_by_text_comment_pyi.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 2.0.3 import typing from datetime import datetime diff --git a/example/proto_pydanticv2/example/example_proto/common/p2p_validate_pb2.py b/example/proto_pydanticv2/example/example_proto/common/p2p_validate_pb2.py index 173948f..c133de1 100644 --- a/example/proto_pydanticv2/example/example_proto/common/p2p_validate_pb2.py +++ b/example/proto_pydanticv2/example/example_proto/common/p2p_validate_pb2.py @@ -22,10 +22,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.common.p2p_validate_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - google_dot_protobuf_dot_descriptor__pb2.MessageOptions.RegisterExtension(ignored) - google_dot_protobuf_dot_descriptor__pb2.OneofOptions.RegisterExtension(required) - google_dot_protobuf_dot_descriptor__pb2.FieldOptions.RegisterExtension(rules) - DESCRIPTOR._options = None _globals['_FIELDRULES']._serialized_start=165 _globals['_FIELDRULES']._serialized_end=1190 diff --git a/example/proto_pydanticv2/example/example_proto/common/single_p2p.py b/example/proto_pydanticv2/example/example_proto/common/single_p2p.py index 87262f0..8d71132 100644 --- a/example/proto_pydanticv2/example/example_proto/common/single_p2p.py +++ b/example/proto_pydanticv2/example/example_proto/common/single_p2p.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 2.0.3 from enum import IntEnum diff --git a/example/proto_pydanticv2/example/example_proto/common/single_pb2.py b/example/proto_pydanticv2/example/example_proto/common/single_pb2.py index 74759b1..d031f8c 100644 --- a/example/proto_pydanticv2/example/example_proto/common/single_pb2.py +++ b/example/proto_pydanticv2/example/example_proto/common/single_pb2.py @@ -19,7 +19,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.common.single_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None _globals['_DEMOENUM']._serialized_start=114 _globals['_DEMOENUM']._serialized_end=152 diff --git a/example/proto_pydanticv2/example/example_proto/common/validate_pb2.py b/example/proto_pydanticv2/example/example_proto/common/validate_pb2.py index ba2aa7f..2135f88 100644 --- a/example/proto_pydanticv2/example/example_proto/common/validate_pb2.py +++ b/example/proto_pydanticv2/example/example_proto/common/validate_pb2.py @@ -22,11 +22,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.common.validate_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - google_dot_protobuf_dot_descriptor__pb2.MessageOptions.RegisterExtension(disabled) - google_dot_protobuf_dot_descriptor__pb2.MessageOptions.RegisterExtension(ignored) - google_dot_protobuf_dot_descriptor__pb2.OneofOptions.RegisterExtension(required) - google_dot_protobuf_dot_descriptor__pb2.FieldOptions.RegisterExtension(rules) - DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b'\n\032io.envoyproxy.pgv.validateZ2github.com/envoyproxy/protoc-gen-validate/validate' _globals['_KNOWNREGEX']._serialized_start=4561 diff --git a/example/proto_pydanticv2/example/example_proto/demo/demo_p2p.py b/example/proto_pydanticv2/example/example_proto/demo/demo_p2p.py index 9973eda..2864b68 100644 --- a/example/proto_pydanticv2/example/example_proto/demo/demo_p2p.py +++ b/example/proto_pydanticv2/example/example_proto/demo/demo_p2p.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 2.0.3 import typing from datetime import datetime diff --git a/example/proto_pydanticv2/example/example_proto/demo/demo_pb2.py b/example/proto_pydanticv2/example/example_proto/demo/demo_pb2.py index 1489acf..3c0ff89 100644 --- a/example/proto_pydanticv2/example/example_proto/demo/demo_pb2.py +++ b/example/proto_pydanticv2/example/example_proto/demo/demo_pb2.py @@ -22,7 +22,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.demo.demo_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None _MAPMESSAGE_USERMAPENTRY._options = None _MAPMESSAGE_USERMAPENTRY._serialized_options = b'8\001' diff --git a/example/proto_pydanticv2/example/example_proto/p2p_validate/demo_p2p.py b/example/proto_pydanticv2/example/example_proto/p2p_validate/demo_p2p.py index e7e7494..4e26b4a 100644 --- a/example/proto_pydanticv2/example/example_proto/p2p_validate/demo_p2p.py +++ b/example/proto_pydanticv2/example/example_proto/p2p_validate/demo_p2p.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 2.0.3 import typing from datetime import datetime, timedelta diff --git a/example/proto_pydanticv2/example/example_proto/p2p_validate/demo_pb2.py b/example/proto_pydanticv2/example/example_proto/p2p_validate/demo_pb2.py index cc06be3..f2f2db4 100644 --- a/example/proto_pydanticv2/example/example_proto/p2p_validate/demo_pb2.py +++ b/example/proto_pydanticv2/example/example_proto/p2p_validate/demo_pb2.py @@ -24,7 +24,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.p2p_validate.demo_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None _FLOATTEST.fields_by_name['const_test']._options = None _FLOATTEST.fields_by_name['const_test']._serialized_options = b'\212C\007\n\005\r\000\000\200?' diff --git a/example/proto_pydanticv2/example/example_proto/validate/demo_p2p.py b/example/proto_pydanticv2/example/example_proto/validate/demo_p2p.py index 8354e77..76e72ff 100644 --- a/example/proto_pydanticv2/example/example_proto/validate/demo_p2p.py +++ b/example/proto_pydanticv2/example/example_proto/validate/demo_p2p.py @@ -1,6 +1,6 @@ # This is an automatically generated file, please do not change # gen by protobuf_to_pydantic[v0.2.0.2](https://github.com/so1n/protobuf_to_pydantic) -# Protobuf Version: 4.24.0 +# Protobuf Version: 4.24.4 # Pydantic Version: 2.0.3 import typing from datetime import datetime, timedelta diff --git a/example/proto_pydanticv2/example/example_proto/validate/demo_pb2.py b/example/proto_pydanticv2/example/example_proto/validate/demo_pb2.py index 8952841..8d57ab5 100644 --- a/example/proto_pydanticv2/example/example_proto/validate/demo_pb2.py +++ b/example/proto_pydanticv2/example/example_proto/validate/demo_pb2.py @@ -24,7 +24,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.validate.demo_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None _FLOATTEST.fields_by_name['const_test']._options = None _FLOATTEST.fields_by_name['const_test']._serialized_options = b'\372B\007\n\005\r\000\000\200?' diff --git a/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py b/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py index f1d0a17..4ce89c2 100644 --- a/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py +++ b/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py @@ -299,10 +299,9 @@ def _message_field_handle( if optional_dict.get(field.name, {}).get("is_proto3_optional", False): type_str = f"typing.Optional[{type_str}]" - if ( - field_info_dict.get("default", _pydantic_adapter.PydanticUndefined) - is _pydantic_adapter.PydanticUndefined - ): + if field_info_dict.get( + "default", _pydantic_adapter.PydanticUndefined + ) is _pydantic_adapter.PydanticUndefined and not field_info_dict.get("default_factory", None): field_info_dict["default"] = None # arranging field info parameters @@ -392,26 +391,24 @@ def _message( if desc.enum_type: class_head_content += self._enum(desc.enum_type, scl_prefix, indent + self.code_indent) - if desc.oneof_decl: - one_of_dict, optional_dict = self._gen_one_of_dict(desc) - if one_of_dict: + if one_of_dict: + class_head_content += ( + f"{' ' * (indent + self.code_indent)}_one_of_dict = {self._get_value_code(one_of_dict)}\n" + ) + + self._add_import_code("protobuf_to_pydantic.customer_validator", "check_one_of") + if _pydantic_adapter.is_v1: class_head_content += ( - f"{' ' * (indent + self.code_indent)}_one_of_dict = {self._get_value_code(one_of_dict)}\n" + f"{' ' * (indent + self.code_indent)}" + f"one_of_validator = root_validator(pre=True, allow_reuse=True)(check_one_of)\n" ) - - self._add_import_code("protobuf_to_pydantic.customer_validator", "check_one_of") - if _pydantic_adapter.is_v1: - class_head_content += ( - f"{' ' * (indent + self.code_indent)}" - f"one_of_validator = root_validator(pre=True, allow_reuse=True)(check_one_of)\n" - ) - self._add_import_code("pydantic", "root_validator") - else: - class_head_content += ( - f"{' ' * (indent + self.code_indent)}" - f'one_of_validator = model_validator(mode="before")(check_one_of)\n' - ) - self._add_import_code("pydantic", "model_validator") + self._add_import_code("pydantic", "root_validator") + else: + class_head_content += ( + f"{' ' * (indent + self.code_indent)}" + f'one_of_validator = model_validator(mode="before")(check_one_of)\n' + ) + self._add_import_code("pydantic", "model_validator") if use_custom_type: if _pydantic_adapter.is_v1: diff --git a/protobuf_to_pydantic/protos/protos/p2p_validate_pb2.py b/protobuf_to_pydantic/protos/protos/p2p_validate_pb2.py index 41dd47c..f4057b2 100644 --- a/protobuf_to_pydantic/protos/protos/p2p_validate_pb2.py +++ b/protobuf_to_pydantic/protos/protos/p2p_validate_pb2.py @@ -22,10 +22,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'protos.p2p_validate_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - google_dot_protobuf_dot_descriptor__pb2.MessageOptions.RegisterExtension(ignored) - google_dot_protobuf_dot_descriptor__pb2.OneofOptions.RegisterExtension(required) - google_dot_protobuf_dot_descriptor__pb2.FieldOptions.RegisterExtension(rules) - DESCRIPTOR._options = None _globals['_FIELDRULES']._serialized_start=143 _globals['_FIELDRULES']._serialized_end=1168 diff --git a/protobuf_to_pydantic/protos/protos/validate_pb2.py b/protobuf_to_pydantic/protos/protos/validate_pb2.py index 142a2ec..72b3e1c 100644 --- a/protobuf_to_pydantic/protos/protos/validate_pb2.py +++ b/protobuf_to_pydantic/protos/protos/validate_pb2.py @@ -22,11 +22,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'protos.validate_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - google_dot_protobuf_dot_descriptor__pb2.MessageOptions.RegisterExtension(disabled) - google_dot_protobuf_dot_descriptor__pb2.MessageOptions.RegisterExtension(ignored) - google_dot_protobuf_dot_descriptor__pb2.OneofOptions.RegisterExtension(required) - google_dot_protobuf_dot_descriptor__pb2.FieldOptions.RegisterExtension(rules) - DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b'\n\032io.envoyproxy.pgv.validateZ2github.com/envoyproxy/protoc-gen-validate/validate' _globals['_KNOWNREGEX']._serialized_start=4539