Skip to content

Commit

Permalink
lint: fix untyped-defs on /test/unittest/cmd
Browse files Browse the repository at this point in the history
Signed-off-by: iru <[email protected]>
  • Loading branch information
wideawakening committed Oct 8, 2024
1 parent e10b09b commit 4ece6c3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cloudinit/cmd/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class StatusDetails(NamedTuple):
recoverable_errors: Dict[str, List[str]]
last_update: str
datasource: Optional[str]
v1: Dict[str, Dict]
v1: Dict[str, Any]


TABULAR_LONG_TMPL = """\
Expand Down
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ module = [
"cloudinit.user_data",
"tests.integration_tests.instances",
"tests.unittests.analyze.test_show",
"tests.unittests.cmd.devel.test_hotplug_hook",
"tests.unittests.cmd.devel.test_render",
"tests.unittests.cmd.test_clean",
"tests.unittests.cmd.test_query",
"tests.unittests.cmd.test_status",
"tests.unittests.config.test_apt_configure_sources_list_v1",
"tests.unittests.config.test_apt_configure_sources_list_v3",
"tests.unittests.config.test_apt_source_v1",
Expand Down
11 changes: 10 additions & 1 deletion tests/unittests/cmd/devel/test_hotplug_hook.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import namedtuple
from typing import Any, NamedTuple
from unittest import mock
from unittest.mock import call

Expand All @@ -19,6 +20,14 @@
FAKE_MAC = "11:22:33:44:55:66"


# Define the NamedTuple class
class Mocks(NamedTuple):
m_init: Any
m_network_state: Any
m_activator: Any
m_sleep: Any


@pytest.fixture
def mocks():
m_init = mock.MagicMock(spec=Init)
Expand Down Expand Up @@ -54,7 +63,7 @@ def mocks():
parse_net.start()
m_sleep = sleep.start()

yield namedtuple("mocks", "m_init m_network_state m_activator m_sleep")(
yield Mocks(
m_init=m_init,
m_network_state=m_network_state,
m_activator=m_activator,
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/cmd/devel/test_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_invalid_jinja_syntax(self, caplog, tmpdir):
assert (
JinjaSyntaxParsingException.format_error_message(
syntax_error="unexpected '}'",
line_number=2,
line_number="2",
line_content="rendering: {{ my_var } }",
)
in caplog.text
Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/cmd/test_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def fake_subp(cmd, capture):
return "", ""

myargs = namedtuple(
"MyArgs", "remove_logs remove_seed remove_config reboot machine_id"
"myargs", "remove_logs remove_seed remove_config reboot machine_id"
)
cmdargs = myargs(
remove_logs=False,
Expand Down Expand Up @@ -382,7 +382,7 @@ def test_handle_clean_args_removed_machine_id(
"""handle_clean_args removes /etc/machine-id when arg is True."""
uses_systemd.return_value = systemd_val
myargs = namedtuple(
"MyArgs", "remove_logs remove_seed remove_config reboot machine_id"
"myargs", "remove_logs remove_seed remove_config reboot machine_id"
)
cmdargs = myargs(
remove_logs=False,
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/cmd/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ def test_handle_args_invalid_jinja_exception(self, caplog, tmpdir, capsys):
"Failed to render templated data. "
+ JinjaSyntaxParsingException.format_error_message(
syntax_error="unexpected '}'",
line_number=2,
line_number="2",
line_content="v1_1: {{ v1.v1_1 } }",
)
)
Expand Down

0 comments on commit 4ece6c3

Please sign in to comment.