Skip to content

bug: generate a valid class name when the project name starts with a digit - #674

Open
Amadeus-22 wants to merge 1 commit into
QuantConnect:masterfrom
Amadeus-22:bug-673-class-name-leading-digit
Open

Amadeus-22 wants to merge 1 commit into
QuantConnect:masterfrom
Amadeus-22:bug-673-class-name-leading-digit

Conversation

@Amadeus-22

Copy link
Copy Markdown

Closes #673.

  • lean project-create --language python "2024 Momentum" wrote class 2024Momentum(QCAlgorithm):, which is a syntax error; the same happens for C#. The command still exited with code 0.
  • convert_to_class_name now 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 by lean research.
  • Added a parametrized test that creates the project and compiles the generated main.py. It fails on master and passes with the fix.
  • pytest tests/commands/test_create_project.py tests/commands/test_research.py passes (30 tests, Python 3.12) and python static_analysis.py is clean.

🤖 Generated with Claude Code

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

project-create generates an invalid class name when the project name starts with a digit

1 participant