Skip to content

Commit 4e98a38

Browse files
committed
Fix ty 0.0.100 warnings due to renamed rules in ignore comments
1 parent b8e5d82 commit 4e98a38

6 files changed

Lines changed: 31 additions & 31 deletions

File tree

‎cmd2/annotated.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ def _convert(value: str) -> enum.Enum:
709709
raise _invalid_choice(value, _value_map)
710710

711711
_convert.__name__ = enum_class.__name__
712-
_convert._cmd2_enum_class = enum_class # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
712+
_convert._cmd2_enum_class = enum_class # type: ignore[attr-defined] # ty: ignore[missing-attribute]
713713
return _convert
714714

715715

@@ -1115,7 +1115,7 @@ def _convert(value: str) -> Any:
11151115
_convert.__name__ = getattr(converter, "__name__", "preprocess")
11161116
enum_class = getattr(converter, "_cmd2_enum_class", None)
11171117
if enum_class is not None:
1118-
_convert._cmd2_enum_class = enum_class # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
1118+
_convert._cmd2_enum_class = enum_class # type: ignore[attr-defined] # ty: ignore[missing-attribute]
11191119
return _convert
11201120

11211121

‎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: ignore[unresolved-attribute]
55+
suppress_hint = arg_action.get_suppress_tab_hint() # type: ignore[attr-defined] # ty: ignore[missing-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: ignore[unresolved-attribute]
107+
nargs_range: tuple[int, int | float] | None = self.action.get_nargs_range() # type: ignore[attr-defined] # ty: ignore[missing-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: ignore[unresolved-attribute]
578+
table_columns = arg_state.action.get_table_columns() # type: ignore[attr-defined] # ty: ignore[missing-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: ignore[unresolved-attribute]
609+
arg_state.action.get_table_columns(), # type: ignore[attr-defined] # ty: ignore[missing-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: ignore[unresolved-attribute]
764+
completer = arg_state.action.get_completer() # type: ignore[attr-defined] # ty: ignore[missing-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: ignore[unresolved-attribute]
778+
choices_provider = arg_state.action.get_choices_provider() # type: ignore[attr-defined] # ty: ignore[missing-attribute]
779779
if choices_provider is not None:
780780
args, kwargs = self._prepare_callable_params(
781781
choices_provider,

‎cmd2/argparse_utils.py‎

Lines changed: 17 additions & 17 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: 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]
567+
new_arg.set_nargs_range(nargs_range) # type: ignore[attr-defined] # ty: ignore[missing-attribute]
568+
new_arg.set_choices_provider(choices_provider) # type: ignore[attr-defined] # ty: ignore[missing-attribute]
569+
new_arg.set_completer(completer) # type: ignore[attr-defined] # ty: ignore[missing-attribute]
570+
new_arg.set_suppress_tab_hint(suppress_tab_hint) # type: ignore[attr-defined] # ty: ignore[missing-attribute]
571+
new_arg.set_table_columns(table_columns) # type: ignore[attr-defined] # ty: ignore[missing-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: ignore[unresolved-attribute]
669+
record = self.remove_parser(name) # type: ignore[attr-defined] # ty: ignore[missing-attribute]
670670
records.append(record)
671671

672672
return records
673673

674674

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]
675+
argparse._SubParsersAction.remove_parser = _SubParsersAction_remove_parser # type: ignore[attr-defined] # ty: ignore[missing-attribute]
676+
argparse._SubParsersAction.remove_all_parsers = _SubParsersAction_remove_all_parsers # type: ignore[attr-defined] # ty: ignore[missing-attribute]
677677

678678

