mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[refurb] Check for subclasses includes subscript expressions (FURB189) (#16155)
## Summary Added checks for subscript expressions on builtin classes as in FURB189. The object is changed to use the collections objects and the types from the subscript are kept. Resolves #16130 > Note: Added some comments in the code explaining why ## Test Plan - Added a subscript dict and list class to the test file. - Tested locally to check that the symbols are changed and the types are kept. - No modifications changed on optional `str` values.
This commit is contained in:
parent
f58a54f043
commit
219712860c
3 changed files with 65 additions and 6 deletions
|
@ -8,7 +8,7 @@ class SetOnceMappingMixin:
|
|||
if key in self:
|
||||
raise KeyError(str(key) + ' already set')
|
||||
return super().__setitem__(key, value)
|
||||
|
||||
|
||||
|
||||
class CaseInsensitiveEnumMeta(EnumMeta):
|
||||
pass
|
||||
|
@ -23,6 +23,12 @@ class L(list):
|
|||
class S(str):
|
||||
pass
|
||||
|
||||
class SubscriptDict(dict[str, str]):
|
||||
pass
|
||||
|
||||
class SubscriptList(list[str]):
|
||||
pass
|
||||
|
||||
# currently not detected
|
||||
class SetOnceDict(SetOnceMappingMixin, dict):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue