Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsdebruin committed Nov 29, 2024
1 parent dbf27f5 commit 5af2396
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions rewrite/rewrite/python/format/auto_format.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from typing import Optional, TypeVar
from typing import Optional

from .blank_lines import BlankLinesVisitor
from .normalize_format import NormalizeFormatVisitor
from .spaces_visitor import SpacesVisitor
from ..style import BlankLinesStyle, SpacesStyle, IntelliJ
from ..visitor import PythonVisitor
from ... import Recipe, Tree, Cursor
from ...java import JavaSourceFile, MethodDeclaration, J, Space
from ...java import JavaSourceFile
from ...visitor import P, T


@@ -23,6 +24,9 @@ def visit(self, tree: Optional[Tree], p: P, parent: Optional[Cursor] = None) ->
cu = tree if isinstance(tree, JavaSourceFile) else self._cursor.first_enclosing_or_throw(JavaSourceFile)

tree = NormalizeFormatVisitor(self._stop_after).visit(tree, p, self._cursor.fork())
tree = BlankLinesVisitor(cu.get_style(BlankLinesStyle) or IntelliJ.blank_lines(), self._stop_after).visit(tree, p, self._cursor.fork())
tree = SpacesVisitor(cu.get_style(SpacesStyle) or IntelliJ.spaces(), self._stop_after).visit(tree, p, self._cursor.fork())
tree = BlankLinesVisitor(cu.get_style(BlankLinesStyle) or IntelliJ.blank_lines(), self._stop_after).visit(tree,
p,
self._cursor.fork())
tree = SpacesVisitor(cu.get_style(SpacesStyle) or IntelliJ.spaces(), self._stop_after).visit(tree, p,
self._cursor.fork())
return tree
2 changes: 1 addition & 1 deletion rewrite/tests/manual_parser_test.py
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
RemotePrinterFactory(remoting_context.client).set_current()
remoting_context.client.reset()

parser = PythonParser()
parser = PythonParser(None)
res = parser.parse_inputs([ParserInput(pathlib.Path(path), None, False, lambda: open(path, 'r', newline='', encoding='utf-8'))], relative_to=None, ctx=InMemoryExecutionContext())
for r in res:
if isinstance(r, ParseError):

0 comments on commit 5af2396

Please sign in to comment.