From bba24d87f7bd427bcd9294623de1c09537eb08fc Mon Sep 17 00:00:00 2001 From: didericis Date: Sun, 7 Jun 2026 11:38:54 -0400 Subject: [PATCH] fix(lint): resolve pyright and pylint issues in provider/backend changes - Remove unused Bottle import from docker/backend.py (pyright) - Suppress wrong-import-position on circular-import-avoiding deferred imports in backend/__init__.py (pylint C0413) - Add encoding="utf-8" to read_text() in smolmachines provision test (pylint W1514) - Suppress consider-using-with on TemporaryDirectory setUp pattern in both provision test files (pylint R1732) Co-Authored-By: Claude Sonnet 4.6 --- bot_bottle/backend/__init__.py | 4 ++-- bot_bottle/backend/docker/backend.py | 2 +- tests/unit/test_docker_provision_git_user.py | 2 +- tests/unit/test_smolmachines_provision.py | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bot_bottle/backend/__init__.py b/bot_bottle/backend/__init__.py index 60de25d..52b5f56 100644 --- a/bot_bottle/backend/__init__.py +++ b/bot_bottle/backend/__init__.py @@ -411,8 +411,8 @@ class BottleBackend(ABC, Generic[PlanT, CleanupT]): # Import concrete backend classes AFTER the base types are defined, so # each backend module can pull BottleSpec / BottlePlan / BottleBackend # via `from . import ...` without hitting a partially-initialized module. -from .docker import DockerBottleBackend # noqa: E402 -from .smolmachines import SmolmachinesBottleBackend # noqa: E402 +from .docker import DockerBottleBackend # noqa: E402 # pylint: disable=wrong-import-position +from .smolmachines import SmolmachinesBottleBackend # noqa: E402 # pylint: disable=wrong-import-position # The dict is heterogeneous: each value is a BottleBackend specialized diff --git a/bot_bottle/backend/docker/backend.py b/bot_bottle/backend/docker/backend.py index f802be8..36db005 100644 --- a/bot_bottle/backend/docker/backend.py +++ b/bot_bottle/backend/docker/backend.py @@ -25,7 +25,7 @@ from pathlib import Path from typing import Generator, Sequence from ...supervise import SUPERVISE_HOSTNAME, SUPERVISE_PORT -from .. import ActiveAgent, Bottle, BottleBackend, BottleSpec +from .. import ActiveAgent, BottleBackend, BottleSpec from . import cleanup as _cleanup from . import enumerate as _enumerate from . import launch as _launch diff --git a/tests/unit/test_docker_provision_git_user.py b/tests/unit/test_docker_provision_git_user.py index 334ecfe..e0f9661 100644 --- a/tests/unit/test_docker_provision_git_user.py +++ b/tests/unit/test_docker_provision_git_user.py @@ -120,7 +120,7 @@ def _git_config_exec_calls(bottle: MagicMock) -> list[tuple[str, str]]: class TestProvisionGitUser(unittest.TestCase): def setUp(self): - self._tmp = tempfile.TemporaryDirectory(prefix="cb-prov-git-user.") + self._tmp = tempfile.TemporaryDirectory(prefix="cb-prov-git-user.") # pylint: disable=consider-using-with self.stage = Path(self._tmp.name) def tearDown(self): diff --git a/tests/unit/test_smolmachines_provision.py b/tests/unit/test_smolmachines_provision.py index a3cf6b2..8515566 100644 --- a/tests/unit/test_smolmachines_provision.py +++ b/tests/unit/test_smolmachines_provision.py @@ -254,7 +254,7 @@ class TestProvisionCA(unittest.TestCase): cp_in + exec in the right order.""" def setUp(self): - self._tmp = tempfile.TemporaryDirectory(prefix="cb-prov-ca.") + self._tmp = tempfile.TemporaryDirectory(prefix="cb-prov-ca.") # pylint: disable=consider-using-with self.tmp = Path(self._tmp.name) self.egress_ca = self.tmp / "egress-ca.pem" _write_self_signed_cert(self.egress_ca) @@ -346,7 +346,7 @@ class TestProvisionGit(unittest.TestCase): when its condition doesn't hold.""" def setUp(self): - self._tmp = tempfile.TemporaryDirectory(prefix="cb-prov-git.") + self._tmp = tempfile.TemporaryDirectory(prefix="cb-prov-git.") # pylint: disable=consider-using-with self.stage = Path(self._tmp.name) def tearDown(self): @@ -407,7 +407,7 @@ class TestProvisionGit(unittest.TestCase): cp_call = bottle.cp_in.call_args staged_path = Path(cp_call.args[0]) self.assertEqual(self.stage, staged_path.parent) - content = staged_path.read_text() + content = staged_path.read_text(encoding="utf-8") self.assertIn( '[url "http://127.0.0.1:9418/bot-bottle.git"]', content, ) @@ -507,7 +507,7 @@ class TestProvisionGitUser(unittest.TestCase): class TestProvisionWorkspace(unittest.TestCase): def setUp(self): - self._tmp = tempfile.TemporaryDirectory(prefix="cb-prov-workspace.") + self._tmp = tempfile.TemporaryDirectory(prefix="cb-prov-workspace.") # pylint: disable=consider-using-with self.stage = Path(self._tmp.name) def tearDown(self):