kislyuk / argcomplete

Python and tab completion, better together.
https://kislyuk.github.io/argcomplete/
Apache License 2.0
1.39k stars 129 forks source link

mypy: Full annotations #397

Closed tony closed 1 year ago

tony commented 1 year ago

Moved to https://github.com/kislyuk/argcomplete/pull/401

Based on #378 Fixes #377
codecov-commenter commented 1 year ago

Codecov Report

Base: 80.59% // Head: 80.54% // Decreases project coverage by -0.05% :warning:

Coverage data is based on head (17ece19) compared to base (ed82421). Patch coverage: 44.44% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #397 +/- ## =========================================== - Coverage 80.59% 80.54% -0.06% =========================================== Files 6 6 Lines 737 740 +3 =========================================== + Hits 594 596 +2 - Misses 143 144 +1 ``` | [Impacted Files](https://codecov.io/gh/kislyuk/argcomplete/pull/397?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Kislyuk) | Coverage Δ | | |---|---|---| | [argcomplete/\_check\_console\_script.py](https://codecov.io/gh/kislyuk/argcomplete/pull/397/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Kislyuk#diff-YXJnY29tcGxldGUvX2NoZWNrX2NvbnNvbGVfc2NyaXB0LnB5) | `0.00% <0.00%> (ø)` | | | [argcomplete/\_check\_module.py](https://codecov.io/gh/kislyuk/argcomplete/pull/397/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Kislyuk#diff-YXJnY29tcGxldGUvX2NoZWNrX21vZHVsZS5weQ==) | `39.06% <25.00%> (-0.63%)` | :arrow_down: | | [argcomplete/my\_argparse.py](https://codecov.io/gh/kislyuk/argcomplete/pull/397/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Kislyuk#diff-YXJnY29tcGxldGUvbXlfYXJncGFyc2UucHk=) | `81.66% <100.00%> (+0.20%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Kislyuk). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Kislyuk)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

tony commented 1 year ago

