-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
[Refactor] Fix ruff rule E721: type-comparison #49919
base: master
Are you sure you want to change the base?
Conversation
assert ( | ||
type(params) == list | ||
type(params) is list |
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.
shouldn't line 46 just declar params as type List
? @sven1977 ?
please resolve merge conflict. |
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.
please resolve merge conflict.
Signed-off-by: win5923 <[email protected]>
Done! |
if type(channel) is CachedChannel: | ||
channel_details += f", {channel._channel_id[:6]}..." | ||
# get inner channel | ||
if ( | ||
type(channel) == CompositeChannel | ||
type(channel) is CompositeChannel | ||
and downstream_actor_id in channel._channel_dict | ||
): | ||
inner_channel = channel._channel_dict[downstream_actor_id] | ||
channel_details += f"\n{type(inner_channel).__name__}" | ||
if type(inner_channel) == IntraProcessChannel: | ||
if type(inner_channel) is IntraProcessChannel: |
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.
Should this be changed to isinstance
?
Why are these changes needed?
Unlike a direct type comparison,
isinstance
will also check if an object is an instance of a class or a subclass thereof.If you want to check for an exact type match, use
is
oris not
.Ref: https://docs.astral.sh/ruff/rules/type-comparison/
Related issue number
#47991
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.