Skip to content

Commit

Permalink
More fixes for type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Sep 5, 2024
1 parent 6d5615b commit 464c116
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rewrite/rewrite/python/_parser_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,8 @@ def visit_UnaryOp(self, node):
def __convert_type_hint(self, node) -> Optional[TypeTree]:
if isinstance(node, ast.Constant):
literal = cast(j.Literal, self.__convert(node))
if node.value is None or node.value is Ellipsis:
return literal
return j.Identifier(
random_id(),
literal.prefix,
Expand Down
5 changes: 5 additions & 0 deletions rewrite/tests/python/all/literal_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def test_fraction_leading_dot():
rewrite_run(python("assert .0"))


def test_large_int():
# language=python
rewrite_run(python("assert 0xC03A0019"))


def test_single_quoted_string():
# language=python
rewrite_run(python("assert 'foo'"))
Expand Down

0 comments on commit 464c116

Please sign in to comment.