Skip to content
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

Module docstrings don't work with together with Hy core imports #1540

Closed
Kodiologist opened this issue Mar 24, 2018 · 3 comments · Fixed by #1673
Closed

Module docstrings don't work with together with Hy core imports #1540

Kodiologist opened this issue Mar 24, 2018 · 3 comments · Fixed by #1673
Labels

Comments

@Kodiologist
Copy link
Member

Similarly to #1367, any automatic imports from core will prevent a string literal from being the first statement in a module, and hence from being the module docstring.

$ echo '"hello world" (print (get [1 2] 0))' > test.hy
$ hy -c '(import test) (print test.__doc__)'
1
hello world
$ echo '"hello world" (print (first [1 2]))' > test.hy 
$ hy -c '(import test) (print test.__doc__)'          
1
None
@gilch
Copy link
Member

gilch commented Mar 25, 2018

We can just set the __doc__ global and put module docstrings wherever we please. But I'd rather get rid of autoimports altogether somehow. It's causing a lot of problems and the above is just one of them. Hy's core is not discoverable with dir. We can't easily import * from a Hy module, since the Hy core we happen to use in that module comes with it.

What we really want is our own builtins module for Hy. But Python doesn't have an easy way to add that. And dumping our "builtin" stuff into Python's builtins is not nice to the Python side. So we autoimport. #1407 had some ideas on how to deal with that differently.

@vodik
Copy link
Contributor

vodik commented Mar 25, 2018

What we really want is our own builtins module for Hy. But Python doesn't have an easy way to add that.

It does... we just have to drop Python 2 😉 See BuiltinImporter (and get #1518 in...)

@gilch
Copy link
Member

gilch commented Mar 25, 2018

Wait, what? Does this really do what we need? Python 2.7 also has a "BuiltinImporter" class, I checked. But it's not clear to me how to use it or what it's good for from those linked docs.

brandonwillard added a commit to brandonwillard/hy that referenced this issue Aug 27, 2018
brandonwillard added a commit to brandonwillard/hy that referenced this issue Aug 27, 2018
brandonwillard added a commit to brandonwillard/hy that referenced this issue Aug 28, 2018
brandonwillard added a commit to brandonwillard/hy that referenced this issue Aug 28, 2018
brandonwillard added a commit to brandonwillard/hy that referenced this issue Aug 28, 2018
Kodiologist pushed a commit to brandonwillard/hy that referenced this issue Sep 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants