Open bnomis opened 3 months ago
This seems like a mix of some issues with modeling submodule imports (we roughly treat import some.module
and import some.other
as equivalent) and control flow analysis.
There's more on submodule imports in (e.g.) #4656.
The interesting thing about submodule imports is -- this on its own will often:
def func():
logger = logging.getLogger('some')
try:
import some.other
print(some.other.version)
return None
except Exception as e:
logger.exception('exception' % e, extra={'now': some.module.now()})
raise
Ruff version 0.4.4
Flags
import some.module
in the below as unused F401 but it is usedhttps://play.ruff.rs/f84ea9b2-0401-491f-a6a9-20f4e370d47f
If I move the import into the function - it's no longer flagged: