Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit e279c79

Browse files
Fix builtins with annotations (#81)
* Fix builtin with annotations * Add new tests
1 parent 517c698 commit e279c79

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/betterproto2_compiler/plugin/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,15 @@ def annotations(self) -> list[str]:
441441
def annotation(self) -> str:
442442
py_type = self.py_type
443443

444+
if self.use_builtins:
445+
py_type = f"builtins.{py_type}"
446+
444447
# Add the pydantic annotation if needed
445448
if self.output_file.settings.pydantic_dataclasses:
446449
annotations = self.annotations
447450
if annotations:
448451
py_type = f"typing.Annotated[{py_type}, {', '.join(annotations)}]"
449452

450-
if self.use_builtins:
451-
py_type = f"builtins.{py_type}"
452453
if self.repeated:
453454
return f"list[{py_type}]"
454455
if self.optional:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
syntax = "proto3";
2+
3+
package encoding_decoding;
4+
5+
message Overflow32 {
6+
uint32 uint = 1;
7+
int32 int = 2;
8+
sint32 sint = 3;
9+
}
10+
11+
message Overflow64 {
12+
uint64 uint = 1;
13+
int64 int = 2;
14+
sint64 sint = 3;
15+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
syntax = "proto3";
2+
3+
package manual_validation;
4+
5+
message Msg {
6+
uint32 x = 1;
7+
}

0 commit comments

Comments
 (0)