Show More
@@ -31,7 +31,7 b' import sys' | |||||
31 | import tokenize |
|
31 | import tokenize | |
32 | import warnings |
|
32 | import warnings | |
33 |
|
33 | |||
34 | from typing import List |
|
34 | from typing import List, Tuple, Union | |
35 |
|
35 | |||
36 | from IPython.core.inputtransformer import (leading_indent, |
|
36 | from IPython.core.inputtransformer import (leading_indent, | |
37 | classic_prompt, |
|
37 | classic_prompt, | |
@@ -150,7 +150,7 b' def partial_tokens(s):' | |||||
150 | else: |
|
150 | else: | |
151 | raise |
|
151 | raise | |
152 |
|
152 | |||
153 | def find_next_indent(code): |
|
153 | def find_next_indent(code) -> int: | |
154 | """Find the number of spaces for the next line of indentation""" |
|
154 | """Find the number of spaces for the next line of indentation""" | |
155 | tokens = list(partial_tokens(code)) |
|
155 | tokens = list(partial_tokens(code)) | |
156 | if tokens[-1].type == tokenize.ENDMARKER: |
|
156 | if tokens[-1].type == tokenize.ENDMARKER: | |
@@ -324,7 +324,7 b' class InputSplitter(object):' | |||||
324 | # If self.source matches the first value, the second value is a valid |
|
324 | # If self.source matches the first value, the second value is a valid | |
325 | # current indentation. Otherwise, the cache is invalid and the indentation |
|
325 | # current indentation. Otherwise, the cache is invalid and the indentation | |
326 | # must be recalculated. |
|
326 | # must be recalculated. | |
327 | _indent_spaces_cache = None, None |
|
327 | _indent_spaces_cache: Union[Tuple[None, None], Tuple[str, int]] = None, None | |
328 | # String, indicating the default input encoding. It is computed by default |
|
328 | # String, indicating the default input encoding. It is computed by default | |
329 | # at initialization time via get_input_encoding(), but it can be reset by a |
|
329 | # at initialization time via get_input_encoding(), but it can be reset by a | |
330 | # client with specific knowledge of the encoding. |
|
330 | # client with specific knowledge of the encoding. | |
@@ -332,7 +332,7 b' class InputSplitter(object):' | |||||
332 | # String where the current full source input is stored, properly encoded. |
|
332 | # String where the current full source input is stored, properly encoded. | |
333 | # Reading this attribute is the normal way of querying the currently pushed |
|
333 | # Reading this attribute is the normal way of querying the currently pushed | |
334 | # source code, that has been properly encoded. |
|
334 | # source code, that has been properly encoded. | |
335 |
source = |
|
335 | source: str = "" | |
336 | # Code object corresponding to the current source. It is automatically |
|
336 | # Code object corresponding to the current source. It is automatically | |
337 | # synced to the source, so it can be queried at any time to obtain the code |
|
337 | # synced to the source, so it can be queried at any time to obtain the code | |
338 | # object; it will be None if the source doesn't compile to valid Python. |
|
338 | # object; it will be None if the source doesn't compile to valid Python. | |
@@ -517,9 +517,10 b' class InputSplitter(object):' | |||||
517 | # General fallback - accept more code |
|
517 | # General fallback - accept more code | |
518 | return True |
|
518 | return True | |
519 |
|
519 | |||
520 | def get_indent_spaces(self): |
|
520 | def get_indent_spaces(self) -> int: | |
521 | sourcefor, n = self._indent_spaces_cache |
|
521 | sourcefor, n = self._indent_spaces_cache | |
522 | if sourcefor == self.source: |
|
522 | if sourcefor == self.source: | |
|
523 | assert n is not None | |||
523 | return n |
|
524 | return n | |
524 |
|
525 | |||
525 | # self.source always has a trailing newline |
|
526 | # self.source always has a trailing newline | |
@@ -568,7 +569,7 b' class IPythonInputSplitter(InputSplitter):' | |||||
568 | # Private attributes |
|
569 | # Private attributes | |
569 |
|
570 | |||
570 | # List with lines of raw input accumulated so far. |
|
571 | # List with lines of raw input accumulated so far. | |
571 |
_buffer_raw |
|
572 | _buffer_raw: List[str] | |
572 |
|
573 | |||
573 | def __init__(self, line_input_checker=True, physical_line_transforms=None, |
|
574 | def __init__(self, line_input_checker=True, physical_line_transforms=None, | |
574 | logical_line_transforms=None, python_line_transforms=None): |
|
575 | logical_line_transforms=None, python_line_transforms=None): | |
@@ -658,8 +659,8 b' class IPythonInputSplitter(InputSplitter):' | |||||
658 | tmp = transform.reset() |
|
659 | tmp = transform.reset() | |
659 | if tmp is not None: |
|
660 | if tmp is not None: | |
660 | yield tmp |
|
661 | yield tmp | |
661 |
|
662 | |||
662 | out = [] |
|
663 | out: List[str] = [] | |
663 | for t in self.transforms_in_use: |
|
664 | for t in self.transforms_in_use: | |
664 | out = _flush(t, out) |
|
665 | out = _flush(t, out) | |
665 |
|
666 |
General Comments 0
You need to be logged in to leave comments.
Login now