-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MAINTENANCE] Ruff 0.4.4
#9918
[MAINTENANCE] Ruff 0.4.4
#9918
Conversation
✅ Deploy Preview for niobium-lead-7998 canceled.
|
✅ Deploy Preview for niobium-lead-7998 canceled.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #9918 +/- ##
========================================
Coverage 77.24% 77.24%
========================================
Files 491 491
Lines 41817 41817
========================================
Hits 32300 32300
Misses 9517 9517 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -73,7 +73,7 @@ def __hash__(self: PartitionerMethod): | |||
return hash(self.value) | |||
|
|||
|
|||
class DataPartitioner(abc.ABC): | |||
class DataPartitioner(abc.ABC): # noqa: B024 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the violation is understandable given we do need this class to be inherited and never instantied directly.
A Protocal
with default methods COULD also work here (or having a distinct Protocol
+ a DataPartitionerBase
), but these don't seem obviously better to me.
I think this is the exception that proves the rule.
https://docs.astral.sh/ruff/rules/abstract-base-class-without-abstract-method/
abstract-base-class-without-abstract-method (B024)
Derived from the flake8-bugbear linter.
What it does
Checks for abstract classes without abstract methods.
Why is this bad?
Abstract base classes are used to define interfaces. If an abstract base
class has no abstract methods, you may have forgotten to add an abstract
method to the class or omitted an @abstractmethod
decorator.
If the class is not meant to be used as an interface, consider removing
the ABC
base class from the class definition.
Example
from abc import ABC
class Foo(ABC):
def method(self):
bar()
Use instead:
from abc import ABC, abstractmethod
class Foo(ABC):
@abstractmethod
def method(self):
bar()
References
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with it as is, even though ABCs without abstractmethods can be instantiated directly. We could also do something like suggested here, but I think it should be apparent to readers that they shouldn't directly instantiate this, which is the most important thin IMO
Update version of
ruff