@kislyuk This would be a huge PR for me to complete - I want to wait for a thumbs up before I start (as it'd take me half a day or more)

``` argcomplete on  mypy-strict [!⇕] ❯ ls argcomplete/**/*.py argcomplete/*.py | entr -c mypy argcomplete/my_shlex.py:28: error: Unused "type: ignore" comment argcomplete/my_shlex.py:34: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_shlex.py:63: error: Need type annotation for "pushback" [var-annotated] argcomplete/my_shlex.py:67: error: Need type annotation for "filestack" [var-annotated] argcomplete/my_shlex.py:76: error: Need type annotation for "_pushback_chars" [var-annotated] argcomplete/my_shlex.py:87: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_shlex.py:93: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_shlex.py:108: error: Function is missing a return type annotation [no-untyped-def] argcomplete/my_shlex.py:108: note: Use "-> None" if function does not return a value argcomplete/my_shlex.py:117: error: Function is missing a return type annotation [no-untyped-def] argcomplete/my_shlex.py:125: error: Call to untyped function "read_token" in typed context [no-untyped-call] argcomplete/my_shlex.py:129: error: Call to untyped function "sourcehook" in typed context [no-untyped-call] argcomplete/my_shlex.py:129: error: Call to untyped function "read_token" in typed context [no-untyped-call] argcomplete/my_shlex.py:132: error: Call to untyped function "push_source" in typed context [no-untyped-call] argcomplete/my_shlex.py:133: error: Call to untyped function "get_token" in typed context [no-untyped-call] argcomplete/my_shlex.py:139: error: Call to untyped function "pop_source" in typed context [no-untyped-call] argcomplete/my_shlex.py:140: error: Call to untyped function "get_token" in typed context [no-untyped-call] argcomplete/my_shlex.py:149: error: Function is missing a return type annotation [no-untyped-def] argcomplete/my_shlex.py:167: error: Incompatible types in assignment (expression has type "None", variable has type "str") [assignment] argcomplete/my_shlex.py:236: error: Incompatible types in assignment (expression has type "None", variable has type "str") [assignment] argcomplete/my_shlex.py:289: error: Incompatible types in assignment (expression has type "None", variable has type "str") [assignment] argcomplete/my_shlex.py:300: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_shlex.py:310: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_shlex.py:318: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_shlex.py:321: error: Function is missing a return type annotation [no-untyped-def] argcomplete/my_shlex.py:322: error: Call to untyped function "get_token" in typed context [no-untyped-call] argcomplete/completers.py:8: error: Function is missing a type annotation [no-untyped-def] argcomplete/completers.py:18: error: Function is missing a type annotation [no-untyped-def] argcomplete/completers.py:21: error: Function is missing a type annotation [no-untyped-def] argcomplete/completers.py:26: error: Function is missing a type annotation [no-untyped-def] argcomplete/completers.py:27: error: Call to untyped function "_convert" in typed context [no-untyped-call] argcomplete/completers.py:30: error: Call to untyped function "ChoicesCompleter" in typed context [no-untyped-call] argcomplete/completers.py:38: error: Function is missing a type annotation [no-untyped-def] argcomplete/completers.py:46: error: Function is missing a type annotation [no-untyped-def] argcomplete/completers.py:50: error: Call to untyped function "_call" in typed context [no-untyped-call] argcomplete/completers.py:53: error: Call to untyped function "_call" in typed context [no-untyped-call] argcomplete/completers.py:55: error: Call to untyped function "_call" in typed context [no-untyped-call] argcomplete/completers.py:56: error: Call to untyped function "_call" in typed context [no-untyped-call] argcomplete/completers.py:65: error: Function is missing a type annotation [no-untyped-def] argcomplete/completers.py:75: error: Function is missing a type annotation [no-untyped-def] argcomplete/completers.py:96: error: Function is missing a return type annotation [no-untyped-def] argcomplete/completers.py:96: note: Use "-> None" if function does not return a value argcomplete/completers.py:97: error: Call to untyped function "__init__" in typed context [no-untyped-call] argcomplete/completers.py:105: error: Function is missing a return type annotation [no-untyped-def] argcomplete/completers.py:105: note: Use "-> None" if function does not return a value argcomplete/completers.py:108: error: Function is missing a return type annotation [no-untyped-def] argcomplete/shell_integration.py:82: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_argparse.py:22: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_argparse.py:42: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_argparse.py:56: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_argparse.py:63: error: Call to untyped function "action_is_satisfied" in typed context [no-untyped-call] argcomplete/my_argparse.py:75: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_argparse.py:78: error: Need type annotation for "active_actions" (hint: "active_actions: List[] = ...") [var-annotated] argcomplete/my_argparse.py:85: error: Need type annotation for "action_conflicts" (hint: "action_conflicts: Dict[, ] = ...") [var-annotated] argcomplete/my_argparse.py:124: error: Need type annotation for "seen_non_default_actions" (hint: "seen_non_default_actions: Set[] = ...") [var-annotated] argcomplete/my_argparse.py:127: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_argparse.py:161: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_argparse.py:170: error: Need type annotation for "action_tuples" (hint: "action_tuples: List[] = ...") [var-annotated] argcomplete/my_argparse.py:221: error: Invalid index type "Action" for "Dict[str, int]"; expected type "str" [index] argcomplete/my_argparse.py:229: error: Invalid index type "Action" for "Dict[str, int]"; expected type "str" [index] argcomplete/my_argparse.py:230: error: Call to untyped function "action_is_open" in typed context [no-untyped-call] argcomplete/my_argparse.py:241: error: Call to untyped function "take_action" in typed context [no-untyped-call] argcomplete/my_argparse.py:249: error: Function is missing a type annotation [no-untyped-def] argcomplete/my_argparse.py:262: error: Invalid index type "Action" for "Dict[str, int]"; expected type "str" [index] argcomplete/my_argparse.py:263: error: Call to untyped function "take_action" in typed context [no-untyped-call] argcomplete/my_argparse.py:286: error: Call to untyped function "consume_positionals" in typed context [no-untyped-call] argcomplete/my_argparse.py:304: error: Call to untyped function "consume_optional" in typed context [no-untyped-call] argcomplete/my_argparse.py:307: error: Call to untyped function "consume_positionals" in typed context [no-untyped-call] argcomplete/my_argparse.py:339: error: Argument 1 to "join" of "str" has incompatible type "List[Optional[str]]"; expected "Iterable[str]" [arg-type] argcomplete/_check_module.py:14: error: Unused "type: ignore" comment argcomplete/_check_module.py:42: error: Function is missing a type annotation [no-untyped-def] argcomplete/_check_module.py:65: error: Function is missing a return type annotation [no-untyped-def] argcomplete/_check_module.py:65: note: Use "-> None" if function does not return a value argcomplete/_check_module.py:71: error: Call to untyped function "find" in typed context [no-untyped-call] argcomplete/_check_module.py:75: error: Incompatible types in assignment (expression has type overloaded function, variable has type "Callable[[Union[Union[str, bytes, PathLike[str], PathLike[bytes]], int]], TextIO]") [assignment] argcomplete/_check_module.py:91: error: Call to untyped function "main" in typed context [no-untyped-call] argcomplete/__init__.py:20: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:40: error: Function is missing a return type annotation [no-untyped-def] argcomplete/__init__.py:50: error: Function is missing a return type annotation [no-untyped-def] argcomplete/__init__.py:64: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:68: error: Call to untyped function "shlex" in typed context [no-untyped-call] argcomplete/__init__.py:73: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:79: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:95: error: Call to untyped function "get_token" in typed context [no-untyped-call] argcomplete/__init__.py:101: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:102: error: Call to untyped function "split_word" in typed context [no-untyped-call] argcomplete/__init__.py:105: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:107: error: Call to untyped function "split_word" in typed context [no-untyped-call] argcomplete/__init__.py:116: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:127: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:134: error: Call to untyped function "FilesCompleter" in typed context [no-untyped-call] argcomplete/__init__.py:151: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:161: error: Call to untyped function "FilesCompleter" in typed context [no-untyped-call] argcomplete/__init__.py:200: error: Accessing "__init__" on an instance is unsound, since instance.__init__ could be from an incompatible subclass [misc] argcomplete/__init__.py:219: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:224: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:231: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:240: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:245: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:251: error: Call to untyped function "split_line" in typed context [no-untyped-call] argcomplete/__init__.py:265: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:275: error: Call to untyped function "_get_completions" in typed context [no-untyped-call] argcomplete/__init__.py:285: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:291: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:292: error: Call to untyped function "_patch_argument_parser" in typed context [no-untyped-call] argcomplete/__init__.py:298: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:301: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:303: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:310: error: Call to untyped function "collect_completions" in typed context [no-untyped-call] argcomplete/__init__.py:311: error: Call to untyped function "filter_completions" in typed context [no-untyped-call] argcomplete/__init__.py:312: error: Call to untyped function "quote_completions" in typed context [no-untyped-call] argcomplete/__init__.py:315: error: Function is missing a return type annotation [no-untyped-def] argcomplete/__init__.py:322: error: Need type annotation for "active_parsers" (hint: "active_parsers: List[] = ...") [var-annotated] argcomplete/__init__.py:323: error: Need type annotation for "visited_positionals" (hint: "visited_positionals: List[] = ...") [var-annotated] argcomplete/__init__.py:327: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:344: error: Name "action.__class__" is not defined [name-defined] argcomplete/__init__.py:344: error: Class cannot subclass "__class__" (has type "Any") [misc] argcomplete/__init__.py:345: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:346: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:347: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:348: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:349: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:354: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:355: error: Call to untyped function "patch" in typed context [no-untyped-call] argcomplete/__init__.py:367: error: Call to untyped function "patch" in typed context [no-untyped-call] argcomplete/__init__.py:369: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:370: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:374: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:375: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:378: error: Need type annotation for "aliases_by_parser" (hint: "aliases_by_parser: Dict[, ] = ...") [var-annotated] argcomplete/__init__.py:384: error: Call to untyped function "filter_aliases" in typed context [no-untyped-call] argcomplete/__init__.py:391: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:402: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:405: error: List comprehension has incompatible type List[List[Any]]; expected List[Tuple[Any, Any]] [misc] argcomplete/__init__.py:415: error: Call to untyped function "suppress" in typed context [no-untyped-call] argcomplete/__init__.py:419: error: Call to untyped function "_action_allowed" in typed context [no-untyped-call] argcomplete/__init__.py:422: error: Call to untyped function "_include_options" in typed context [no-untyped-call] argcomplete/__init__.py:426: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:434: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:435: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:439: error: Call to untyped function "action_is_greedy" in typed context [no-untyped-call] argcomplete/__init__.py:444: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:461: error: Call to untyped function "action_is_open" in typed context [no-untyped-call] argcomplete/__init__.py:469: error: Call to untyped function "action_is_satisfied" in typed context [no-untyped-call] argcomplete/__init__.py:469: error: Call to untyped function "action_is_open" in typed context [no-untyped-call] argcomplete/__init__.py:470: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:473: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:479: error: Call to untyped function "ChoicesCompleter" in typed context [no-untyped-call] argcomplete/__init__.py:484: error: Call to untyped function "suppress" in typed context [no-untyped-call] argcomplete/__init__.py:500: error: List comprehension has incompatible type List[List[Any]]; expected List[Tuple[Any, Any]] [misc] argcomplete/__init__.py:503: error: List comprehension has incompatible type List[List[Sequence[Any]]]; expected List[Tuple[Any, Any]] [misc] argcomplete/__init__.py:505: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:507: error: Item "ChoicesCompleter" of "Union[ChoicesCompleter, Any]" has no attribute "complete" [union-attr] argcomplete/__init__.py:515: error: Call to untyped function "debug" in typed context [no-untyped-call] argcomplete/__init__.py:518: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:531: error: Call to untyped function "_get_option_completions" in typed context [no-untyped-call] argcomplete/__init__.py:534: error: Call to untyped function "_get_next_positional" in typed context [no-untyped-call] argcomplete/__init__.py:538: error: Call to untyped function "_get_subparser_completions" in typed context [no-untyped-call] argcomplete/__init__.py:540: error: Call to untyped function "_complete_active_option" in typed context [no-untyped-call] argcomplete/__init__.py:548: error: Function is missing a return type annotation [no-untyped-def] argcomplete/__init__.py:572: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:583: error: "add" of "set" does not return a value [func-returns-value] argcomplete/__init__.py:585: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:633: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:651: error: Call to untyped function "split_line" in typed context [no-untyped-call] argcomplete/__init__.py:653: error: Call to untyped function "_get_completions" in typed context [no-untyped-call] argcomplete/__init__.py:661: error: Function is missing a return type annotation [no-untyped-def] argcomplete/__init__.py:697: error: Function is missing a type annotation [no-untyped-def] argcomplete/__init__.py:698: error: Call to untyped function "_action_allowed" of "CompletionFinder" in typed context [no-untyped-call] argcomplete/__init__.py:711: error: Call to untyped function "CompletionFinder" in typed context [no-untyped-call] argcomplete/__init__.py:715: error: Function is missing a type annotation [no-untyped-def] argcomplete/_check_console_script.py:25: error: Function is missing a return type annotation [no-untyped-def] argcomplete/_check_console_script.py:25: note: Use "-> None" if function does not return a value argcomplete/_check_console_script.py:47: error: Call to untyped function "find" in typed context [no-untyped-call] argcomplete/_check_console_script.py:55: error: Call to untyped function "main" in typed context [no-untyped-call] Found 170 errors in 7 files (checked 7 source files) ```
neithere commented 1 year ago

@tony thank you for your effort! Do you have plans to continue working on this? It would be beneficial for neithere/argh#107 too (argh uses argcomplete).

tony commented 1 year ago

@neithere Before embarking on this - I'm looking for a thumbs up from @kislyuk at https://github.com/kislyuk/argcomplete/pull/378#issuecomment-1364697960 in #378

Once #378 is in, I can continue the approach here typing the argcomplete codebase

kislyuk commented 1 year ago

@tony I merged #378 - please proceed.

tony commented 1 year ago

@neithere @kislyuk Moved to #401