Skip to content

Commit e4840cb

Browse files
committed
Merge branch 'main' into pipeline-job-control
2 parents d75c148 + 4cc2471 commit e4840cb

9 files changed

Lines changed: 66 additions & 68 deletions

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repos:
1515
- id: trailing-whitespace
1616

1717
- repo: https://github.com/astral-sh/ruff-pre-commit
18-
rev: "v0.16.9"
18+
rev: "v0.16.10"
1919
hooks:
2020
- id: ruff-format
2121
args: [--config=ruff.toml]

‎cmd2/annotated.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ def _convert(value: str) -> enum.Enum:
713713
raise _invalid_choice(value, _value_map)
714714

715715
_convert.__name__ = enum_class.__name__
716-
_convert._cmd2_enum_class = enum_class # type: ignore[attr-defined, ty:unresolved-attribute]
716+
_convert._cmd2_enum_class = enum_class # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
717717
return _convert
718718

719719

@@ -989,7 +989,7 @@ def _unwrap_optional(tp: Any) -> tuple[Any, bool]:
989989
there alone, so this helper never validates union members itself.
990990
"""
991991
origin = get_origin(tp)
992-
if origin is Union or origin is types.UnionType: # type: ignore[comparison-overlap]
992+
if origin is Union or origin is types.UnionType:
993993
all_args = get_args(tp)
994994
non_none = [a for a in all_args if a is not type(None)]
995995
has_none = len(non_none) < len(all_args)
@@ -1014,14 +1014,14 @@ def _normalize_annotation(annotation: Any) -> _NormalizedAnnotation:
10141014
tp, unwrapped = _unwrap_optional(tp)
10151015
if unwrapped:
10161016
is_optional = True
1017-
if get_origin(tp) is Annotated: # type: ignore[comparison-overlap]
1017+
if get_origin(tp) is Annotated:
10181018
inner_tp = get_args(tp)[0]
10191019
inner_origin = get_origin(inner_tp)
1020-
inner_is_union = inner_origin is Union or inner_origin is types.UnionType # type: ignore[comparison-overlap]
1020+
inner_is_union = inner_origin is Union or inner_origin is types.UnionType
10211021
if not (inner_is_union and type(None) in get_args(inner_tp)):
10221022
raise TypeError("Annotated[T, meta] | None is ambiguous. Use Annotated[T | None, meta] instead.")
10231023

1024-
if get_origin(tp) is Annotated: # type: ignore[comparison-overlap]
1024+
if get_origin(tp) is Annotated:
10251025
args = get_args(tp)
10261026
tp = args[0]
10271027
for meta in args[1:]:
@@ -1119,7 +1119,7 @@ def _convert(value: str) -> Any:
11191119
_convert.__name__ = getattr(converter, "__name__", "preprocess")
11201120
enum_class = getattr(converter, "_cmd2_enum_class", None)
11211121
if enum_class is not None:
1122-
_convert._cmd2_enum_class = enum_class # type: ignore[attr-defined, ty:unresolved-attribute]
1122+
_convert._cmd2_enum_class = enum_class # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
11231123
return _convert
11241124

11251125

‎cmd2/argparse_completer.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
def _build_hint(parser: Cmd2ArgumentParser, arg_action: argparse.Action) -> str:
5353
"""Build completion hint for a given argument."""
5454
# Check if hinting is disabled for this argument
55-
suppress_hint = arg_action.get_suppress_tab_hint() # type: ignore[attr-defined, ty:unresolved-attribute]
55+
suppress_hint = arg_action.get_suppress_tab_hint() # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
5656
if suppress_hint or arg_action.help == argparse.SUPPRESS:
5757
return ""
5858

@@ -104,7 +104,7 @@ def __init__(self, arg_action: argparse.Action) -> None:
104104
self.is_remainder = self.action.nargs == argparse.REMAINDER
105105

106106
# Check if nargs is a range
107-
nargs_range: tuple[int, int | float] | None = self.action.get_nargs_range() # type: ignore[attr-defined, ty:unresolved-attribute]
107+
nargs_range: tuple[int, int | float] | None = self.action.get_nargs_range() # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
108108
if nargs_range is not None:
109109
self.min = nargs_range[0]
110110
self.max = nargs_range[1]
@@ -575,7 +575,7 @@ def _validate_table_data(arg_state: _ArgumentState, completions: Completions) ->
575575
576576
:raises ValueError: if there is an error with the data.
577577
"""
578-
table_columns = arg_state.action.get_table_columns() # type: ignore[attr-defined, ty:unresolved-attribute]
578+
table_columns = arg_state.action.get_table_columns() # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
579579
has_table_data = any(item.table_data for item in completions)
580580

