From 1e54d97366fcf1501be31e1e50f15026d959ee07 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Tue, 17 Jan 2023 07:38:45 -0600 Subject: [PATCH] Fix the type annotation for `color` param of `Spinner.finalize()` Colorama's ANSI class attributes are defined as ints. However, when an ANSI class is instantiated (say, when the `AnsiFore` class is instantiated as `Fore`), instance attributes with identical names are dynamically created, but the attributes are strings containing ANSI escape sequences. Thus, `AnsiFore.YELLOW` is an int, while `Fore.YELLOW` is a str. mypy 0.991 isn't catching this discrepancy, but PyCharm did. Fixes #2878 --- docs/changelog/2878.misc.rst | 1 + src/tox/util/spinner.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 docs/changelog/2878.misc.rst diff --git a/docs/changelog/2878.misc.rst b/docs/changelog/2878.misc.rst new file mode 100644 index 000000000..4b727e2a5 --- /dev/null +++ b/docs/changelog/2878.misc.rst @@ -0,0 +1 @@ +* Fix an incorrect type annotation for the ``color`` parameter in ``Spinner.finalize()``. diff --git a/src/tox/util/spinner.py b/src/tox/util/spinner.py index e816786ba..f95b4bf62 100644 --- a/src/tox/util/spinner.py +++ b/src/tox/util/spinner.py @@ -138,7 +138,7 @@ def fail(self, key: str) -> None: def skip(self, key: str) -> None: self.finalize(key, f"SKIP {self.outcome.skip}", Fore.YELLOW) - def finalize(self, key: str, status: str, color: int) -> None: + def finalize(self, key: str, status: str, color: str) -> None: start_at = self._envs.pop(key, None) if self.enabled: self.clear()