-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't workingruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
If a feature imported from __future__ is used later in the module, it is not unnecessary, so unnecessary-future-import (UP010) should not flag it. Example:
$ cat >up010.py <<'# EOF'
from __future__ import print_function
print(print_function)
# EOF
$ python up010.py
_Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 1048576)
$ ruff --isolated check up010.py --select UP010 --fix
Found 1 error (1 fixed, 0 remaining).
$ python up010.py 2>&1 | tail -n 1
NameError: name 'print_function' is not definedThis also applies to reexports using __all__ like this:
from __future__ import print_function
__all__ = ["print_function"]Version
ruff 0.12.5 (d13228a 2025-07-24)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingruleImplementing or modifying a lint ruleImplementing or modifying a lint rule