fix: pyright errors in test file, bump pyright floor to 1.1.411
- Remove unused `import dataclasses` and stray `die as real_die` import - Replace lambda side_effect callbacks with list side_effect; lambdas with untyped parameters trigger reportUnknownLambdaType in pyright >=1.1.400 — side_effect=[...] is both cleaner and type-safe - Bump pyright floor from >=1.1.300 to >=1.1.411 in requirements-dev.txt so CI installs a version that matches what the lint job runs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,5 +3,5 @@
|
|||||||
# These tools are used for code quality checks in CI/CD.
|
# These tools are used for code quality checks in CI/CD.
|
||||||
|
|
||||||
pylint>=3.0.0
|
pylint>=3.0.0
|
||||||
pyright>=1.1.300
|
pyright>=1.1.411
|
||||||
coverage>=7.0.0
|
coverage>=7.0.0
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import dataclasses
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -404,20 +403,18 @@ class TestPreflightHostKeys(unittest.TestCase):
|
|||||||
|
|
||||||
def test_headless_dies_when_key_missing(self) -> None:
|
def test_headless_dies_when_key_missing(self) -> None:
|
||||||
manifest = _manifest_with_git()
|
manifest = _manifest_with_git()
|
||||||
from bot_bottle.log import die as real_die
|
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
preflight_host_keys(manifest, headless=True, home_md=None)
|
preflight_host_keys(manifest, headless=True, home_md=None)
|
||||||
|
|
||||||
def test_interactive_fetches_and_confirms_key(self) -> None:
|
def test_interactive_fetches_and_confirms_key(self) -> None:
|
||||||
manifest = _manifest_with_git()
|
manifest = _manifest_with_git()
|
||||||
replies = iter(["y", "n"]) # confirm key, don't persist
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"bot_bottle.git_gate_host_key.fetch_host_key",
|
"bot_bottle.git_gate_host_key.fetch_host_key",
|
||||||
return_value="ssh-ed25519 FETCHED",
|
return_value="ssh-ed25519 FETCHED",
|
||||||
), patch(
|
), patch(
|
||||||
"bot_bottle.git_gate_host_key._prompt_tty",
|
"bot_bottle.git_gate_host_key._prompt_tty",
|
||||||
side_effect=lambda msg: next(replies),
|
side_effect=["y", "n"], # confirm key, don't persist
|
||||||
), patch("sys.stderr"):
|
), patch("sys.stderr"):
|
||||||
result = preflight_host_keys(manifest, headless=False, home_md=None)
|
result = preflight_host_keys(manifest, headless=False, home_md=None)
|
||||||
|
|
||||||
@@ -437,7 +434,6 @@ class TestPreflightHostKeys(unittest.TestCase):
|
|||||||
|
|
||||||
def test_interactive_persists_when_requested(self) -> None:
|
def test_interactive_persists_when_requested(self) -> None:
|
||||||
manifest = _manifest_with_git()
|
manifest = _manifest_with_git()
|
||||||
replies = iter(["y", "y"]) # confirm key, yes persist
|
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as home:
|
with tempfile.TemporaryDirectory() as home:
|
||||||
bottles_dir = Path(home) / "bottles"
|
bottles_dir = Path(home) / "bottles"
|
||||||
@@ -455,7 +451,7 @@ class TestPreflightHostKeys(unittest.TestCase):
|
|||||||
return_value="ssh-ed25519 FETCHED",
|
return_value="ssh-ed25519 FETCHED",
|
||||||
), patch(
|
), patch(
|
||||||
"bot_bottle.git_gate_host_key._prompt_tty",
|
"bot_bottle.git_gate_host_key._prompt_tty",
|
||||||
side_effect=lambda msg: next(replies),
|
side_effect=["y", "y"], # confirm key, yes persist
|
||||||
), patch("sys.stderr"):
|
), patch("sys.stderr"):
|
||||||
result = preflight_host_keys(
|
result = preflight_host_keys(
|
||||||
manifest, headless=False, home_md=Path(home),
|
manifest, headless=False, home_md=Path(home),
|
||||||
@@ -467,7 +463,6 @@ class TestPreflightHostKeys(unittest.TestCase):
|
|||||||
|
|
||||||
def test_interactive_skips_persist_when_declined(self) -> None:
|
def test_interactive_skips_persist_when_declined(self) -> None:
|
||||||
manifest = _manifest_with_git()
|
manifest = _manifest_with_git()
|
||||||
replies = iter(["y", "n"]) # confirm key, no persist
|
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as home:
|
with tempfile.TemporaryDirectory() as home:
|
||||||
bottles_dir = Path(home) / "bottles"
|
bottles_dir = Path(home) / "bottles"
|
||||||
@@ -485,7 +480,7 @@ class TestPreflightHostKeys(unittest.TestCase):
|
|||||||
return_value="ssh-ed25519 FETCHED",
|
return_value="ssh-ed25519 FETCHED",
|
||||||
), patch(
|
), patch(
|
||||||
"bot_bottle.git_gate_host_key._prompt_tty",
|
"bot_bottle.git_gate_host_key._prompt_tty",
|
||||||
side_effect=lambda msg: next(replies),
|
side_effect=["y", "n"], # confirm key, no persist
|
||||||
), patch("sys.stderr"):
|
), patch("sys.stderr"):
|
||||||
result = preflight_host_keys(
|
result = preflight_host_keys(
|
||||||
manifest, headless=False, home_md=Path(home),
|
manifest, headless=False, home_md=Path(home),
|
||||||
@@ -506,7 +501,6 @@ class TestPreflightHostKeys(unittest.TestCase):
|
|||||||
|
|
||||||
def test_interactive_warns_when_persist_file_not_found(self) -> None:
|
def test_interactive_warns_when_persist_file_not_found(self) -> None:
|
||||||
manifest = _manifest_with_git()
|
manifest = _manifest_with_git()
|
||||||
replies = iter(["y", "y"]) # confirm key, yes persist
|
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as home:
|
with tempfile.TemporaryDirectory() as home:
|
||||||
# bottles/ dir exists but does not contain the repo entry
|
# bottles/ dir exists but does not contain the repo entry
|
||||||
@@ -520,7 +514,7 @@ class TestPreflightHostKeys(unittest.TestCase):
|
|||||||
return_value="ssh-ed25519 FETCHED",
|
return_value="ssh-ed25519 FETCHED",
|
||||||
), patch(
|
), patch(
|
||||||
"bot_bottle.git_gate_host_key._prompt_tty",
|
"bot_bottle.git_gate_host_key._prompt_tty",
|
||||||
side_effect=lambda msg: next(replies),
|
side_effect=["y", "y"], # confirm key, yes persist
|
||||||
), patch("sys.stderr", buf):
|
), patch("sys.stderr", buf):
|
||||||
result = preflight_host_keys(
|
result = preflight_host_keys(
|
||||||
manifest, headless=False, home_md=Path(home),
|
manifest, headless=False, home_md=Path(home),
|
||||||
|
|||||||
Reference in New Issue
Block a user