Skip to content

Commit 3afffca

Browse files
committed
Fix for names starting with ints
1 parent 6fe9b5c commit 3afffca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/betterproto/casing.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,8 @@ def lowercase_first(value: str) -> str:
135135

136136
def sanitize_name(value: str) -> str:
137137
# https://www.python.org/dev/peps/pep-0008/#descriptive-naming-styles
138-
return f"{value}_" if keyword.iskeyword(value) else value
138+
if keyword.iskeyword(value):
139+
return f"{value}_"
140+
if value[0].isdigit():
141+
return f"_{value}"
142+
return value

0 commit comments

Comments
 (0)