-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test and document how to use isort on a notebook
- Loading branch information
Showing
8 changed files
with
70 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ dependencies: | |
- pylint | ||
- flake8 | ||
- black | ||
- isort | ||
- autopep8 | ||
- sphinx-gallery | ||
- nodejs<13 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from jupytext import reads, writes | ||
from jupytext.cli import pipe_notebook | ||
from jupytext.compare import compare | ||
|
||
from .utils import requires_isort | ||
|
||
|
||
@requires_isort | ||
def test_pipe_into_isort(): | ||
text_org = """# %% | ||
import numpy as np | ||
np.array([1,2,3]) | ||
# %% | ||
import pandas as pd | ||
pd.Series([1,2,3]) | ||
# %% | ||
# This is a comment on the second import | ||
import pandas as pd | ||
pd.Series([4,5,6]) | ||
""" | ||
|
||
text_target = """# %% | ||
import numpy as np | ||
# This is a comment on the second import | ||
import pandas as pd | ||
np.array([1,2,3]) | ||
# %% | ||
pd.Series([1,2,3]) | ||
# %% | ||
pd.Series([4,5,6]) | ||
""" | ||
|
||
nb_org = reads(text_org, fmt="py:percent") | ||
nb_pipe = pipe_notebook( | ||
nb_org, 'isort - --treat-comment-as-code "# %%" --float-to-top' | ||
) | ||
text_actual = writes(nb_pipe, "py:percent") | ||
compare(text_actual, text_target) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters