NoRedundantLambda's autofix is not always safe
Open
- Dominant language
- Python
- Stars
- 714
- Forks
- 72
- PR merge metrics
- No merged PRs in 30d
Description
The documentation states that:
> A lamba function which has a single objective of passing all it is arguments to another callable can be safely replaced by that callable.
But this is not always true. For instance:
```python
get_now_isoformat = lambda: datetime.now().isoformat()
```
This will be autofixed this way:
```python
get_now_isoformat = datetime.now().isoformat
```
But the two functions do not have the same behaviour:
```python
>>> # A different result is returned everytime the function is called
>>> get_now_isoformat_v1() == get_now_isoformat_v1()
False
>>> # The result is "frozen"
>>> get_now_isoformat_v2() == get_now_isoformat_v2()
True
```
Contributor guide
Assessment
This issue has not been assessed yet.