MyPy complains if file replaced by shadow-file doesn't exist
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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 fileerror.pywith the contents ofshadow.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 asshadow.py, witherror.pybeing the name of the yet-unsaved file. -
In
# (2)I did not expected the--shadow-fileoption to make a difference, since I remappederror.pytoshadow.pyand then asked aboutshadow.py(which shouldn't be affected by the unrelated mapping). Additionally, the error seems wrong (the fileshadow.pyexists).
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!
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 54
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python/mypy
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug topic-configuration topic-error-reporting
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100