We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 18adcdb commit 86e0a82Copy full SHA for 86e0a82
_misc/_ensure_annotations.py
@@ -17,6 +17,7 @@
17
import ast
18
import inspect
19
import sys
20
+import textwrap
21
from functools import partial
22
from types import FunctionType
23
from typing import Any
@@ -39,7 +40,7 @@ def ensure_annotations[T: type | FunctionType](f: T) -> T:
39
40
if _cycle_blocked:
41
return f
42
- new_ast = rec(ast.parse(inspect.getsource(f)), optimize=1)
43
+ new_ast = rec(ast.parse(textwrap.dedent(inspect.getsource(f))), optimize=1)
44
45
env = sys.modules[f.__module__].__dict__
46
0 commit comments