Skip to content

Commit fd945ae

Browse files
committed
Handle symbols with leading numbers and convert spaces to _ in
normalize_symbol.
1 parent 9abfd63 commit fd945ae

File tree

1 file changed

+3
-1
lines changed
  • src/openapi_python_generator/language_converters/python

1 file changed

+3
-1
lines changed

src/openapi_python_generator/language_converters/python/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ def normalize_symbol(symbol: str) -> str:
4949
:param symbol: name of the identifier
5050
:return: normalized identifier name
5151
"""
52-
symbol = symbol.replace("-", "_")
52+
symbol = symbol.replace("-", "_").replace(" ", "_")
5353
normalized_symbol = _symbol_ascii_strip_re.sub("", symbol)
5454
if normalized_symbol in keyword.kwlist:
5555
normalized_symbol = normalized_symbol + "_"
56+
if len(normalized_symbol) > 0 and normalized_symbol[0].isnumeric():
57+
normalized_symbol = "_" + normalized_symbol
5658
return normalized_symbol

0 commit comments

Comments
 (0)