prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Method `given_function_called` should only take the function name into account.
  # Bug report
  
  ## What's wrong
  
  The method `given_function_called(node: ast.Call, to_check: Container[str]) -> str` in `logic.tree.functions` is described as a method that returns the name of the function being called in `node`, in case it is included in `to_check`. For example:
   ```python
  # Let's imagine we are visiting the Call node in `print(123, 456)` stored in `node`
  called_function = given_function_called(node, ['print'])
  print(called_function)
  # Prints `print`
  # But, if we are visiting `datetime.timedelta(days=1)`
  called_function = given_function_called(node, ['timedelta'])
  print(called_function)
  # Prints an empty string, as if `timedelta` had not been called. The way for it to be shown is:
  called_function = given_function_called(node, ['datetime.timedelta'])
  print(called_function)
  # Prints `datetime.timedelta`
  ```
  
  This is related to https://github.com/wemake-services/wemake-python-styleguide/pull/1676#discussion_r508471791
  
  ## How is that should be
  
  ```python
  # If we are visiting `datetime.timedelta(days=1)`
  called_function = given_function_called(node, ['timedelta'])
  print(called_function)
  # Prints `timedelta`
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `wemake_python_styleguide/logic/tree/functions.py`
  Content:
  ```
  1 from ast import Call, Yield, YieldFrom, arg
  2 from typing import Container, List, Optional
  3 
  4 from wemake_python_styleguide.compat.functions import get_posonlyargs
  5 from wemake_python_styleguide.logic import source
  6 from wemake_python_styleguide.logic.walk import is_contained
  7 from wemake_python_styleguide.types import (
  8     AnyFunctionDef,
  9     AnyFunctionDefAndLambda,
  10 )
  11 
  12 
  13 def given_function_called(node: Call, to_check: Container[str]) -> str:
  14     """
  15     Returns function name if it is called and contained in the container.
  16 
  17     >>> import ast
  18     >>> module = ast.parse('print(123, 456)')
  19     >>> given_function_called(module.body[0].value, ['print'])
  20     'print'
  21 
  22     >>> given_function_called(module.body[0].value, ['adjust'])
  23     ''
  24 
  25     """
  26     function_name = source.node_to_string(node.func)
  27     if function_name in to_check:
  28         return function_name
  29     return ''
  30 
  31 
  32 def is_method(function_type: Optional[str]) -> bool:
  33     """
  34     Returns whether a given function type belongs to a class.
  35 
  36     >>> is_method('function')
  37     False
  38 
  39     >>> is_method(None)
  40     False
  41 
  42     >>> is_method('method')
  43     True
  44 
  45     >>> is_method('classmethod')
  46     True
  47 
  48     >>> is_method('staticmethod')
  49     True
  50 
  51     >>> is_method('')
  52     False
  53 
  54     """
  55     return function_type in {'method', 'classmethod', 'staticmethod'}
  56 
  57 
  58 def get_all_arguments(node: AnyFunctionDefAndLambda) -> List[arg]:
  59     """
  60     Returns list of all arguments that exist in a function.
  61 
  62     Respects the correct parameters order.
  63     Positional only args, regular argument,
  64     ``*args``, keyword-only, ``**kwargs``.
  65 
  66     Positional only args are only added for ``python3.8+``
  67     other versions are ignoring this type of arguments.
  68     """
  69     names = [
  70         *get_posonlyargs(node),
  71         *node.args.args,
  72     ]
  73 
  74     if node.args.vararg:
  75         names.append(node.args.vararg)
  76 
  77     names.extend(node.args.kwonlyargs)
  78 
  79     if node.args.kwarg:
  80         names.append(node.args.kwarg)
  81 
  82     return names
  83 
  84 
  85 def is_first_argument(node: AnyFunctionDefAndLambda, name: str) -> bool:
  86     """Tells whether an argument name is the logically first in function."""
  87     positional_args = [
  88         *get_posonlyargs(node),
  89         *node.args.args,
  90     ]
  91 
  92     if not positional_args:
  93         return False
  94 
  95     return name == positional_args[0].arg
  96 
  97 
  98 def is_generator(node: AnyFunctionDef) -> bool:
  99     """Tells whether a given function is a generator."""
  100     for body_item in node.body:
  101         if is_contained(node=body_item, to_check=(Yield, YieldFrom)):
  102             return True
  103     return False
  104
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/wemake_python_styleguide/logic/tree/functions.py b/wemake_python_styleguide/logic/tree/functions.py
  --- a/wemake_python_styleguide/logic/tree/functions.py
  +++ b/wemake_python_styleguide/logic/tree/functions.py
  @@ -10,20 +10,21 @@
   )
   
   
  -def given_function_called(node: Call, to_check: Container[str]) -> str:
  +def given_function_called(
  +    node: Call,
  +    to_check: Container[str],
  +    *,
  +    split_modules: bool = False,
  +) -> str:
       """
       Returns function name if it is called and contained in the container.
   
  -    >>> import ast
  -    >>> module = ast.parse('print(123, 456)')
  -    >>> given_function_called(module.body[0].value, ['print'])
  -    'print'
  -
  -    >>> given_function_called(module.body[0].value, ['adjust'])
  -    ''
  -
  +    If `split_modules`, takes the modules or objects into account. Otherwise,
  +    it only cares about the function's name.
       """
       function_name = source.node_to_string(node.func)
  +    if split_modules:
  +        function_name = function_name.split('.')[-1]
       if function_name in to_check:
           return function_name
       return ''
  
