project-create generates an invalid class name when the project name starts with a digit
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 40/100
Hướng nghiên cứu
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'.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 327
- Fork
- 169
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của QuantConnect/lean-cli
-
lean cloud live deploy --notify-webhooks fails when the address is a URLCó thể đã có người làm @Amadeus-22 đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
QuantConnect/lean-cli#671 ·
-
Docker image with a registry port cannot be parsedCó thể đã có người làm @Amadeus-22 đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
QuantConnect/lean-cli#669 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
QuantConnect/lean-cli#661 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
QuantConnect/lean-cli#619 ·
-
Implements AutocompleteCó thể làm lại được @shreejaykurhade đã nhận 194 ngày trước và không có pull request nào đang mở. Đang mởfeature
QuantConnect/lean-cli#602 · 6 bình luận · 3 reaction · 1 người được giao ·
Tất cả issue của QuantConnect/lean-cli
Issue tương tự
-
changelog investigate
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
ramnes/notion-sdk-py#409 ·
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
lindicaphxag-tech/kaggle#28 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
BSData/horus-heresy-3rd-edition#3211 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày