Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit 88bb0b8

Browse files
committed
Add first set of classes for Python formatter
1 parent d227fa4 commit 88bb0b8

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

rewrite/rewrite/python/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .parser import *
55
from .visitor import *
66
from .markers import *
7+
from .format import *
78

89
__all__ = [
910
'Py',
@@ -51,4 +52,7 @@
5152
'UnionType',
5253
'VariableScope',
5354
'YieldFrom',
55+
56+
# Formatter
57+
'AutoFormat',
5458
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
2+
3+
from .auto_format import *
4+
5+
__all__ = [
6+
'AutoFormat'
7+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from typing import Optional
2+
3+
from rewrite import Recipe, Tree, Cursor
4+
from rewrite.python import PythonVisitor
5+
from rewrite.visitor import P, T
6+
7+
8+
class AutoFormat(Recipe):
9+
def get_visitor(self):
10+
return AutoFormatVisitor()
11+
12+
13+
class AutoFormatVisitor(PythonVisitor):
14+
def __init__(self, stop_after: Tree = None):
15+
self._stop_after = stop_after
16+
17+
def visit(self, tree: Optional[Tree], p: P, parent: Optional[Cursor] = None) -> Optional[T]:
18+
pass

0 commit comments

Comments
 (0)