Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ repos:
args: ["--diff", "betterproto2/src", "betterproto2/tests", "betterproto2_compiler/src", "betterproto2_compiler/tests"]
- id: ruff
args: ["betterproto2/src", "betterproto2/tests", "betterproto2_compiler/src", "betterproto2_compiler/tests"]

- repo: https://github.com/bufbuild/buf
rev: v1.57.2
hooks:
- id: buf-format
files: ^betterproto2_compiler/tests/inputs/.*\.proto$
2 changes: 1 addition & 1 deletion betterproto2/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dev = [
"mkdocs-material>=9.6.14",
"mkdocstrings[python]>=0.29.1",
"mypy>=1.16.0",
"pre-commit>=4.2.0",
"pre-commit>=4.2.0,<5",
"pyright>=1.1.401",
# The Ruff version is pinned. To update it, also update it in .pre-commit-config.yaml
"ruff==0.9.3",
Expand Down
2 changes: 1 addition & 1 deletion betterproto2/uv.lock

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

2 changes: 1 addition & 1 deletion betterproto2_compiler/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protoc-gen-python_betterproto2 = "betterproto2_compiler.plugin:main"

[dependency-groups]
dev = [
"pre-commit>=2.17.0,<3",
"pre-commit>=4.2.0,<5",
"grpcio-tools>=1.54.2,<2",
"poethepoet>=0.32.2,<0.33",
"pyright>=1.1.391,<2",
Expand Down
8 changes: 4 additions & 4 deletions betterproto2_compiler/tests/inputs/any/any.proto
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
syntax = "proto3";

import "google/protobuf/any.proto";

package any;

import "google/protobuf/any.proto";

message Person {
string first_name = 1;
string last_name = 2;
string first_name = 1;
string last_name = 2;
}
2 changes: 1 addition & 1 deletion betterproto2_compiler/tests/inputs/bool/bool.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ syntax = "proto3";
package bool;

message Test {
bool value = 1;
bool value = 1;
}
2 changes: 1 addition & 1 deletion betterproto2_compiler/tests/inputs/bytes/bytes.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ syntax = "proto3";
package bytes;

message Test {
bytes data = 1;
bytes data = 1;
}
4 changes: 1 addition & 3 deletions betterproto2_compiler/tests/inputs/casing/casing.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ message Test {
int32 UPPERCASE = 4;
}

message snake_case_message {

}
message snake_case_message {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ message Test {
sint32 old_exp = 1;
}
inner_class inner = 2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ message Test {
int32 UPPERCASE = 1;
int32 UPPERCASE_V2 = 2;
int32 UPPER_CAMEL_CASE = 3;
}
}
6 changes: 3 additions & 3 deletions betterproto2_compiler/tests/inputs/compiler_lib/plugin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
syntax = "proto2";

package google.protobuf.compiler;
option java_package = "com.google.protobuf.compiler";
option java_outer_classname = "PluginProtos";

import "google/protobuf/descriptor.proto";

option csharp_namespace = "Google.Protobuf.Compiler";
option go_package = "google.golang.org/protobuf/types/pluginpb";
option java_outer_classname = "PluginProtos";
option java_package = "com.google.protobuf.compiler";

// The version number of protocol compiler.
message Version {
Expand Down Expand Up @@ -177,4 +177,4 @@ message CodeGeneratorResponse {
optional GeneratedCodeInfo generated_code_info = 16;
}
repeated File file = 15;
}
}
20 changes: 11 additions & 9 deletions betterproto2_compiler/tests/inputs/deprecated/deprecated.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@ package deprecated;

// Some documentation about the Test message.
message Test {
Message message = 1 [deprecated=true];
int32 value = 2;
message Nested {
int32 nested_value = 1 [deprecated=true];
}
Message message = 1 [deprecated = true];
int32 value = 2;
message Nested {
int32 nested_value = 1 [deprecated = true];
}
}

message Message {
option deprecated = true;
string value = 1;
option deprecated = true;
string value = 1;
}

message Empty {}

service TestService {
rpc func(Empty) returns (Empty);
rpc deprecated_func(Empty) returns (Empty) { option deprecated = true; };
rpc func(Empty) returns (Empty);
rpc deprecated_func(Empty) returns (Empty) {
option deprecated = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ package documentation;
// Documentation of message 2
// other line 2
message Test { // Documentation of message 3
// Documentation of field 1
// other line 1
// Documentation of field 1
// other line 1

// Documentation of field 2
// other line 2
uint32 x = 1; // Documentation of field 3
// Documentation of field 2
// other line 2
uint32 x = 1; // Documentation of field 3

// Documentation of oneof 1
// Documentation of oneof 1
// other line 1

// Documentation of oneof 2
// other line 2
oneof oneof_example { // Documentation of oneof 3
// Documentation of oneof field 1
// other line 1

// Documentation of oneof 2
// Documentation of oneof field 2
// other line 2
oneof oneof_example { // Documentation of oneof 3
// Documentation of oneof field 1
// other line 1

// Documentation of oneof field 2
// other line 2
int32 a = 2; // Documentation of oneof field 3
}
int32 a = 2; // Documentation of oneof field 3
}
}

// Documentation of enum 1
Expand All @@ -35,12 +35,12 @@ message Test { // Documentation of message 3
// Documentation of enum 2
// other line 2
enum Enum { // Documentation of enum 3
// Documentation of variant 1
// other line 1
// Documentation of variant 1
// other line 1

// Documentation of variant 2
// other line 2
Enum_Variant = 0; // Documentation of variant 3
// Documentation of variant 2
// other line 2
Enum_Variant = 0; // Documentation of variant 3
}

// Documentation of service 1
Expand All @@ -49,12 +49,12 @@ enum Enum { // Documentation of enum 3
// Documentation of service 2
// other line 2
service Service { // Documentation of service 3
// Documentation of method 1
// other line 1
// Documentation of method 1
// other line 1

// Documentation of method 2
// other line 2
rpc get(Test) returns (Test); // Documentation of method 3
// Documentation of method 2
// other line 2
rpc get(Test) returns (Test); // Documentation of method 3
}

// A comment with backslashes \ and triple quotes """
Expand Down
2 changes: 1 addition & 1 deletion betterproto2_compiler/tests/inputs/double/double.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ syntax = "proto3";
package double;

message Test {
double count = 1;
double count = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ syntax = "proto3";

package empty_service;

service Test {
}
service Test {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ syntax = "proto3";
package encoding_decoding;

message Overflow32 {
uint32 uint = 1;
int32 int = 2;
sint32 sint = 3;
uint32 uint = 1;
int32 int = 2;
sint32 sint = 3;
}

message Overflow64 {
uint64 uint = 1;
int64 int = 2;
sint64 sint = 3;
uint64 uint = 1;
int64 int = 2;
sint64 sint = 3;
}
4 changes: 2 additions & 2 deletions betterproto2_compiler/tests/inputs/entry/entry.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ package entry;
// error because the parent type does not have a "nested_type" attribute.

message Test {
repeated ExportEntry export = 1;
repeated ExportEntry export = 1;
}

message ExportEntry {
string name = 1;
string name = 1;
}
58 changes: 29 additions & 29 deletions betterproto2_compiler/tests/inputs/enum/enum.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,64 @@ package enum;

// Tests that enums are correctly serialized and that it correctly handles skipped and out-of-order enum values
message Test {
Choice choice = 1;
repeated Choice choices = 2;
Choice choice = 1;
repeated Choice choices = 2;
}

enum Choice {
ZERO = 0;
ONE = 1;
// TWO = 2;
FOUR = 4;
THREE = 3;
MINUS_ONE = -1;
ZERO = 0;
ONE = 1;
// TWO = 2;
FOUR = 4;
THREE = 3;
MINUS_ONE = -1;
}

// A "C" like enum with the enum name prefixed onto members, these should be stripped
enum ArithmeticOperator {
ARITHMETIC_OPERATOR_NONE = 0;
ARITHMETIC_OPERATOR_PLUS = 1;
ARITHMETIC_OPERATOR_MINUS = 2;
ARITHMETIC_OPERATOR_0_PREFIXED = 3;
ARITHMETIC_OPERATOR_NONE = 0;
ARITHMETIC_OPERATOR_PLUS = 1;
ARITHMETIC_OPERATOR_MINUS = 2;
ARITHMETIC_OPERATOR_0_PREFIXED = 3;
}

// If not all the fields are prefixed, the prefix should not be stripped at all
enum NoStriping {
NO_STRIPING_NONE = 0;
NO_STRIPING_A = 1;
B = 2;
NO_STRIPING_NONE = 0;
NO_STRIPING_A = 1;
B = 2;
}

// Make sure that the prefix are removed even if it's difficult to infer the position
// of underscores.
enum HTTPCode {
HTTP_CODE_UNSPECIFIED = 0;
HTTP_CODE_OK = 200;
HTTP_CODE_NOT_FOUND = 404;
HTTP_CODE_UNSPECIFIED = 0;
HTTP_CODE_OK = 200;
HTTP_CODE_NOT_FOUND = 404;
}

message EnumMessage {
ArithmeticOperator arithmetic_operator = 1;
NoStriping no_striping = 2;
ArithmeticOperator arithmetic_operator = 1;
NoStriping no_striping = 2;
}

enum OldVersion {
OLD_VERSION_UNSPECIFIED = 0;
OLD_VERSION_V1 = 1;
OLD_VERSION_V2 = 2;
OLD_VERSION_UNSPECIFIED = 0;
OLD_VERSION_V1 = 1;
OLD_VERSION_V2 = 2;
}

message OldVersionMessage {
OldVersion old_version = 1;
OldVersion old_version = 1;
}

enum NewVersion {
NEW_VERSION_UNSPECIFIED = 0;
NEW_VERSION_V1 = 1;
NEW_VERSION_V2 = 2;
NEW_VERSION_V3 = 3;
NEW_VERSION_UNSPECIFIED = 0;
NEW_VERSION_V1 = 1;
NEW_VERSION_V2 = 2;
NEW_VERSION_V3 = 3;
}

message NewVersionMessage {
NewVersion new_version = 1;
NewVersion new_version = 1;
}
Loading
Loading