Repository navigation
bug: generate a valid class name when the project name starts with a digit - #674
Amadeus-22 wants to merge 2 commits into
Conversation
…digit convert_to_class_name only removed non-alphanumeric characters, so a project called '2024 Momentum' got 'class 2024Momentum', which does not compile. Prefix the name with an underscore when it is empty or starts with a digit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Project names such as `none`, `true` or `_class` produced `class None`, `class True` or `class class`, which are syntax errors in Python and C#. Prefix the class name with an underscore when it starts with a lowercase letter or is a Python keyword.
|
Thanks for the fix. I pushed a follow-up commit (e57b0ef) on top of it. Names that still failed with the previous commit The leading-digit case was fixed, but
The second shape also produces C# keywords for C# projects ( What changed
A hyphen-prefixed name such as |
|
Thanks, @jhonabreul. I read e57b0ef. I had only covered the leading digit and missed that capitalizing or stripping the prefix could still land on a keyword ( |
jhonabreul
left a comment
There was a problem hiding this comment.
Thank you for your contribution!
Closes #673.
lean project-create --language python "2024 Momentum"wroteclass 2024Momentum(QCAlgorithm):, which is a syntax error; the same happens for C#. The command still exited with code 0.convert_to_class_namenow prefixes the name with an underscore when it is empty or starts with a digit (_2024Momentum). Other names are unchanged. The same helper is used bylean research.main.py. It fails on master and passes with the fix.pytest tests/commands/test_create_project.py tests/commands/test_research.pypasses (30 tests, Python 3.12) andpython static_analysis.pyis clean.🤖 Generated with Claude Code