File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 11import ast
22import inspect
3+ import textwrap
34from typing import (
45 Callable ,
56 Dict ,
@@ -34,7 +35,7 @@ def is_proxy(self) -> bool:
3435
3536 @cached_property
3637 def _nodes (self ) -> Iterator [ast .AST ]:
37- source = inspect .getsource (self .model_cls )
38+ source = textwrap . dedent ( inspect .getsource (self .model_cls ) )
3839 return iter (ast .parse (source ).body [0 ].body ) # type: ignore
3940
4041 def _parse (self , predicate : Optional [Callable [[ast .AST ], bool ]] = None ) -> None :
Original file line number Diff line number Diff line change @@ -14,9 +14,11 @@ class Meta:
1414 verbose_name = "Site Article"
1515
1616
17- class Author (models .Model ):
18- first_name = models .CharField (max_length = 100 )
19- last_name = models .CharField (max_length = 100 )
17+ if True :
18+ # test that indentation doesn't break ast parser
19+ class Author (models .Model ):
20+ first_name = models .CharField (max_length = 100 )
21+ last_name = models .CharField (max_length = 100 )
2022
2123
2224class NestedField (models .Field ):
You can’t perform that action at this time.
0 commit comments