From 3337f9f8c49ce6184ef1c333164fe3738fb26137 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 25 Nov 2024 15:01:34 -0500 Subject: [PATCH] Type Command.sub_commands to avoid variance issues --- distutils/cmd.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/distutils/cmd.py b/distutils/cmd.py index 6ffe7bd4..de342687 100644 --- a/distutils/cmd.py +++ b/distutils/cmd.py @@ -10,7 +10,8 @@ import os import re import sys -from typing import TypeVar, overload +from collections.abc import Callable +from typing import Any, ClassVar, TypeVar, overload from . import _modified, archive_util, dir_util, file_util, util from ._log import log @@ -49,7 +50,9 @@ class Command: # 'sub_commands' is usually defined at the *end* of a class, because # predicates can be unbound methods, so they must already have been # defined. The canonical example is the "install" command. - sub_commands = [] + sub_commands: ClassVar[ # Any to work around variance issues + list[tuple[str, Callable[[Any], bool] | None]] + ] = [] # -- Creation/initialization methods -------------------------------