Add option to select scope for doctests
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Pyflakes |
New
|
Wishlist
|
Unassigned |
Bug Description
test.py:
import sys
import sys
def func():
"""
A docstring
>>> import sys
>>> sys.path
"""
return 1
The pyflakes output is
test.py:1: 'sys' imported but unused
test.py:6: redefinition of unused 'sys' from line 1
The line 6 "redefinition of unused 'sys' from line 1" is incorrect, because the doctest scope is separate from the module scope.
I can't figure out how to reproduce it with a small file, but in this file: https:/
sympy/physics/
sympy/physics/
sympy/physics/
sympy/physics/
sympy/physics/
That is, it complains about the imports in the doctests, but not the imports themselves (because they actually are used in the file).
Changed in pyflakes: | |
importance: | Undecided → Wishlist |
Changed in pyflakes: | |
status: | New → Fix Released |
Changed in pyflakes: | |
status: | Fix Released → New |
summary: |
- Doctest scope is getting mixed in with regular scope + Add option to select scope for doctests |
I think it's because it's pushing a function scope for doctests, but really, it should be using a completely new module scope. Doctests are run like they a from-scratch Python interpreter.