Wemake-python-styleguide: Method `given_function_called` should only take the function name into account.

Created on 20 Oct 2020  路  3Comments  路  Source: wemake-services/wemake-python-styleguide

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`
bug

Most helpful comment

I understand. I will not change the functionality of this method, but make a different one for this purpose instead.

All 3 comments

Ofc I will be doing this since it is blocking my own PR.

We need both. Sometimes we are interested in attributes as well.

I understand. I will not change the functionality of this method, but make a different one for this purpose instead.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dreamsorcerer picture Dreamsorcerer  路  3Comments

webartifex picture webartifex  路  5Comments

sobolevn picture sobolevn  路  4Comments

sobolevn picture sobolevn  路  4Comments

sobolevn picture sobolevn  路  4Comments