|
68 | 68 | if rl_type == RlType.PYREADLINE: |
69 | 69 |
|
70 | 70 | # Save the original pyreadline display completion function since we need to override it and restore it |
71 | | - # noinspection PyProtectedMember |
| 71 | + # noinspection PyProtectedMember,PyUnresolvedReferences |
72 | 72 | orig_pyreadline_display = readline.rl.mode._display_completions |
73 | 73 |
|
74 | 74 | elif rl_type == RlType.GNU: |
@@ -104,6 +104,7 @@ def __subclasshook__(cls, C): |
104 | 104 |
|
105 | 105 | # Python 3.4 require contextlib2 for temporarily redirecting stderr and stdout |
106 | 106 | if sys.version_info < (3, 5): |
| 107 | + # noinspection PyUnresolvedReferences |
107 | 108 | from contextlib2 import redirect_stdout |
108 | 109 | else: |
109 | 110 | from contextlib import redirect_stdout |
@@ -704,6 +705,7 @@ def reset_completion_defaults(self) -> None: |
704 | 705 | if rl_type == RlType.GNU: |
705 | 706 | readline.set_completion_display_matches_hook(self._display_matches_gnu_readline) |
706 | 707 | elif rl_type == RlType.PYREADLINE: |
| 708 | + # noinspection PyUnresolvedReferences |
707 | 709 | readline.rl.mode._display_completions = self._display_matches_pyreadline |
708 | 710 |
|
709 | 711 | def tokens_for_completion(self, line: str, begidx: int, endidx: int) -> Tuple[List[str], List[str]]: |
@@ -1331,6 +1333,7 @@ def _display_matches_pyreadline(self, matches: List[str]) -> None: # pragma: no |
1331 | 1333 |
|
1332 | 1334 | # Print the header if one exists |
1333 | 1335 | if self.completion_header: |
| 1336 | + # noinspection PyUnresolvedReferences |
1334 | 1337 | readline.rl.mode.console.write('\n' + self.completion_header) |
1335 | 1338 |
|
1336 | 1339 | # Display matches using actual display function. This also redraws the prompt and line. |
@@ -2178,6 +2181,7 @@ def _cmdloop(self) -> bool: |
2178 | 2181 | readline.set_completion_display_matches_hook(None) |
2179 | 2182 | rl_basic_quote_characters.value = old_basic_quotes |
2180 | 2183 | elif rl_type == RlType.PYREADLINE: |
| 2184 | + # noinspection PyUnresolvedReferences |
2181 | 2185 | readline.rl.mode._display_completions = orig_pyreadline_display |
2182 | 2186 |
|
2183 | 2187 | self.cmdqueue.clear() |
@@ -3013,6 +3017,7 @@ def py_quit(): |
3013 | 3017 | # Save cmd2 history |
3014 | 3018 | saved_cmd2_history = [] |
3015 | 3019 | for i in range(1, readline.get_current_history_length() + 1): |
| 3020 | + # noinspection PyArgumentList |
3016 | 3021 | saved_cmd2_history.append(readline.get_history_item(i)) |
3017 | 3022 |
|
3018 | 3023 | readline.clear_history() |
@@ -3045,6 +3050,7 @@ def py_quit(): |
3045 | 3050 | if rl_type == RlType.GNU: |
3046 | 3051 | readline.set_completion_display_matches_hook(None) |
3047 | 3052 | elif rl_type == RlType.PYREADLINE: |
| 3053 | + # noinspection PyUnresolvedReferences |
3048 | 3054 | readline.rl.mode._display_completions = self._display_matches_pyreadline |
3049 | 3055 |
|
3050 | 3056 | # Save off the current completer and set a new one in the Python console |
@@ -3082,6 +3088,7 @@ def py_quit(): |
3082 | 3088 | # Save py's history |
3083 | 3089 | self.py_history.clear() |
3084 | 3090 | for i in range(1, readline.get_current_history_length() + 1): |
| 3091 | + # noinspection PyArgumentList |
3085 | 3092 | self.py_history.append(readline.get_history_item(i)) |
3086 | 3093 |
|
3087 | 3094 | readline.clear_history() |
@@ -3159,10 +3166,12 @@ def do_ipy(self, _: argparse.Namespace) -> None: |
3159 | 3166 | exit_msg = 'Leaving IPython, back to {}'.format(sys.argv[0]) |
3160 | 3167 |
|
3161 | 3168 | if self.locals_in_py: |
3162 | | - def load_ipy(self, app): |
| 3169 | + # noinspection PyUnusedLocal |
| 3170 | + def load_ipy(cmd2_instance, app): |
3163 | 3171 | embed(banner1=banner, exit_msg=exit_msg) |
3164 | 3172 | load_ipy(self, bridge) |
3165 | 3173 | else: |
| 3174 | + # noinspection PyUnusedLocal |
3166 | 3175 | def load_ipy(app): |
3167 | 3176 | embed(banner1=banner, exit_msg=exit_msg) |
3168 | 3177 | load_ipy(bridge) |
@@ -3383,7 +3392,7 @@ def do_edit(self, args: argparse.Namespace) -> None: |
3383 | 3392 |
|
3384 | 3393 | command = utils.quote_string_if_needed(os.path.expanduser(self.editor)) |
3385 | 3394 | if args.file_path: |
3386 | | - command += " " + utils.quote_string_if_needed(os.path.expanduser(args.file_path)) |
| 3395 | + command += " " + utils.quote_string_if_needed(os.path.expaclass nduser(args.file_path)) |
3387 | 3396 |
|
3388 | 3397 | self.do_shell(command) |
3389 | 3398 |
|
@@ -3564,6 +3573,7 @@ def async_alert(self, alert_msg: str, new_prompt: Optional[str] = None) -> None: |
3564 | 3573 | if rl_type == RlType.GNU: |
3565 | 3574 | sys.stderr.write(terminal_str) |
3566 | 3575 | elif rl_type == RlType.PYREADLINE: |
| 3576 | + # noinspection PyUnresolvedReferences |
3567 | 3577 | readline.rl.mode.console.write(terminal_str) |
3568 | 3578 |
|
3569 | 3579 | # Redraw the prompt and input lines |
|
0 commit comments