[refurb] Implement subclass-builtin (FURB189)#14105
[refurb] Implement subclass-builtin (FURB189)#14105dhruvmanila merged 6 commits intoastral-sh:mainfrom
refurb] Implement subclass-builtin (FURB189)#14105Conversation
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
dhruvmanila
left a comment
There was a problem hiding this comment.
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_stringcall foruser_symbolmethod 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 <dhruvmanila@gmail.com>
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, Enumis common prior toStrEnum)Test Plan
cargo test