From cd2821577a3827d5b6091ba15e688f46e6206236 Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Tue, 29 Oct 2024 14:45:29 +0100 Subject: [PATCH] types --- lib/python/pyflyby/_autoimp.py | 7 ++++++- lib/python/pyflyby/_imports2s.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/python/pyflyby/_autoimp.py b/lib/python/pyflyby/_autoimp.py index ba6829af..4ab44033 100644 --- a/lib/python/pyflyby/_autoimp.py +++ b/lib/python/pyflyby/_autoimp.py @@ -959,7 +959,12 @@ def _visit_StoreImport(self, node, modulename): value = _UseChecker(name, imp, self._lineno) self._visit_Store(name, value) - def _visit_Store(self, fullname:str, value=None): + def _visit_Store(self, fullname: str, value: Optional[_UseChecker] = None): + """ + Visit a Store action, check for unused import + and add current value to the last scope. + """ + assert isinstance(value, (_UseChecker, type(None))) logger.debug("_visit_Store(%r)", fullname) if fullname is None: return diff --git a/lib/python/pyflyby/_imports2s.py b/lib/python/pyflyby/_imports2s.py index b21ac3df..110131f5 100644 --- a/lib/python/pyflyby/_imports2s.py +++ b/lib/python/pyflyby/_imports2s.py @@ -121,7 +121,7 @@ def pretty_print(self, params=None): result = [block.pretty_print(params=params) for block in self.blocks] return FileText.concatenate(result) - def find_import_block_by_lineno(self, lineno): + def find_import_block_by_lineno(self, lineno: int): """ Find the import block containing the given line number.