Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit c964fba

Browse files
committed
fix: to_camel_case to produce lower camel case instead of PascalCase where relevant
1 parent 37e3d28 commit c964fba

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

gapic/utils/case.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def to_camel_case(s: str) -> str:
5656
s (str): The input string, provided in any sane case system
5757
5858
Returns:
59-
str: The string in lower camel case with the first letter unchanged.
59+
str: The string in lower camel case.
6060
'''
61-
items = re.split(r'[_-]', s)
62-
return items[0].capitalize() + "".join(x.capitalize() for x in items[1:])
61+
62+
items = re.split(r'[_-]', to_snake_case(s))
63+
return items[0].lower() + "".join(x.capitalize() for x in items[1:])

tests/unit/utils/test_case.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ def test_constant_to_snake():
2828

2929

3030
def test_pascal_to_camel():
31-
assert case.to_camel_case('PascalCaseThing') == 'PascalCaseThing'
31+
assert case.to_camel_case('PascalCaseThing') == 'pascalCaseThing'
3232

3333

3434
def test_snake_to_camel():
3535
assert case.to_camel_case('snake_case_thing') == 'snakeCaseThing'
3636

3737

3838
def test_constant_to_camel():
39-
assert case.to_camel_case('CONSTANT_CASE_THING') == 'ConstantCaseThing'
39+
assert case.to_camel_case('CONSTANT_CASE_THING') == 'constantCaseThing'
4040

4141

4242
def test_kebab_to_camel():

0 commit comments

Comments
 (0)