-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[refurb
] Implement subclass-builtin
(FURB189
)
#14105
[refurb
] Implement subclass-builtin
(FURB189
)
#14105
Conversation
4da72a1
to
0f22b54
Compare
0f22b54
to
2f63930
Compare
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
FURB189 | 12 | 12 | 0 | 0 | 0 |
56cc5ea
to
c7f45b0
Compare
Thanks for the helpful pointers @dhruvmanila! |
- Move utilities after rule logic - Avoid allocating string multiple times
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.
Thanks! I made a couple of minor changes:
- Moved the utilities below the rule logic function; we do this for all rules
- Avoid the eager
.to_string
call foruser_symbol
method and only allocate it when creating theDiagnostic
Looking at the ecosystem changes, we might want to special case
Sorry, I missed this earlier but can you expand on why do we want to diverge from this behavior. Edit: I think we should keep the same behavior as |
Fair point. After looking at the ecosystem results, I think we indeed should stick with refurb's behaviour (at least until type inference is available). Only considering classes with a single base is the least error prone. It also has some false negatives which can be detected by considering multiple bases, e.g. https://github.com/bokeh/bokeh/blob/829b2a75c402d0d0abd7e37ff201fbdfd949d857/src/bokeh/core/property/wrappers.py#L306. However there are false positives for:
|
I think the listed limitations are a good trade-off. |
Co-authored-by: Dhruv Manilawala <[email protected]>
refurb
] Implement subclass-builtin
(FURB189)refurb
] Implement subclass-builtin
(FURB189
)
Summary
Implementation for one of the rules in #1348
Refurb only deals only with classes with a single base, however the rule is valid for any base.
(
str, Enum
is common prior toStrEnum
)Test Plan
cargo test