Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[preview] FURB118 can be unsafe for methods #13829

Description

@henryiii

If you run with preview set, then the FURB118 check makes an unsafe replacement, you can see me rolling back the change wntrblm/nox@a91dbe2 to make the tests pass, the difference in behavior can be shown with this MWE:

>>> class A:
...     pass
...  
>>> A.__eq__ = lambda a, b: a == b
>>> A() == A()
Traceback (most recent call last):
  File "<python-input-5>", line 1, in <module>
    A() == A()
  File "<python-input-4>", line 1, in <lambda>
    A.__eq__ = lambda a, b: a == b
                            ^^^^^^
  File "<python-input-4>", line 1, in <lambda>
    A.__eq__ = lambda a, b: a == b
                            ^^^^^^
  File "<python-input-4>", line 1, in <lambda>
    A.__eq__ = lambda a, b: a == b
                            ^^^^^^
  [Previous line repeated 988 more times]
RecursionError: maximum recursion depth exceeded
>>> import operator
>>> A.__eq__ = operator.eq
>>> A() == A()
Traceback (most recent call last):
  File "<python-input-8>", line 1, in <module>
    A() == A()
TypeError: eq expected 2 arguments, got 1

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpreviewRelated to preview mode features

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions