Add option to select scope for doctests
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- testing-qa, tooling
Direzione di ricerca
Start with the test.py reproducer in the issue and run pyflakes against it, then inspect how doctest code is analyzed. Add a selectable scope for doctests so imports in doctest scope do not produce false redefinition warnings, while genuine unused-import warnings remain; verify the reported output and the SymPy example.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Original report by asmeurer (@asmeurer?) on Launchpad:
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://github.com/sympy/sympy/blob/master/sympy/physics/mechanics/functions.py, the output is
sympy/physics/mechanics/functions.py:160: redefinition of unused 'diff' from line 27
sympy/physics/mechanics/functions.py:200: redefinition of unused 'dynamicsymbols' from line 19
sympy/physics/mechanics/functions.py:261: redefinition of unused 'dynamicsymbols' from line 19
sympy/physics/mechanics/functions.py:458: redefinition of unused 'Point' from line 26
sympy/physics/mechanics/functions.py:508: redefinition of unused 'Point' from line 26
That is, it complains about the imports in the doctests, but not the imports themselves (because they actually are used in the file).
- Lingua principale
- Python
- Stelle
- 1.5k
- Fork
- 205
- Merge medio
- 1g 2h
- PR unite (30g)
- 5
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PyCQA/pyflakes
-
F542 is not a crimeAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 52/100
-
Use of await in a function that is not async should be shown as a syntax error by flake8Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
Tutte le issue di PyCQA/pyflakes
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
micropython/micropython#19906 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
FinanceFlash/unvibecode#597 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
TomAnthony/YourOwnWeigh#21 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG]: Compliance rules never see Unity Catalog views as viewsForse già presa @wagnercsantos l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
databrickslabs/ontos#1348 ·
I maintainer di solito rispondono entro 3 giorni
-
Deprecated datetime.utcnow() is called on every log line (DeprecationWarning on Python 3.12+)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni