Skip to content

Commit 646d0ee

Browse files
vaszigsergei-maertens
authored andcommitted
[#5074] Use camel_to_underscore from the library instead of re-implementing this
1 parent abfe009 commit 646d0ee

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

src/openforms/api/utils.py

-7
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ def underscore_to_camel(input_: str | int) -> str:
2323
return re.sub(camelize_re, _underscore_to_camel, input_)
2424

2525

26-
def camel_to_underscore(input: str) -> str:
27-
"""
28-
Convert a string from camelCase to snake_case
29-
"""
30-
return re.sub(r"(?<!^)(?=[A-Z])", "_", input).lower()
31-
32-
3326
def get_from_serializer_data_or_instance(
3427
field: str, data: Mapping, serializer: Serializer
3528
) -> Any:

src/openforms/registrations/contrib/json_dump/plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
from django.db.models.functions import Coalesce, NullIf
1010
from django.utils.translation import gettext_lazy as _
1111

12+
from djangorestframework_camel_case.util import camel_to_underscore
1213
from zgw_consumers.client import build_client
1314

14-
from openforms.api.utils import camel_to_underscore
1515
from openforms.formio.constants import DataSrcOptions
1616
from openforms.formio.service import rewrite_formio_components
1717
from openforms.formio.typing import (

src/openforms/registrations/contrib/objects_api/handlers/v2.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
from datetime import date, datetime
88
from typing import assert_never, cast
99

10+
from djangorestframework_camel_case.util import camel_to_underscore
1011
from glom import Assign, Path, glom
1112

12-
from openforms.api.utils import camel_to_underscore, underscore_to_camel
13+
from openforms.api.utils import underscore_to_camel
1314
from openforms.formio.service import FormioData
1415
from openforms.formio.typing import Component, EditGridComponent
1516
from openforms.formio.typing.vanilla import FileComponent

0 commit comments

Comments
 (0)