File tree 3 files changed +6
-1
lines changed
3 files changed +6
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## 0.13.0 (UNRELEASED)
4
4
5
+ - Fixed ` str_to_snake_case ` utility to capture fully capitalized words followed by an underscore.
6
+
5
7
6
8
## 0.12.0 (2024-02-05)
7
9
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ def str_to_snake_case(name: str) -> str:
55
55
# lower-case letters that optionally start with a single upper-case letter
56
56
lowercase_words = r"[A-Z]?[a-z]+"
57
57
# upper-case letters, excluding last letter if it is followed by a lower-case letter
58
- uppercase_words = r"[A-Z]+(?=[A-Z][a-z]|\d|\W|$)"
58
+ uppercase_words = r"[A-Z]+(?=[A-Z][a-z]|\d|\W|_| $)"
59
59
numbers = r"\d+"
60
60
61
61
words = re .findall (rf"{ lowercase_words } |{ uppercase_words } |{ numbers } " , name )
Original file line number Diff line number Diff line change @@ -84,9 +84,12 @@ class TestClass(Efg):
84
84
("Test" , "test" ),
85
85
("TEST" , "test" ),
86
86
("test_word" , "test_word" ),
87
+ ("TEST_word" , "test_word" ),
88
+ ("testTEST__Word3" , "test_test_word_3" ),
87
89
("TestWord" , "test_word" ),
88
90
("testWord" , "test_word" ),
89
91
("TESTWord" , "test_word" ),
92
+ ("TEST%Word" , "test_word" ),
90
93
("testWORD" , "test_word" ),
91
94
("testW" , "test_w" ),
92
95
("TestW" , "test_w" ),
You can’t perform that action at this time.
0 commit comments