Skip to content

Commit 408e1ad

Browse files
committed
Don't defer ast import
While we can easily make ast import lazy in inspect module, it is anyway imported in annotationlib, which cannot be made lazy.
1 parent 9006af2 commit 408e1ad

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Lib/inspect.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
import abc
146146
from annotationlib import Format, ForwardRef
147147
from annotationlib import get_annotations # re-exported
148+
import ast
148149
import dis
149150
import collections.abc
150151
import enum
@@ -2155,8 +2156,6 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True):
21552156
"""Private helper to parse content of '__text_signature__'
21562157
and return a Signature based on it.
21572158
"""
2158-
import ast
2159-
21602159
Parameter = cls._parameter_cls
21612160
clean_signature, self_parameter = _signature_strip_non_python_syntax(s)
21622161
program = "def foo" + clean_signature + ": pass"

0 commit comments

Comments
 (0)