From 474b32cb608d6aba521fac2b55dabd769c9933c9 Mon Sep 17 00:00:00 2001 From: Zoran Simic Date: Wed, 1 Apr 2026 19:35:10 -0700 Subject: [PATCH] Declare type of 'main' --- src/runez/conftest.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/runez/conftest.py b/src/runez/conftest.py index 080f11d..bb26b47 100644 --- a/src/runez/conftest.py +++ b/src/runez/conftest.py @@ -13,10 +13,14 @@ import re import sys from pathlib import Path +from typing import TYPE_CHECKING import _pytest.logging import pytest +if TYPE_CHECKING: + from collections.abc import Callable + import runez.config import runez.system from runez.colors import ActivateColors @@ -211,13 +215,13 @@ def __init__(self, stdout=None, stderr=None, exit_code=None, exception=None): class ClickRunner: """Allows to provide a test-friendly fixture around testing click entry-points""" - default_main = None # Class-level default main entry point, set from user's conftest.py + default_main: Callable | str | None = None # Class-level default main entry point, set from user's conftest.py context_wrapper = TempFolder # Class-level context manager to use for cli fixture runs args: list | None = None # Arguments used in last run() exit_code: int | None = None # Exit code of last run() logged: TrackedOutput # Captured log from last run() - main = None # Optional, override default_main for this runner instance + main: Callable | str | None = None # Optional, override default_main for this runner instance trace: bool | None = None # Optional, enable trace logging for this runner instance def __init__(self, context=None): @@ -272,7 +276,7 @@ def run(self, *args, exe=None, main=UNSET, trace=UNSET): Args: *args: Command line args exe (str | None): Optional, override sys.argv[0] just for this run - main (callable | None): Optional, override current self.main just for this run + main (Callable | str | None): Optional, override current self.main just for this run trace (bool): If True, enable trace logging """ main = _R.rdefault(main, self.main or ClickRunner.default_main)