From c9ddbb60a25b940aae9baca7306fb0ff7fddc1bc 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/distutils/cmd.py b/distutils/cmd.py index 2bb97956..650319ae 100644 --- a/distutils/cmd.py +++ b/distutils/cmd.py @@ -8,6 +8,8 @@ import os import re import sys +from collections.abc import Callable +from typing import Any, ClassVar from . import _modified, archive_util, dir_util, file_util, util from ._log import log @@ -44,7 +46,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 -------------------------------