679679
@dataclass
@@ -768,19 +768,19 @@ def __init__(
768768
self.completer_class = completer_class
769769

770770
# To assist type checkers, recast these to reflect our usage of rich-argparse.
771-
self.formatter_class: type[Cmd2HelpFormatter] # ty: ignore[invalid-mutable-override]
772-
self.description: HelpContent | None # type: ignore[assignment] # ty: ignore[invalid-attribute-override]
773-
self.epilog: HelpContent | None # type: ignore[assignment] # ty: ignore[invalid-attribute-override]
771+
self.formatter_class: type[Cmd2HelpFormatter] # ty: ignore[incompatible-mutable-override]
772+
self.description: HelpContent | None # type: ignore[assignment] # ty: ignore[incompatible-attribute-override]
773+
self.epilog: HelpContent | None # type: ignore[assignment] # ty: ignore[incompatible-attribute-override]
774774

775-
def print_usage(self, file: IO[str] | None = None) -> None: # type: ignore[override] # ty: ignore[invalid-method-override]
775+
def print_usage(self, file: IO[str] | None = None) -> None: # type: ignore[override] # ty: ignore[incompatible-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: ignore[invalid-method-override]
783+
def print_help(self, file: IO[str] | None = None) -> None: # type: ignore[override] # ty: ignore[incompatible-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: ignore[unresolved-attribute]
987+
subparsers_action.remove_parser(subcommand), # type: ignore[attr-defined] # ty: ignore[missing-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: ignore[unresolved-attribute]
1009+
subparsers_action.remove_all_parsers(), # type: ignore[attr-defined] # ty: ignore[missing-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: ignore[unresolved-attribute]
1049+
nargs_range = action.get_nargs_range() # type: ignore[attr-defined] # ty: ignore[missing-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: ignore[unresolved-attribute]
1069+
nargs_range = action.get_nargs_range() # type: ignore[attr-defined] # ty: ignore[missing-attribute]
10701070
if nargs_range is not None:
10711071
raise ArgumentError(action, build_range_error(nargs_range[0], nargs_range[1]))
10721072

‎cmd2/rich_utils.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def console(self) -> "Cmd2RichArgparseConsole":
156156
return self._console
157157

158158
@console.setter
159-
def console(self, console: "Cmd2RichArgparseConsole") -> None: # ty: ignore[invalid-property-type-override]
159+
def console(self, console: "Cmd2RichArgparseConsole") -> None: # ty: ignore[incompatible-property-override]
160160
"""Set our console instance."""
161161
self._file = None
162162
self._console = console
@@ -200,7 +200,7 @@ def _format_args(self, action: argparse.Action, default_metavar: str) -> str:
200200
get_metavar = self._metavar_formatter(action, default_metavar)
201201

202202
# Handle nargs specified as a range
203-
nargs_range = action.get_nargs_range() # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
203+
nargs_range = action.get_nargs_range() # type: ignore[attr-defined] # ty: ignore[missing-attribute]
204204
if nargs_range is not None:
205205
arg_str = "%s" % get_metavar(1) # noqa: UP031
206206
range_str = self._build_nargs_range_str(nargs_range)
@@ -227,7 +227,7 @@ def _rich_metavar_parts(
227227
get_metavar = self._metavar_formatter(action, default_metavar)
228228

229229
# Handle nargs specified as a range
230-
nargs_range = action.get_nargs_range() # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
230+
nargs_range = action.get_nargs_range() # type: ignore[attr-defined] # ty: ignore[missing-attribute]
231231
if nargs_range is not None:
232232
yield "%s" % get_metavar(1), True # noqa: UP031
233233
yield self._build_nargs_range_str(nargs_range), False

‎cmd2/utils.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ def _reader_thread_func(self, read_stdout: bool) -> None:
11371137
# Run until process completes
11381138
polled = self._terminal_fd is None and self._pipeline is None
11391139
while (self._proc.poll() if polled else self._proc.returncode) is None:
1140-
available = read_stream.peek() # type: ignore[attr-defined] # ty: ignore[unresolved-attribute]
1140+
available = read_stream.peek() # type: ignore[attr-defined] # ty: ignore[missing-attribute]
11411141
if available:
11421142
read_stream.read(len(available))
11431143
self._write_bytes(write_stream, available)

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ dev = [
5050
"pytest-xdist>=3.8",
5151
"ruff>=0.16.0",
5252
"textual-tty>=0.4.0 ; sys_platform != 'win32'",
53-
"ty>=0.0.75",
53+
"ty>=0.0.100",
5454
"zensical>=0.0.57",
5555
]
5656
docs = [
@@ -72,7 +72,7 @@ test = [
7272
validate = [
7373
"ipython>=8.23",
7474
"mypy>=2.3.1",
75-
"ty>=0.0.75",
75+
"ty>=0.0.100",
7676
"types-setuptools>=80.8.0",
7777
]
7878

0 commit comments

Comments
 (0)