Latest Results
[`refurb`] Do not add `abc.ABC` if already present (`FURB180`) (#22234)
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:
- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
requests.)
- Does this pull request include references to any relevant issues?
-->
## Summary
According to the `FURB180` rule, `abc.ABC` should be used instead of
`metaclass=abc.ABCMeta`. This issue can be fixed automatically, but if
the class being checked already contains `abc.ABC`, it would be added a
second time.
Fixes: #17162
## Test Plan
I ran `cargo test refurb`.
For checking the "fix" I used this python file:
<details>
<summary>Python file (input)</summary>
```python
import abc
from abc import abstractmethod, ABCMeta, ABC
from abc import ABC as ABCAnotherName
class ParentClass:
...
from abc import ABC, ABCMeta
class Foo(metaclass=ABCMeta):
...
class Foo2(abc.ABC, ParentClass, metaclass=ABCMeta):
...
class Foo3(ParentClass, ABC, metaclass=ABCMeta):
...
class Foo4(ABCAnotherName, metaclass=ABCMeta):
...
```
</details>
The output after applying the fix is so:
<details>
<summary>Python file (output)</summary>
```python
import abc
from abc import abstractmethod, ABCMeta, ABC
from abc import ABC as ABCAnotherName
class ParentClass:
...
from abc import ABC, ABCMeta
class Foo(ABC):
...
class Foo2(abc.ABC, ParentClass, ):
...
class Foo3(ParentClass, ABC, ):
...
class Foo4(ABCAnotherName, ):
...
```
</details>
Note: Trailing commas may remain after the automatic fix. It is unclear
whether this is an issue.
---------
Co-authored-by: me <me@example.com>
Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com> Active Branches
#228270%
#228190%
#222280%
© 2026 CodSpeed Technology