Replace pylint protected-access with Ruff SLF001 (#115735)

This commit is contained in:
Sid 2024-05-06 20:33:26 +02:00 committed by GitHub
parent 460c05dc43
commit b456d97e65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
90 changed files with 168 additions and 223 deletions

View file

@ -88,7 +88,7 @@ class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy):
Back ported from cpython 3.12
"""
with events._lock: # type: ignore[attr-defined] # pylint: disable=protected-access
with events._lock: # type: ignore[attr-defined] # noqa: SLF001
if self._watcher is None: # pragma: no branch
if can_use_pidfd():
self._watcher = asyncio.PidfdChildWatcher()
@ -96,7 +96,7 @@ class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy):
self._watcher = asyncio.ThreadedChildWatcher()
if threading.current_thread() is threading.main_thread():
self._watcher.attach_loop(
self._local._loop # type: ignore[attr-defined] # pylint: disable=protected-access
self._local._loop # type: ignore[attr-defined] # noqa: SLF001
)
@property
@ -159,15 +159,14 @@ async def setup_and_run_hass(runtime_config: RuntimeConfig) -> int:
return 1
# threading._shutdown can deadlock forever
# pylint: disable-next=protected-access
threading._shutdown = deadlock_safe_shutdown # type: ignore[attr-defined]
threading._shutdown = deadlock_safe_shutdown # type: ignore[attr-defined] # noqa: SLF001
return await hass.async_run()
def _enable_posix_spawn() -> None:
"""Enable posix_spawn on Alpine Linux."""
if subprocess._USE_POSIX_SPAWN: # pylint: disable=protected-access
if subprocess._USE_POSIX_SPAWN: # noqa: SLF001
return
# The subprocess module does not know about Alpine Linux/musl
@ -175,8 +174,7 @@ def _enable_posix_spawn() -> None:
# less efficient. This is a workaround to force posix_spawn()
# when using musl since cpython is not aware its supported.
tag = next(packaging.tags.sys_tags())
# pylint: disable-next=protected-access
subprocess._USE_POSIX_SPAWN = "musllinux" in tag.platform
subprocess._USE_POSIX_SPAWN = "musllinux" in tag.platform # noqa: SLF001
def run(runtime_config: RuntimeConfig) -> int: