33from __future__ import annotations
44
55import logging
6- import sys
76from abc import ABC , abstractmethod
8- from collections .abc import Collection , Iterable , Iterator , Mapping
9- from typing import TYPE_CHECKING , Any , Callable , Generic , overload
7+ from collections .abc import Callable , Collection , Iterable , Iterator , Mapping
8+ from importlib .metadata import entry_points
9+ from typing import TYPE_CHECKING , Any , Generic , overload
1010
1111from typing_extensions import Self
1212
13- if sys .version_info [:2 ] >= (3 , 10 ):
14- from importlib .metadata import entry_points
15- else :
16- from importlib_metadata import entry_points
17-
1813from .utils import Hint , OptionalKwargs , X , Y , make_callback , normalize_string
1914
2015if TYPE_CHECKING :
@@ -258,7 +253,7 @@ def _get_reverse_synonyms(self) -> dict[str, list[str]]:
258253
259254 def _get_click_choice (
260255 self , prefix : str | None = None , delimiter : str | None = None , suffix : str | None = None
261- ) -> click .Choice :
256+ ) -> click .Choice [ str ] :
262257 """Get a dynamically generated :class:`click.Choice` that shows values and synonyms.
263258
264259 :param prefix: The string shown after the opening square bracket, before the
@@ -274,14 +269,14 @@ def _get_click_choice(
274269 rev = self ._get_reverse_synonyms ()
275270 norm_func = self .normalize
276271
277- class _Choice (click .Choice ):
272+ class _Choice (click .Choice [ str ] ):
278273 """An extended choice that is aware of synonyms."""
279274
280275 def convert (self , value : Any , param : click .Parameter | None , ctx : click .Context | None ) -> Any :
281276 """Normalize."""
282277 return super ().convert (norm_func (value ), param = param , ctx = ctx )
283278
284- def get_metavar (self , param : click .Parameter ) -> str :
279+ def get_metavar (self , param : click .Parameter , ctx : click . Context ) -> str :
285280 """Get the text that shows the choices, including synonyms."""
286281 choices_lst = []
287282 for key , synonyms in rev .items ():
0 commit comments