diff --git a/src/betterproto/casing.py b/src/betterproto/casing.py index cd3c34472..ed8299135 100644 --- a/src/betterproto/casing.py +++ b/src/betterproto/casing.py @@ -133,6 +133,16 @@ def lowercase_first(value: str) -> str: return value[0:1].lower() + value[1:] +def is_reserved_name(value: str) -> bool: + if keyword.iskeyword(value): + return True + + if value in ("bytes", "str"): + return True + + return False + + def sanitize_name(value: str) -> str: # https://www.python.org/dev/peps/pep-0008/#descriptive-naming-styles - return f"{value}_" if keyword.iskeyword(value) else value + return f"{value}_" if is_reserved_name(value) else value diff --git a/tests/inputs/config.py b/tests/inputs/config.py index 9b7b288d3..d72fc24e7 100644 --- a/tests/inputs/config.py +++ b/tests/inputs/config.py @@ -3,7 +3,6 @@ xfail = { "oneof_enum", # 63 "namespace_keywords", # 70 - "namespace_builtin_types", # 53 "googletypes_struct", # 9 "googletypes_value", # 9 "import_capitalized_package",