Skip to content

Commit

Permalink
Fixed missing newline and removed debug code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachaa-Thanasius committed Apr 14, 2024
1 parent 347936e commit cd86fab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 0 additions & 6 deletions jishaku/inline_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,6 @@ def transform_source(source: typing.Union[str, ReadableBuffer]) -> str:
encoding, _ = tokenize.detect_encoding(stream.readline)
stream.seek(0)
tokens_list = transform_tokens(tokenize.tokenize(stream.readline))
try:
if tokens_list[1].type == tokenize.COMMENT:
import pprint
pprint.pprint(tokens_list)
except IndexError:
pass
return tokenize.untokenize(tokens_list).decode(encoding)


Expand Down
3 changes: 2 additions & 1 deletion tests/test_inline_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,10 @@ def test_bytes_input() -> None:
code = compile(tree, "<string>", "eval")
assert eval(code) == TYPE_CHECKING


@pytest.mark.parametrize("test_input", ["# comment here", "print('hello')\n# comment at end"])
def test_comments_input(test_input: str) -> None:
# Check that python3.8's adding of a bad NEWLINE token is accounted for when code ends with a comment and no newline.
tree = inline_import.parse(test_input, "<unknown>", mode="exec")
code = compile(tree, "<string>", "exec")
eval(code, None, None)
eval(code, None, None)

0 comments on commit cd86fab

Please sign in to comment.