Odd behaviour of snake_case functions
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu bằng cách tìm các phần triển khai utils.snake_case và split_words trong trình tạo Python. Tái hiện các ví dụ từ issue, sau đó xác minh rằng các đầu vào kết hợp snake_case và camelCase tạo ra các từ như mong đợi và các trường hợp MODEL4dd vẫn là một từ; thêm hoặc chạy các bài kiểm thử tiện ích liên quan nếu có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
The names of apis are odd, having '_' in irregular and unpredictable places
To Reproduce
The following behavior can be observed using the snake_case function from utils:
utils.snake_case("get_v2_abc")
'get_v2_abc'
utils.snake_case("get_v2_abc_deFgHij")
'get_v_2_abc_de_fg_hij'
These would for example be created for paths: /v2/abc and /v2/abc/deFgHij
The results however inserts an additional underscore between v and 2, so v_2 instead of v2.
Expected behavior
results should be:
get_v2_abc_de_fg_hij
Desktop (please complete the following information):
- OS: CentOS7
- Python Version: 3.8
- openapi-python-client version: github-master from today
Suggestion:
snake_case uses split_words function , which only splits on Aa, so a capital letter followed by a lowercase one, not on underscore. split_words should first split on underscore, then split on capital followed by lowercase. This would solve the issue of mixed snake and camelcase names.
Some additional odd outcomes:
>>> utils.snake_case("MODEL4dd")
'model4_dd'
>>> utils.snake_case("MODEl4dd")
'mod_el_4_dd'
These of course violate camelCase, but in my estimate should all be treated as one word, i.e. multiple consecutive capital letters are treated as a single block. So above model4dd would be the outcome in both cases.
- Ngôn ngữ chính
- Python
- Star
- 2k
- Fork
- 293
- Merge trung bình
- 34 phút
- Pull request đã merge (30 ngày)
- 1
Hướng dẫn đóng góp
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 openapi-generators/openapi-python-client
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
openapi-generators/openapi-python-client#1451 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
openapi-generators/openapi-python-client#1435 · 1 bình luận ·
Tất cả issue của openapi-generators/openapi-python-client
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
zostera/django-bootstrap4#894 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
use-agent-os/agent-os#3276 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NousResearch/hermes-agent#117848 ·