verification_info: {"golden_diff": "diff --git a/wemake_python_styleguide/logic/tree/functions.py b/wemake_python_styleguide/logic/tree/functions.py\n--- a/wemake_python_styleguide/logic/tree/functions.py\n+++ b/wemake_python_styleguide/logic/tree/functions.py\n@@ -10,20 +10,21 @@\n )\n \n \n-def given_function_called(node: Call, to_check: Container[str]) -> str:\n+def given_function_called(\n+    node: Call,\n+    to_check: Container[str],\n+    *,\n+    split_modules: bool = False,\n+) -> str:\n     \"\"\"\n     Returns function name if it is called and contained in the container.\n \n-    >>> import ast\n-    >>> module = ast.parse('print(123, 456)')\n-    >>> given_function_called(module.body[0].value, ['print'])\n-    'print'\n-\n-    >>> given_function_called(module.body[0].value, ['adjust'])\n-    ''\n-\n+    If `split_modules`, takes the modules or objects into account. Otherwise,\n+    it only cares about the function's name.\n     \"\"\"\n     function_name = source.node_to_string(node.func)\n+    if split_modules:\n+        function_name = function_name.split('.')[-1]\n     if function_name in to_check:\n         return function_name\n     return ''\n", "issue": "Method `given_function_called` should only take the function name into account.\n# Bug report\r\n\r\n## What's wrong\r\n\r\nThe method `given_function_called(node: ast.Call, to_check: Container[str]) -> str` in `logic.tree.functions` is described as a method that returns the name of the function being called in `node`, in case it is included in `to_check`. For example:\r\n ```python\r\n# Let's imagine we are visiting the Call node in `print(123, 456)` stored in `node`\r\ncalled_function = given_function_called(node, ['print'])\r\nprint(called_function)\r\n# Prints `print`\r\n# But, if we are visiting `datetime.timedelta(days=1)`\r\ncalled_function = given_function_called(node, ['timedelta'])\r\nprint(called_function)\r\n# Prints an empty string, as if `timedelta` had not been called. The way for it to be shown is:\r\ncalled_function = given_function_called(node, ['datetime.timedelta'])\r\nprint(called_function)\r\n# Prints `datetime.timedelta`\r\n```\r\n\r\nThis is related to https://github.com/wemake-services/wemake-python-styleguide/pull/1676#discussion_r508471791\r\n\r\n## How is that should be\r\n\r\n```python\r\n# If we are visiting `datetime.timedelta(days=1)`\r\ncalled_function = given_function_called(node, ['timedelta'])\r\nprint(called_function)\r\n# Prints `timedelta`\r\n```\r\n\n", "before_files": [{"content": "from ast import Call, Yield, YieldFrom, arg\nfrom typing import Container, List, Optional\n\nfrom wemake_python_styleguide.compat.functions import get_posonlyargs\nfrom wemake_python_styleguide.logic import source\nfrom wemake_python_styleguide.logic.walk import is_contained\nfrom wemake_python_styleguide.types import (\n    AnyFunctionDef,\n    AnyFunctionDefAndLambda,\n)\n\n\ndef given_function_called(node: Call, to_check: Container[str]) -> str:\n    \"\"\"\n    Returns function name if it is called and contained in the container.\n\n    >>> import ast\n    >>> module = ast.parse('print(123, 456)')\n    >>> given_function_called(module.body[0].value, ['print'])\n    'print'\n\n    >>> given_function_called(module.body[0].value, ['adjust'])\n    ''\n\n    \"\"\"\n    function_name = source.node_to_string(node.func)\n    if function_name in to_check:\n        return function_name\n    return ''\n\n\ndef is_method(function_type: Optional[str]) -> bool:\n    \"\"\"\n    Returns whether a given function type belongs to a class.\n\n    >>> is_method('function')\n    False\n\n    >>> is_method(None)\n    False\n\n    >>> is_method('method')\n    True\n\n    >>> is_method('classmethod')\n    True\n\n    >>> is_method('staticmethod')\n    True\n\n    >>> is_method('')\n    False\n\n    \"\"\"\n    return function_type in {'method', 'classmethod', 'staticmethod'}\n\n\ndef get_all_arguments(node: AnyFunctionDefAndLambda) -> List[arg]:\n    \"\"\"\n    Returns list of all arguments that exist in a function.\n\n    Respects the correct parameters order.\n    Positional only args, regular argument,\n    ``*args``, keyword-only, ``**kwargs``.\n\n    Positional only args are only added for ``python3.8+``\n    other versions are ignoring this type of arguments.\n    \"\"\"\n    names = [\n        *get_posonlyargs(node),\n        *node.args.args,\n    ]\n\n    if node.args.vararg:\n        names.append(node.args.vararg)\n\n    names.extend(node.args.kwonlyargs)\n\n    if node.args.kwarg:\n        names.append(node.args.kwarg)\n\n    return names\n\n\ndef is_first_argument(node: AnyFunctionDefAndLambda, name: str) -> bool:\n    \"\"\"Tells whether an argument name is the logically first in function.\"\"\"\n    positional_args = [\n        *get_posonlyargs(node),\n        *node.args.args,\n    ]\n\n    if not positional_args:\n        return False\n\n    return name == positional_args[0].arg\n\n\ndef is_generator(node: AnyFunctionDef) -> bool:\n    \"\"\"Tells whether a given function is a generator.\"\"\"\n    for body_item in node.body:\n        if is_contained(node=body_item, to_check=(Yield, YieldFrom)):\n            return True\n    return False\n", "path": "wemake_python_styleguide/logic/tree/functions.py"}], "after_files": [{"content": "from ast import Call, Yield, YieldFrom, arg\nfrom typing import Container, List, Optional\n\nfrom wemake_python_styleguide.compat.functions import get_posonlyargs\nfrom wemake_python_styleguide.logic import source\nfrom wemake_python_styleguide.logic.walk import is_contained\nfrom wemake_python_styleguide.types import (\n    AnyFunctionDef,\n    AnyFunctionDefAndLambda,\n)\n\n\ndef given_function_called(\n    node: Call,\n    to_check: Container[str],\n    *,\n    split_modules: bool = False,\n) -> str:\n    \"\"\"\n    Returns function name if it is called and contained in the container.\n\n    If `split_modules`, takes the modules or objects into account. Otherwise,\n    it only cares about the function's name.\n    \"\"\"\n    function_name = source.node_to_string(node.func)\n    if split_modules:\n        function_name = function_name.split('.')[-1]\n    if function_name in to_check:\n        return function_name\n    return ''\n\n\ndef is_method(function_type: Optional[str]) -> bool:\n    \"\"\"\n    Returns whether a given function type belongs to a class.\n\n    >>> is_method('function')\n    False\n\n    >>> is_method(None)\n    False\n\n    >>> is_method('method')\n    True\n\n    >>> is_method('classmethod')\n    True\n\n    >>> is_method('staticmethod')\n    True\n\n    >>> is_method('')\n    False\n\n    \"\"\"\n    return function_type in {'method', 'classmethod', 'staticmethod'}\n\n\ndef get_all_arguments(node: AnyFunctionDefAndLambda) -> List[arg]:\n    \"\"\"\n    Returns list of all arguments that exist in a function.\n\n    Respects the correct parameters order.\n    Positional only args, regular argument,\n    ``*args``, keyword-only, ``**kwargs``.\n\n    Positional only args are only added for ``python3.8+``\n    other versions are ignoring this type of arguments.\n    \"\"\"\n    names = [\n        *get_posonlyargs(node),\n        *node.args.args,\n    ]\n\n    if node.args.vararg:\n        names.append(node.args.vararg)\n\n    names.extend(node.args.kwonlyargs)\n\n    if node.args.kwarg:\n        names.append(node.args.kwarg)\n\n    return names\n\n\ndef is_first_argument(node: AnyFunctionDefAndLambda, name: str) -> bool:\n    \"\"\"Tells whether an argument name is the logically first in function.\"\"\"\n    positional_args = [\n        *get_posonlyargs(node),\n        *node.args.args,\n    ]\n\n    if not positional_args:\n        return False\n\n    return name == positional_args[0].arg\n\n\ndef is_generator(node: AnyFunctionDef) -> bool:\n    \"\"\"Tells whether a given function is a generator.\"\"\"\n    for body_item in node.body:\n        if is_contained(node=body_item, to_check=(Yield, YieldFrom)):\n            return True\n    return False\n", "path": "wemake_python_styleguide/logic/tree/functions.py"}]}