-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MyPy complains if file replaced by shadow-file doesn't exist #4746
Comments
Your invocation (1) is correct, but the error.py file should still exist (its existence is checked before the shadowing goes into effect, though its contents is irrelevant). In (2) the shadow flag has no effect because you're not type-checking error.py. You'll find that if you create an empty error.py, (1) will work correctly -- it will report the same error as (3), except the filename will be error.py. |
Thanks!
But it does have an effect: mypy produces a nonsensical error message. Is that intended?
I'm well aware of this :) But it's inconvenient. Is there a strong reason to require that the file exist? |
Oh, I wonder if you've got the arguments to --shadow-file reversed. See #4712 |
Sorry if I'm being slow. I'm struggling to reconcile the docs (and the behavior that I observe) with your comment. In your comment you say that the correct invocation is
and indeed when I try thing in the order suggested by the docstring, everything works as expected:
whereas in the order that you suggest, I don't get errors:
My core issue is different, though; I'd like one of these (I'm not sure which one anymore :/) to work:
|
… and I made the mistake of mixing two bugs in one in my original report — sorry about this. The following seems suspicious to me:
(I could understand mypy complaining about |
This flag is just super confusing. Sorry.
…On Fri, Mar 16, 2018, 15:59 Clément Pit-Claudel ***@***.***> wrote:
… and I made the mistake of mixing two bugs in one in my original report —
sorry about this. The following seems suspicious to me:
$ touch a.py
$ mypy --shadow-file a.py nonexistent.py a.py
mypy: can't read file 'a.py': No such file or directory
$ mypy --shadow-file nonexistent.py a.py a.py
mypy: can't read file 'a.py': No such file or directory
(I could understand mypy complaining about nonexistent.py, but it seems
odd to complain about a.py, which does exists)
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#4746 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACwrMmmo4hRpi9fy0Q76aOC56zZqpwGnks5tfEPZgaJpZM4StQoG>
.
|
Also, if you want to help, you can put in some print statements (or better, use pdb) and try to find the bug(s) in the code. |
This is a follow-up to #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
:I see two problems here:
I expected
# (1)
to behave just as if there had been a fileerror.py
with 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.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 remappederror.py
toshadow.py
and then asked aboutshadow.py
(which shouldn't be affected by the unrelated mapping). Additionally, the error seems wrong (the fileshadow.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!
The text was updated successfully, but these errors were encountered: