Skip to content

Commit

Permalink
Apply a couple of user-proposed fixes to merge-pyi.
Browse files Browse the repository at this point in the history
These fixes were proposed by @mrolle45 in the linked issues.

Resolves #1153.
Resolves #1156.

PiperOrigin-RevId: 436350521
  • Loading branch information
rchen152 committed Mar 22, 2022
1 parent 2c21609 commit f21eeb5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pytype/tools/merge_pyi/merge_pyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def has_return_exprs(cls, node):
return True
return False

driver = driver.Driver(pygram.python_grammar, convert=pytree.convert)
driver = driver.Driver(
pygram.python_grammar_no_print_statement, convert=pytree.convert)

@classmethod
def parse_string(cls, text):
Expand Down Expand Up @@ -237,6 +238,8 @@ def split_colon(nodes):
return is_tuple, stars, arg_type, arg, default

if len(arg) != 1:
if not arg and stars == '*':
return is_tuple, stars, arg_type, arg, default
raise KnownError() # expected/parse_error.py

node = arg[0]
Expand Down Expand Up @@ -918,7 +921,7 @@ def is_comma(n):
def annotate_string(args, py_src, pyi_src):
"""Applies the annotations in pyi_src to py_src."""

tool = StandaloneRefactoringTool(options={})
tool = StandaloneRefactoringTool(options={'print_function': True})
fixer = tool.fixer

fixer.annotate_pep484 = not args.as_comments
Expand Down

0 comments on commit f21eeb5

Please sign in to comment.