Odd behaviour of snake_case functions
まだ誰も着手していません。
評価
調査の方向性
まず、Python ジェネレーター内の utils.snake_case と split_words の実装を見つけます。issue の例を再現し、混在した snake_case と camelCase の入力が期待される単語を生成すること、また MODEL4dd のケースが 1 つの単語のままであることを確認します。関連する utility テストがあれば追加または実行します。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 2k
- フォーク
- 293
- 平均マージ
- 34分
- マージ済み PR(30日)
- 1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
openapi-generators/openapi-python-client のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
openapi-generators/openapi-python-client#1451 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
openapi-generators/openapi-python-client#1435 · コメント 1 件 ·
openapi-generators/openapi-python-client の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
zostera/django-bootstrap4#894 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
use-agent-os/agent-os#3276 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
NousResearch/hermes-agent#117848 ·