581581
if table_columns is None:
@@ -606,7 +606,7 @@ def _build_completion_table(self, arg_state: _ArgumentState, completions: Comple
606606

607607
table_columns = cast(
608608
Sequence[str | Column] | None,
609-
arg_state.action.get_table_columns(), # type: ignore[attr-defined, ty:unresolved-attribute]
609+
arg_state.action.get_table_columns(), # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
610610
)
611611

612612
# Skip table generation if results are outside thresholds or no columns are defined
@@ -761,7 +761,7 @@ def _complete_arg(
761761
:raises CompletionError: if the completer or choices function this calls raises one
762762
"""
763763
# Check if the argument uses a completer
764-
completer = arg_state.action.get_completer() # type: ignore[attr-defined, ty:unresolved-attribute]
764+
completer = arg_state.action.get_completer() # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
765765
if completer is not None:
766766
args, kwargs = self._prepare_callable_params(
767767
completer,
@@ -775,7 +775,7 @@ def _complete_arg(
775775

776776
# Otherwise it uses a choices provider or choices list
777777
else:
778-
choices_provider = arg_state.action.get_choices_provider() # type: ignore[attr-defined, ty:unresolved-attribute]
778+
choices_provider = arg_state.action.get_choices_provider() # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
779779
if choices_provider is not None:
780780
args, kwargs = self._prepare_callable_params(
781781
choices_provider,

‎cmd2/argparse_utils.py‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,11 @@ def _ActionsContainer_add_argument( # noqa: N802
564564
new_arg = orig_actions_container_add_argument(self, *args, **kwargs)
565565

566566
# Set the cmd2-specific attributes
567-
new_arg.set_nargs_range(nargs_range) # type: ignore[attr-defined, ty:unresolved-attribute]
568-
new_arg.set_choices_provider(choices_provider) # type: ignore[attr-defined, ty:unresolved-attribute]
569-
new_arg.set_completer(completer) # type: ignore[attr-defined, ty:unresolved-attribute]
570-
new_arg.set_suppress_tab_hint(suppress_tab_hint) # type: ignore[attr-defined, ty:unresolved-attribute]
571-
new_arg.set_table_columns(table_columns) # type: ignore[attr-defined, ty:unresolved-attribute]
567+
new_arg.set_nargs_range(nargs_range) # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
568+
new_arg.set_choices_provider(choices_provider) # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
569+
new_arg.set_completer(completer) # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
570+
new_arg.set_suppress_tab_hint(suppress_tab_hint) # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
571+
new_arg.set_table_columns(table_columns) # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
572572

573573
# Set other registered custom attributes
574574
for keyword, value in custom_attribs.items():
@@ -666,14 +666,14 @@ def _SubParsersAction_remove_all_parsers( # noqa: N802
666666
# Get the next subcommand name. remove_parser() will remove
667667
# it and any associated aliases from _name_parser_map.
668668
name = next(iter(self._name_parser_map))
669-
record = self.remove_parser(name) # type: ignore[attr-defined, ty:unresolved-attribute]
669+
record = self.remove_parser(name) # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
670670
records.append(record)
671671

672672
return records
673673

674674

675-
argparse._SubParsersAction.remove_parser = _SubParsersAction_remove_parser # type: ignore[attr-defined, ty:unresolved-attribute]
676-
argparse._SubParsersAction.remove_all_parsers = _SubParsersAction_remove_all_parsers # type: ignore[attr-defined, ty:unresolved-attribute]
675+
argparse._SubParsersAction.remove_parser = _SubParsersAction_remove_parser # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
676+
argparse._SubParsersAction.remove_all_parsers = _SubParsersAction_remove_all_parsers # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
677677

678678

679679
@dataclass
@@ -747,8 +747,8 @@ def __init__(
747747
super().__init__(
748748
prog=prog,
749749
usage=usage,
750-
description=description, # type: ignore[arg-type, ty:invalid-argument-type]
751-
epilog=epilog, # type: ignore[arg-type, ty:invalid-argument-type]
750+
description=description, # type: ignore[arg-type] # ty: ignore[invalid-argument-type]
751+
epilog=epilog, # type: ignore[arg-type] # ty: ignore[invalid-argument-type]
752752
parents=parents,
753753
formatter_class=formatter_class,
754754
prefix_chars=prefix_chars,
@@ -772,15 +772,15 @@ def __init__(
772772
self.description: HelpContent | None # type: ignore[assignment]
773773
self.epilog: HelpContent | None # type: ignore[assignment]
774774

775-
def print_usage(self, file: IO[str] | None = None) -> None: # type: ignore[override, ty:invalid-method-override]
775+
def print_usage(self, file: IO[str] | None = None) -> None: # type: ignore[override] # ty: ignore[invalid-method-override]
776776
"""Override to ensure the formatter is aware of the target file."""
777777
if file is None:
778778
file = self._thread_locals.current_output_file
779779

780780
with self.output_to(file):
781781
super().print_usage(file)
782782

783-
def print_help(self, file: IO[str] | None = None) -> None: # type: ignore[override, ty:invalid-method-override]
783+
def print_help(self, file: IO[str] | None = None) -> None: # type: ignore[override] # ty: ignore[invalid-method-override]
784784
"""Override to ensure the formatter is aware of the target file."""
785785
if file is None:
786786
file = self._thread_locals.current_output_file
@@ -984,7 +984,7 @@ def detach_subcommand(self, subcommand_path: Iterable[str], subcommand: str) ->
984984
try:
985985
record = cast(
986986
SubcommandRecord,
987-
subparsers_action.remove_parser(subcommand), # type: ignore[attr-defined, ty:unresolved-attribute]
987+
subparsers_action.remove_parser(subcommand), # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
988988
)
989989
except ValueError:
990990
raise ValueError(f"Subcommand '{subcommand}' does not exist for '{target_parser.prog}'") from None
@@ -1006,7 +1006,7 @@ def detach_all_subcommands(self, subcommand_path: Iterable[str]) -> list[Subcomm
10061006

10071007
records = cast(
10081008
list[SubcommandRecord],
1009-
subparsers_action.remove_all_parsers(), # type: ignore[attr-defined, ty:unresolved-attribute]
1009+
subparsers_action.remove_all_parsers(), # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
10101010
)
10111011
# Update command for each detached subcommand
10121012
for record in records:
@@ -1046,7 +1046,7 @@ def format_help(self, *args: Any, **kwargs: Any) -> str:
10461046

10471047
def _get_nargs_pattern(self, action: argparse.Action) -> str:
10481048
"""Override to support nargs ranges."""
1049-
nargs_range = action.get_nargs_range() # type: ignore[attr-defined, ty:unresolved-attribute]
1049+
nargs_range = action.get_nargs_range() # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
10501050
if nargs_range:
10511051
range_max = "" if nargs_range[1] == constants.INFINITY else nargs_range[1]
10521052
nargs_pattern = f"(-*A{{{nargs_range[0]},{range_max}}}-*)"
@@ -1066,7 +1066,7 @@ def _match_argument(self, action: argparse.Action, arg_strings_pattern: str) ->
10661066

10671067
# raise an exception if we weren't able to find a match
10681068
if match is None:
1069-
nargs_range = action.get_nargs_range() # type: ignore[attr-defined, ty:unresolved-attribute]
1069+
nargs_range = action.get_nargs_range() # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
10701070
if nargs_range is not None:
10711071
raise ArgumentError(action, build_range_error(nargs_range[0], nargs_range[1]))
10721072

0 commit comments

Comments
 (0)