Skip to content

Commit

Permalink
More debug/repr information and type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Oct 29, 2024
1 parent 7d1390e commit 19c71fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions lib/python/pyflyby/_autoimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,17 +341,24 @@ def symbol_needs_import(fullname, namespaces):
return True


class _UseChecker(object):
class _UseChecker:
"""
An object that can check whether it was used.
"""
used = False

def __init__(self, name, source, lineno):
used: bool = False
name: str
source: str
lineno: int

def __init__(self, name: str, source: str, lineno: int):
self.name = name
self.source = source # generally an Import
self.lineno = lineno

def __repr__(self):
return f"<{type(self).__name__}: name:{self.name} source:{self.source!r} lineno:{self.lineno} used:{self.used}>"


class _MissingImportFinder:
"""
Expand Down Expand Up @@ -923,9 +930,8 @@ def _visit_fullname(self, fullname, ctx):

def _visit_StoreImport(self, node, modulename):
name = node.asname or node.name
logger.debug("_visit_StoreImport(asname=%r,name=%r)",
node.asname, node.name)
is_star = node.name == '*'
logger.debug("_visit_StoreImport(asname=%r, name=%r)", node.asname, node.name)
is_star = node.name == "*"
if is_star:
logger.debug("Got star import: line %s: 'from %s import *'",
self._lineno, modulename)
Expand Down
2 changes: 1 addition & 1 deletion lib/python/pyflyby/_importstmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class NonImportStatementError(TypeError):
"""

@total_ordering
class Import(object):
class Import:
"""
Representation of the desire to import a single name into the current
namespace.
Expand Down

0 comments on commit 19c71fe

Please sign in to comment.