You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importloggingimportsome.module# ruff thinks this is not useddeffunc():
logger=logging.getLogger('some')
try:
importsome.otherprint(some.other.version)
returnNoneexceptExceptionase:
logger.exception('exception'%e, extra={'now': some.module.now()})
raise
If I move the import into the function - it's no longer flagged:
importloggingdeffunc():
importsome.module# now it's not flaggedlogger=logging.getLogger('some')
try:
importsome.otherprint(some.other.version)
returnNoneexceptExceptionase:
logger.exception('exception'%e, extra={'now': some.module.now()})
raise
The text was updated successfully, but these errors were encountered:
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.
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:
The text was updated successfully, but these errors were encountered: