prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Unexpected Snake Case for Acronyms
  The snake case conversion of the `snake_case_fallback_resolvers` yields unexpected results for words with multiple uppercase letters in a row, e.g.
   - `getHTTPResponse` is converted to `get_h_t_t_p_response`, or
   - `externalID` is converted to "external_i_d`.  
  
  These are unlikely names for python attributes and I would expect the resolver to look for `get_http_response` / `external_id` instead.
  
  Possible implementations for the camel to snake case conversions are discussed here: https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case
  Unexpected Snake Case for Acronyms
  The snake case conversion of the `snake_case_fallback_resolvers` yields unexpected results for words with multiple uppercase letters in a row, e.g.
   - `getHTTPResponse` is converted to `get_h_t_t_p_response`, or
   - `externalID` is converted to "external_i_d`.  
  
  These are unlikely names for python attributes and I would expect the resolver to look for `get_http_response` / `external_id` instead.
  
  Possible implementations for the camel to snake case conversions are discussed here: https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case
  
  </issue>
  <code>
  [start of ariadne/utils.py]
  1 import asyncio
  2 from functools import wraps
  3 from typing import Optional, Union, Callable, Dict, Any
  4 
  5 from graphql import GraphQLError, parse
  6 
  7 
  8 def convert_camel_case_to_snake(graphql_name: str) -> str:
  9     python_name = ""
  10     for i, c in enumerate(graphql_name.lower()):
  11         if (
  12             i > 0
  13             and (
  14                 all(
  15                     (
  16                         c != graphql_name[i],
  17                         graphql_name[i - 1] != "_",
  18                         graphql_name[i - 1] == python_name[-1],
  19                     )
  20                 )
  21             )
  22             or all((c.isdigit(), graphql_name[i - 1].isdigit() is False))
  23         ):
  24             python_name += "_"
  25         python_name += c
  26     return python_name
  27 
  28 
  29 def gql(value: str) -> str:
  30     parse(value)
  31     return value
  32 
  33 
  34 def unwrap_graphql_error(
  35     error: Union[GraphQLError, Optional[Exception]]
  36 ) -> Optional[Exception]:
  37     if isinstance(error, GraphQLError):
  38         return unwrap_graphql_error(error.original_error)
  39     return error
  40 
  41 
  42 def convert_kwargs_to_snake_case(func: Callable) -> Callable:
  43     def convert_to_snake_case(d: Dict) -> Dict:
  44         converted: Dict = {}
  45         for k, v in d.items():
  46             if isinstance(v, dict):
  47                 v = convert_to_snake_case(v)
  48             if isinstance(v, list):
  49                 v = [convert_to_snake_case(i) if isinstance(i, dict) else i for i in v]
  50             converted[convert_camel_case_to_snake(k)] = v
  51         return converted
  52 
  53     if asyncio.iscoroutinefunction(func):
  54 
  55         @wraps(func)
  56         async def async_wrapper(*args: Any, **kwargs: Any) -> Any:
  57             return await func(*args, **convert_to_snake_case(kwargs))
  58 
  59         return async_wrapper
  60 
  61     @wraps(func)
  62     def wrapper(*args: Any, **kwargs: Any) -> Any:
  63         return func(*args, **convert_to_snake_case(kwargs))
  64 
  65     return wrapper
  66
  [end of ariadne/utils.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/ariadne/utils.py b/ariadne/utils.py
  --- a/ariadne/utils.py
  +++ b/ariadne/utils.py
  @@ -6,20 +6,29 @@
   
   
   def convert_camel_case_to_snake(graphql_name: str) -> str:
  +    # pylint: disable=too-many-boolean-expressions
  +    max_index = len(graphql_name) - 1
  +    lowered_name = graphql_name.lower()
  +
       python_name = ""
  -    for i, c in enumerate(graphql_name.lower()):
  -        if (
  -            i > 0
  -            and (
  -                all(
  -                    (
  -                        c != graphql_name[i],
  -                        graphql_name[i - 1] != "_",
  -                        graphql_name[i - 1] == python_name[-1],
  -                    )
  -                )
  +    for i, c in enumerate(lowered_name):
  +        if i > 0 and (
  +            # testWord -> test_word
  +            (
  +                c != graphql_name[i]
  +                and graphql_name[i - 1] != "_"
  +                and graphql_name[i - 1] == python_name[-1]
  +            )
  +            # TESTWord -> test_word
  +            or (
  +                i < max_index
  +                and graphql_name[i] != lowered_name[i]
  +                and graphql_name[i + 1] == lowered_name[i + 1]
               )
  -            or all((c.isdigit(), graphql_name[i - 1].isdigit() is False))
  +            # test134 -> test_134
  +            or (c.isdigit() and not graphql_name[i - 1].isdigit())
  +            # 134test -> 134_test
  +            or (not c.isdigit() and graphql_name[i - 1].isdigit())
           ):
               python_name += "_"
           python_name += c
  
verification_info: {"golden_diff": "diff --git a/ariadne/utils.py b/ariadne/utils.py\n--- a/ariadne/utils.py\n+++ b/ariadne/utils.py\n@@ -6,20 +6,29 @@\n \n \n def convert_camel_case_to_snake(graphql_name: str) -> str:\n+    # pylint: disable=too-many-boolean-expressions\n+    max_index = len(graphql_name) - 1\n+    lowered_name = graphql_name.lower()\n+\n     python_name = \"\"\n-    for i, c in enumerate(graphql_name.lower()):\n-        if (\n-            i > 0\n-            and (\n-                all(\n-                    (\n-                        c != graphql_name[i],\n-                        graphql_name[i - 1] != \"_\",\n-                        graphql_name[i - 1] == python_name[-1],\n-                    )\n-                )\n+    for i, c in enumerate(lowered_name):\n+        if i > 0 and (\n+            # testWord -> test_word\n+            (\n+                c != graphql_name[i]\n+                and graphql_name[i - 1] != \"_\"\n+                and graphql_name[i - 1] == python_name[-1]\n+            )\n+            # TESTWord -> test_word\n+            or (\n+                i < max_index\n+                and graphql_name[i] != lowered_name[i]\n+                and graphql_name[i + 1] == lowered_name[i + 1]\n             )\n-            or all((c.isdigit(), graphql_name[i - 1].isdigit() is False))\n+            # test134 -> test_134\n+            or (c.isdigit() and not graphql_name[i - 1].isdigit())\n+            # 134test -> 134_test\n+            or (not c.isdigit() and graphql_name[i - 1].isdigit())\n         ):\n             python_name += \"_\"\n         python_name += c\n", "issue": "Unexpected Snake Case for Acronyms\nThe snake case conversion of the `snake_case_fallback_resolvers` yields unexpected results for words with multiple uppercase letters in a row, e.g.\r\n - `getHTTPResponse` is converted to `get_h_t_t_p_response`, or\r\n - `externalID` is converted to \"external_i_d`.  \r\n\r\nThese are unlikely names for python attributes and I would expect the resolver to look for `get_http_response` / `external_id` instead.\r\n\r\nPossible implementations for the camel to snake case conversions are discussed here: https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case\nUnexpected Snake Case for Acronyms\nThe snake case conversion of the `snake_case_fallback_resolvers` yields unexpected results for words with multiple uppercase letters in a row, e.g.\r\n - `getHTTPResponse` is converted to `get_h_t_t_p_response`, or\r\n - `externalID` is converted to \"external_i_d`.  \r\n\r\nThese are unlikely names for python attributes and I would expect the resolver to look for `get_http_response` / `external_id` instead.\r\n\r\nPossible implementations for the camel to snake case conversions are discussed here: https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case\n", "before_files": [{"content": "import asyncio\nfrom functools import wraps\nfrom typing import Optional, Union, Callable, Dict, Any\n\nfrom graphql import GraphQLError, parse\n\n\ndef convert_camel_case_to_snake(graphql_name: str) -> str:\n    python_name = \"\"\n    for i, c in enumerate(graphql_name.lower()):\n        if (\n            i > 0\n            and (\n                all(\n                    (\n                        c != graphql_name[i],\n                        graphql_name[i - 1] != \"_\",\n                        graphql_name[i - 1] == python_name[-1],\n                    )\n                )\n            )\n            or all((c.isdigit(), graphql_name[i - 1].isdigit() is False))\n        ):\n            python_name += \"_\"\n        python_name += c\n    return python_name\n\n\ndef gql(value: str) -> str:\n    parse(value)\n    return value\n\n\ndef unwrap_graphql_error(\n    error: Union[GraphQLError, Optional[Exception]]\n) -> Optional[Exception]:\n    if isinstance(error, GraphQLError):\n        return unwrap_graphql_error(error.original_error)\n    return error\n\n\ndef convert_kwargs_to_snake_case(func: Callable) -> Callable:\n    def convert_to_snake_case(d: Dict) -> Dict:\n        converted: Dict = {}\n        for k, v in d.items():\n            if isinstance(v, dict):\n                v = convert_to_snake_case(v)\n            if isinstance(v, list):\n                v = [convert_to_snake_case(i) if isinstance(i, dict) else i for i in v]\n            converted[convert_camel_case_to_snake(k)] = v\n        return converted\n\n    if asyncio.iscoroutinefunction(func):\n\n        @wraps(func)\n        async def async_wrapper(*args: Any, **kwargs: Any) -> Any:\n            return await func(*args, **convert_to_snake_case(kwargs))\n\n        return async_wrapper\n\n    @wraps(func)\n    def wrapper(*args: Any, **kwargs: Any) -> Any:\n        return func(*args, **convert_to_snake_case(kwargs))\n\n    return wrapper\n", "path": "ariadne/utils.py"}]}