Skip to content

Commit 0ba9e10

Browse files
committed
gh-156363: Use PEP 810 lazy imports for inspect and re in rlcompleter
Address review feedback: replace deferred in-function imports of `inspect` and `re` with `lazy import` statements at the top of the module, keeping them alongside the regular imports.
1 parent fadfaf9 commit 0ba9e10

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Lib/rlcompleter.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
import warnings
3737
import types
3838

39+
lazy import inspect
40+
lazy import re
41+
3942
__all__ = ["Completer"]
4043

4144
# Sentinel object to distinguish "missing" from "present but None"
@@ -103,7 +106,6 @@ def complete(self, text, state):
103106

104107
def _callable_postfix(self, val, word):
105108
if callable(val):
106-
import inspect
107109
word += "("
108110
try:
109111
if not inspect.signature(val).parameters:
@@ -152,7 +154,6 @@ def attr_matches(self, text):
152154
with a __getattr__ hook is evaluated.
153155
154156
"""
155-
import re
156157
m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text)
157158
if not m:
158159
return []

0 commit comments

Comments
 (0)