-
Notifications
You must be signed in to change notification settings - Fork 333
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
Python: Running function definitions with decorators ignores the decorator #77
Comments
Hydrogen relies on Atom's code-folding and indentation right now to figure out what a block is. This is so that the code for finding blocks works across languages. This is definitely annoying behavior, but I don't know of a way to address this without writing a parser for each language that Hydrogen supports. Which maybe we should do at some point, but isn't going to happen for a while. Any ideas about how to solve this without breaking the problem out into all the languages? |
sorry, I don't have any ideas. is it a bug in atom? |
Nope, it's just hard to take a bunch of text and figure out what a logical block is cross-language. Atom is correct not to fold to decorators, as that would fold the actual function definition under. |
any suggestion to get around this problem? |
@alvis A way around this is to use comments to define the execution cells in your code and use the command |
@n-riesco: Thanks for pointing out. It's smart to use the |
Please have a look if the most recent commit in this PR nikitakit/hydrogen-python#10 work for you. I've just added exactly this functionality. |
This is as solved as possible through the use of cells and with hydrogen-python so I'm going to close. |
Say we have this code:
Trying to evaluate the
myfunc
function will be wrong in two different ways: if I have my cursor on the@deco
line, it causes a syntax error because it seems to just be trying to evaluate@deco
by itself, without the function definition after it. If I have my cursor on thedef myfunc
line, or on the blank line immediately aftermyfunc
, it defines the function without the decorator.I can work around this by manually selecting the whole function definition including the decorator line and then hitting cmd-alt-enter.
The text was updated successfully, but these errors were encountered: