Leading whitespace is lost during parsing
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Riproduci il problema usando RequirementsFile.from_file e dumps con una riga di requirements o un commento che inizi con degli spazi, quindi traccia il punto in cui questi spazi iniziali vengono scartati. Confronta l’output con gli esempi originali, incluse le righe di continuazione indentate. Il lavoro è completato quando dumps preserva gli spazi iniziali continuando a gestire correttamente i requirements analizzati; aggiungi una copertura di regressione per questi casi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Thanks for building pip-requirements-parser! I'm really happy with it.
I noticed that if I parse a requirements file and then print it out with dumps, any leading whitespace before a requirement or comment gets removed. Example below:
(env) tetsuo@Alexs-MacBook-Pro pip-audit % cat requirements.txt
flask==0.5
(env) tetsuo@Alexs-MacBook-Pro pip-audit % python
Python 3.9.13 (main, May 24 2022, 21:13:51)
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pip_requirements_parser import RequirementsFile
>>> rf = RequirementsFile.from_file("requirements.txt")
>>> rf.dumps()
'flask==0.5'
It seems that whitespace within the line is preserved, it's just when it exists at the beginning of the line that it gets stripped.
(env) tetsuo@Alexs-MacBook-Pro pip-audit % cat base.txt
django-celery-results==2.3.1 \
--hash=sha256:b8c9416619dbcc38f13398e31bcb1f14a228cd1e8f65fb22d3b7fc68aaa5331a \
--hash=sha256:bf24ecc29c42e49cc7eb30b9b3739471331e2a0ca517cc88ca53a0cf3a2031d1
(env) tetsuo@Alexs-MacBook-Pro pip-audit % python
Python 3.9.13 (main, May 24 2022, 21:13:51)
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pip_requirements_parser import RequirementsFile
>>> rf = RequirementsFile.from_file("base.txt")
>>> rf.dumps()
'django-celery-results==2.3.1 \\\n --hash=sha256:b8c9416619dbcc38f13398e31bcb1f14a228cd1e8f65fb22d3b7fc68aaa5331a \\\n --hash=sha256:bf24ecc29c42e49cc7eb30b9b3739471331e2a0ca517cc88ca53a0cf3a2031d1'
This matters to pip-audit because our use case involves parsing a requirements file and then rewriting it with some of the requirements modified. So any requirements files that have leading whitespace will have the whitespace removed when we rewrite a requirements file.
The first example that comes to mind are automatic comments that are indented like those inserted by pip-compile.
Are you interested in having pip-requirements-parser support this use case? If so, I'm happy to take a stab at a PR.
- Lingua principale
- Python
- Stelle
- 20
- Fork
- 16
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
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 aboutcode-org/pip-requirements-parser
-
Quadratic comment split on a requirements file line (pip_requirements_parser.py:1058)Forse già presa @Anurag-S1ngh l’ha presa 6 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
aboutcode-org/pip-requirements-parser#30 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 60/100
-
Tests failures with packaging 26.0Forse già presa @s-t-e-v-e-n-k l’ha presa 270 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
aboutcode-org/pip-requirements-parser#26 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
Tutte le issue di aboutcode-org/pip-requirements-parser
Issue simili
-
Admin member of a research group cannot see the HX2 allocation until they've been added to itAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
developmentseed/titiler-cmr#278 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni