Skip to content

Commit 74b1014

Browse files
committed
fix codeql cli export and import warnings
1 parent 8eb8202 commit 74b1014

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

src/automax/cli/__init__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,18 @@
77

88
from __future__ import annotations
99

10-
from typing import Any
11-
1210
__all__ = ["cli_main"]
1311

1412

15-
def __getattr__(name: str) -> Any:
16-
"""Load the Click entry point lazily.
13+
def cli_main() -> None:
14+
"""Run the Click entry point without importing it during package init.
1715
1816
Importing ``automax.cli.cli`` from this package initializer makes
1917
``python -m automax.cli.cli`` emit a runpy RuntimeWarning because the target
2018
module is already present in ``sys.modules`` before runpy executes it. Keep
2119
the public ``automax.cli:cli_main`` entry point while avoiding the eager
2220
module import.
2321
"""
24-
if name == "cli_main":
25-
from automax.cli.cli import cli_main
22+
from automax.cli.cli import cli_main as _cli_main
2623

27-
return cli_main
28-
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
24+
_cli_main()

tests/test_next_engine.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
import pytest
1212
from click.testing import CliRunner
1313

14-
from automax.cli.cli import cli
14+
import automax.cli.cli as cli_module
15+
16+
cli = cli_module.cli
1517
from automax.core.engine import AutomaxEngine
1618
from automax.core.models import ExecutionContext, Target
1719
from automax.core.state import StateStore
@@ -4491,7 +4493,6 @@ def test_prepare_sudo_password_command_uses_askpass_without_embedding_password()
44914493

44924494
def test_cli_run_sudo_password_env_feeds_sudo_enabled_remote_substeps(tmp_path: Path, monkeypatch):
44934495
from contextlib import contextmanager
4494-
import automax.cli.cli as cli_module
44954496

44964497
class FakeChannel:
44974498
def shutdown_write(self):

0 commit comments

Comments
 (0)