mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Enable Ruff SLOT rules (#115043)
This commit is contained in:
parent
0636ba340c
commit
d61db732da
@ -305,6 +305,8 @@ def gen_result_wrapper(kls: type[dict | list | set]) -> type:
|
||||
class TupleWrapper(tuple, ResultWrapper):
|
||||
"""Wrap a tuple."""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
# This is all magic to be allowed to subclass a tuple.
|
||||
|
||||
def __new__(cls, value: tuple, *, render_result: str | None = None) -> Self:
|
||||
|
@ -18,3 +18,5 @@ class EventType(str, Generic[_DataT]):
|
||||
|
||||
At runtime this is a generic subclass of str.
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
@ -664,6 +664,7 @@ select = [
|
||||
"S608", # hardcoded-sql-expression
|
||||
"S609", # unix-command-wildcard-injection
|
||||
"SIM", # flake8-simplify
|
||||
"SLOT", # flake8-slots
|
||||
"T100", # Trace found: {name} used
|
||||
"T20", # flake8-print
|
||||
"TID251", # Banned imports
|
||||
|
@ -383,7 +383,7 @@ async def test_passing_subclassed_str_as_address(
|
||||
_, cancel_hci0, cancel_hci1 = _generate_scanners_with_fake_devices(hass)
|
||||
|
||||
class SubclassedStr(str):
|
||||
pass
|
||||
__slots__ = ()
|
||||
|
||||
address = SubclassedStr("00:00:00:00:00:01")
|
||||
client = bleak.BleakClient(address)
|
||||
|
@ -544,7 +544,7 @@ def test_string(hass: HomeAssistant) -> None:
|
||||
|
||||
# Test subclasses of str are returned
|
||||
class MyString(str):
|
||||
pass
|
||||
__slots__ = ()
|
||||
|
||||
my_string = MyString("hello")
|
||||
assert schema(my_string) is my_string
|
||||
|
@ -1270,7 +1270,7 @@ def test_to_json(hass: HomeAssistant) -> None:
|
||||
# Test special case where substring class cannot be rendered
|
||||
# See: https://github.com/ijl/orjson/issues/445
|
||||
class MyStr(str):
|
||||
pass
|
||||
__slots__ = ()
|
||||
|
||||
expected_result = '{"mykey1":11.0,"mykey2":"myvalue2","mykey3":["opt3b","opt3a"]}'
|
||||
test_dict = {
|
||||
|
@ -163,7 +163,7 @@ async def test_loading_derived_class():
|
||||
"""Test loading data from classes derived from str."""
|
||||
|
||||
class MyStr(str):
|
||||
pass
|
||||
__slots__ = ()
|
||||
|
||||
class MyBytes(bytes):
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user