Repository navigation
Fix short acronym boundaries in camel_to_underscore - #57
Merged
Merged
Conversation
wolph
added a commit
that referenced
this pull request
Oct 11, 2026
#57 moved the acronym boundary check from three preceding capitals to two, which split a plural acronym before its trailing s: IDs became i_ds and UserIDs became user_i_ds, where 4.1.0 returned ids and user_ids. A lone s that ends the word now stays with the acronym, which also turns GetURLs into get_urls instead of get_ur_ls.
Owner
|
That's a silly one indeed, the boundary check never looked at short acronyms. Thank you for the fix and the tests! I've built on top of it in 1bb0458 so plural acronyms like |
Owner
|
I've created a new release (v4.1.1) which includes your fix, thanks again for the help :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
camel_to_underscore("IPad")currently returns"ipad", and"ABCd"returns"abcd". The acronym boundary check requires three preceding capitals and an offset greater than three, so it misses short acronyms and boundaries near the beginning of a name.Check the two preceding letters instead. This returns
"i_pad"and"ab_cd", keeps the final capital with the following word, and preserves existing underscore/digit behavior. Add regression cases for short prefixes, leading underscores, and a longer acronym.Validation on Python 3.12:
Prepared with AI assistance and verified locally.