project-create generates an invalid class name when the project name starts with a digit
評估
研究方向
Find the code handling the project-create command in the lean-cli codebase, likely in a commands or templates directory. Look for the function that generates class names by removing non-alphanumeric characters from the project name. Add a check to prefix the result with an underscore when it starts with a digit or is empty, then add tests for project names like '2024 Momentum' and '123'.
由索引模型根據 Issue 內容生成。
描述
Expected Behavior
lean project-create writes a main file that compiles, whatever the project name is.
Actual Behavior
The class name is the project name with non-alphanumeric characters removed. If the name starts with a digit, the generated class is not a valid identifier in Python or C#:
$ lean project-create --language python "2024 Momentum"
$ grep class "2024 Momentum/main.py"
class 2024Momentum(QCAlgorithm):
python -m py_compile on that file fails with SyntaxError: invalid decimal literal. A name with only digits (123) gives class 123(QCAlgorithm):. The command exits with code 0 in both cases, so the problem only shows up when the project is run.
Potential Solution
Prefix the class name with an underscore when it is empty or starts with a digit (_2024Momentum). I can open a PR with the fix and tests.
Reproducing the Problem
See the commands above.
System Information
lean-cli master at 20e58aa, Linux.
Checklist
- I have completely filled out this template
- I have confirmed that this issue exists on the current
masterbranch - I have confirmed that this is not a duplicate issue by searching issues
- 主要語言
- Python
- 星號
- 327
- 分支
- 169
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
QuantConnect/lean-cli 的其他 Issue
-
lean cloud live deploy --notify-webhooks fails when the address is a URL可能已有人在做 @Amadeus-22 於 1 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 48/100
QuantConnect/lean-cli#671 ·
-
Docker image with a registry port cannot be parsed可能已有人在做 @Amadeus-22 於 1 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 45/100
QuantConnect/lean-cli#669 ·
-
難度 4/5 3-5 天 新手友好度 55/100
QuantConnect/lean-cli#661 · 1 則留言 ·
-
難度 5/5 一週以上 新手友好度 25/100
QuantConnect/lean-cli#619 ·
-
Implements Autocomplete可能重新可做 @shreejaykurhade 於 194 天前認領,目前沒有進行中的 PR。 未關閉feature
QuantConnect/lean-cli#602 · 6 則留言 · 3 個 reaction · 已指派 1 人 ·
查看 QuantConnect/lean-cli 的全部 Issue
相似的 Issue
-
changelog investigate
難度 2/5 1-3 小時 新手友好度 62/100
ramnes/notion-sdk-py#409 ·
-
good first issue help wanted
難度 2/5 1-3 小時 新手友好度 72/100
lindicaphxag-tech/kaggle#28 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
BSData/horus-heresy-3rd-edition#3211 ·
維護者通常 1 天內回覆
-
bug needs-triage
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆
-
bug tests
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