-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Unbound local due to missing "partial\n" in py.typed #5999
Comments
That's obviously your call, but I should emphasize that this only happened because I was blundering about, trying something that was expressly outside the defined scope of PEP-561, in an attempt to get a stub-only distribution & package for a 3rd party distribution & package recognized by mypy (OTOH, the question of why my stub-only it isn't being recognized might itself be....) |
The fix is easy enough that it should get cherrypicked before it matters. PR incoming :) |
Also @wcooley feel free to open a new issue if you think mypy isn't finding a stub package it should. |
mypy: 0.641
Python: 3.6.5 built with pyenv on macOS 10.13.6
Crash with traceback.
Either not crashing or exiting with a helpful error message.
I have not tried but seeing where the obvious error in the code is, I do not see any difference in master at this time.
No flags are needed to cause the failure.
I am attempting to create a stub-only package for a 3rd party package. In attempting to figure out why it is not working, I created an empty
py.typed
alongside the installed stubfiles (I know PEP 561 says it is not necessary... but it does not forbid it either). Afterwards, I get the followingUnboundLocalError
exception when I runmypy
, which goes away when I create it withprintf "partial\n" > .../py.typed
:The cause of the error is obvious:
runtime_path
is not assigned outside of theif
conditional on line 157 and not checked before theappend
on line 159.It seems like there should be an
else
clause that at least exits without a traceback with a helpful error message, like 'Either {stub_typed_file} should not exist or it should have "partial\n" at the beginning.' Alternatively, thepy.typed
file could be ignored as it is redundant.But I am confused about this behavior with the
py.typed
marker file in a "<...>-stubs" package: PEP 561 says that if the stubs package is partial, it must includepy.typed
with "partial\n", which implies to me that if thepy.typed
file exists without "partial\n", then it indicates the package is not partial (which might be the default assumption and therefore redundant). Perhaps this is an ambiguity I should take up with the PEP 561 author?The text was updated successfully, but these errors were encountered: