-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
--imports
option for outputting # from xxx.yyy import function_name
#26
Comments
The interesting challenge here is how to figure out that import string, since it depends on the location of the function relative to the Python path. I think the following heuristics should work:
|
Tried those heuristics and found a problem - when using the Might be that it needs a |
That Part of the reason I'm having trouble here is that
|
This initial implementation doesn't yet do anything fancy with |
Refs #26 Signed-off-by: Simon Willison <swillison@gmail.com>
This does not do the right thing with class methods, symbex '*.*' -in # from tests.example_symbols import __init__
def __init__(self, a)
# from tests.example_symbols import method_types
def method_types(self, b: int) -> bool For class methods attempting to display a What would make sense? I guess showing the name of the class, which the symbex '*.*' --imports # File: tests/example_symbols.py Class: ClassWithMethods Line: 79
# from tests.example_symbols import __init__
def __init__(self, a)
# File: tests/example_symbols.py Class: ClassWithMethods Line: 82
# from tests.example_symbols import method_types
def method_types(self, b: int) -> bool |
So what should # Class tests.ClassWithMethods
def __init__(self, a) So the class is fully qualified. Or maybe it should look like this: # from tests import ClassWithMethods
def __init__(self, a) I think that second option is more consistent with |
A thing that worries me about this feature is that it's genuinely making promises it can't keep. If an LLM is fed an incorrect If a user is browsing function documentation using this and reads an incorrect |
This will make it even easier to pipe
-s
output tollm
and get back working code examples.Should output:
Also a
--no-file
option to suppress output of the# File:
lines.Those can have shortcuts of
-i
for--imports
and-n
for--no-code
- so if you want to apply both (and just get the imports) you can then do this:The text was updated successfully, but these errors were encountered: