Skip to content

Commit 8992b7a

Browse files
committed
Type Command.sub_commands to avoid variance issues
1 parent a9f832b commit 8992b7a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

distutils/cmd.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
in the distutils.command package.
55
"""
66

7+
from __future__ import annotations
8+
79
import logging
810
import os
911
import re
1012
import sys
13+
from collections.abc import Callable
14+
from typing import Any, ClassVar
1115

1216
from . import _modified, archive_util, dir_util, file_util, util
1317
from ._log import log
@@ -44,7 +48,9 @@ class Command:
4448
# 'sub_commands' is usually defined at the *end* of a class, because
4549
# predicates can be unbound methods, so they must already have been
4650
# defined. The canonical example is the "install" command.
47-
sub_commands = []
51+
sub_commands: ClassVar[ # Any to work around variance issues
52+
list[tuple[str, Callable[[Any], bool] | None]]
53+
] = []
4854

4955
# -- Creation/initialization methods -------------------------------
5056

0 commit comments

Comments
 (0)