Skip to content

Ingore notebook syntax #142

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

Open
azachar opened this issue Mar 25, 2021 · 1 comment
Open

Ingore notebook syntax #142

azachar opened this issue Mar 25, 2021 · 1 comment

Comments

@azachar
Copy link

azachar commented Mar 25, 2021

Hello,
I am trying to apply changes also on some notebooks from databricks stored as .py files, from time to time, there is %pip install or %magic command, could you please tell me how to ignore it easily, do you support such a case?

Thank you!
Best regards,
Andrej

@thatch
Copy link
Contributor

thatch commented Mar 28, 2021

The best way to do this would be alter the grammar. Some untested hints, I think you'll want to treat these like comments:

  1. https://github.com/jreese/fissix/blob/main/fissix/pgen2/tokenize.py#L69 add a new regex similar to Comment that is for Directive
  2. Add Directive to PsuedoExtras https://github.com/jreese/fissix/blob/main/fissix/pgen2/tokenize.py#L130
  3. Generate some kind of token (calling them COMMENT saves you some effort) https://github.com/jreese/fissix/blob/main/fissix/pgen2/tokenize.py#L537

Note these are re.compile with default args, so if you want to preserve their special behavior only at the beginning of the line, that's more complicated.

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

No branches or pull requests

2 participants