MyPy complains if file replaced by shadow-file doesn't exist

Aperta
#4,746 8 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

Start by reproducing the three commands in the issue with mypy 0.570 or a current checkout, then trace the --shadow-file argument handling and file-existence checks. Done means a missing source file mapped to an existing shadow file behaves like the shadow file, while an unrelated mapping does not produce a misleading missing-file error.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

This is a follow-up to https://github.com/python/mypy/issues/2119. I think this a bug report, but maybe it's a feature request, or even possibly a documentation request.

I'm surprised by the following behavior of --shadow-file SOURCE_FILE SHADOW_FILE:

$ cd /tmp/
$ mkdir python
$ cd python/
$ echo "x = 1 + 'A'" > shadow.py
$ mypy --shadow-file error.py shadow.py error.py #1
mypy: can't read file 'error.py': No such file or directory
$ mypy --shadow-file error.py shadow.py shadow.py #2
mypy: can't read file 'shadow.py': No such file or directory
$ mypy shadow.py #3
shadow.py:1: error: Unsupported operand types for + ("int" and "str")

I see two problems here:

  • I expected # (1) to behave just as if there had been a file error.py with the contents of shadow.py, returning the same as # (3). This use case happens concretely when a user of Emacs creates a new file (but hasn't saved it to disk yet). In that case we create a temporary file with the contents of the unsaved file, and pass that as shadow.py, with error.py being the name of the yet-unsaved file.

  • In # (2) I did not expected the --shadow-file option to make a difference, since I remapped error.py to shadow.py and then asked about shadow.py (which shouldn't be affected by the unrelated mapping). Additionally, the error seems wrong (the file shadow.py exists).

I'm using mypy 0.570 and Python 3.5.2 (I have not tried with mypy from git master)

Am I misunderstanding the way --shadow-file is used?

Thanks!

Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Merge medio
1g 18h
PR unite (30g)
54

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python/mypy

Tutte le issue di python/mypy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.