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

Allow expressions such as (require [hy.contrib [walk]]) #2020

Merged

Conversation

peaceamongworlds
Copy link
Contributor

Fixes #2016.

Also gets rid of error HyRequireError when requiring a module with no macros, since previously this behavior was inconsistent and I don't see why this should be an error. So previously

i => (require os.path)
i => (require [os [path]])
Traceback (most recent call last):
  File "stdin-08ce82c15e0a77ce6e17125ffa2f87a3fbdcd4df", line 1, in <module>
    (require [os [path]])
hy.errors.HyRequireError: The module <module 'os' from '/usr/lib/python3.9/os.py'> has no macros or tags

But now the second will also not throw an error.

@Kodiologist
Copy link
Member

You know, I'd forgotten that we are now only supporting Pythons recent enough to have f-strings, and so we can use f-strings in our own Python code. Neat.

Can you use parentheses instead of backslashes for the long condition?

For tests of requiring a macro that's supposed to exist, use a test macro rather than a real one in our core like hy.contrib.destructure.setv+, so the test doesn't depend on unrelated features existing.

@Kodiologist
Copy link
Member

And don't forget a NEWS item.

@peaceamongworlds
Copy link
Contributor Author

peaceamongworlds commented Mar 28, 2021

Can you use parentheses instead of backslashes for the long condition?

For tests of requiring a macro that's supposed to exist, use a test macro rather than a real one in our core like hy.contrib.destructure.setv+, so the test doesn't depend on unrelated features existing.

And don't forget a NEWS item.

Done

@Kodiologist Kodiologist merged commit e828bf7 into hylang:master Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot require module from a package
3 participants