-
Notifications
You must be signed in to change notification settings - Fork 169
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
monketype fails to stub the initial script #19
Comments
Yeah, when you run For now I'll add a documentation note to that effect. But I'll leave this open as a low-pri enhancement; if someone submits a PR that implements it in a way that looks robust, I'd consider it. |
Doc clarification added in de7868a Thanks for the report! This was definitely an oversight in the documentation, it wasn't at all clear which code |
Here's a simple but concrete example of this workaround: https://github.com/bhrutledge/til/blob/main/python/monkeytype-script.md |
@bhrutledge maybe this workaround not working anymore..? I have now this,
run_script.py import sys
sys.path.insert(1,'./src')
import sort
sort.main()
## this also not work
# from src import sort
# sort.main() then, however, ❯ monkeytype -v stub sort
WARNING: Failed decoding trace: No module named 'sort'
WARNING: Failed decoding trace: No module named 'sort'
No traces found for module sort stub and apply causes error. |
@Ryuta69
Here's an example of the second option: https://repl.it/@bhrutledge/monkeytyperunscript |
@bhrutledge oh, great! Now it works. Thank you very much! |
What about adding an option so MonkeyType creates a temp python file turning the "main" into a module? That is, to "automate" the workaround and no need for any bash. |
I'm open to something like this in principle as a resolution of this ticket, but I'm not clear how it should work in general. Does it assume that the script module has a It really seems like the "runner" script has to be created with some knowledge of the script itself. |
I think it should parse the file and look for |
I'm not sure what this means; we can't "call" an TBH the whole thing sounds quite finicky and unreliable to me; I'm not going to work on it, but if somebody has a concrete plan I'm willing to evaluate whether it seems workable and potentially look at a PR. |
This was exactly my "parsing the code" proposal.
great! let me bring somebody ;) |
I want to add types to
myscript.py
,so I do
monkeytype run myscript.py
but
monkeytype stub myscript.py
saysNo traces found
so I dumped
monkeytype.sqlite3
and see it has traces under the module named__main__
,but
monkeytype stub __main__
saysERROR: Failed decoding trace: Module '__main__' has no attribute 'main'
The text was updated successfully, but these errors were encountered: