Skip to content

Commit 19a3e23

Browse files
committed
Apply ruff formatting to notebooks
1 parent a79bd77 commit 19a3e23

File tree

6 files changed

+32
-12
lines changed

6 files changed

+32
-12
lines changed

examples/gds-nvl-example.ipynb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"metadata": {},
9090
"outputs": [],
9191
"source": [
92-
"G_sample.node_properties()\n"
92+
"G_sample.node_properties()"
9393
]
9494
},
9595
{
@@ -108,7 +108,12 @@
108108
"from neo4j_viz.gds import from_gds\n",
109109
"\n",
110110
"# TODO inform about automatic size scaling\n",
111-
"VG = from_gds(gds, G_sample, size_property=\"pagerank\", additional_node_properties=[\"componentId\", \"subject\"])"
111+
"VG = from_gds(\n",
112+
" gds,\n",
113+
" G_sample,\n",
114+
" size_property=\"pagerank\",\n",
115+
" additional_node_properties=[\"componentId\", \"subject\"],\n",
116+
")"
112117
]
113118
},
114119
{
@@ -143,7 +148,7 @@
143148
"metadata": {},
144149
"outputs": [],
145150
"source": [
146-
"VG.render()\n"
151+
"VG.render()"
147152
]
148153
},
149154
{

examples/neo4j-nvl-example.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@
5050
" driver.verify_connectivity()\n",
5151
"\n",
5252
" result = driver.execute_query(\n",
53-
" \"MATCH (n)-[r]-(m) RETURN n,r,m LIMIT 10\", database_=\"neo4j\", result_transformer_=Result.graph\n",
53+
" \"MATCH (n)-[r]-(m) RETURN n,r,m LIMIT 10\",\n",
54+
" database_=\"neo4j\",\n",
55+
" result_transformer_=Result.graph,\n",
5456
" )\n",
5557
"\n",
5658
" result\n",

python-wrapper/pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,9 @@ select = [
129129

130130
[tool.mypy]
131131
strict = true
132-
exclude = '(^build|^\.?venv)'
132+
exclude = [
133+
'(^build|^\.?venv)',
134+
'build',
135+
]
133136
plugins = ['pydantic.mypy']
137+
untyped_calls_exclude=["nbconvert"]

scripts/checkstyle.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -o pipefail
77

88
python -m ruff check .
99
python -m ruff format --check .
10-
mypy .
10+
mypy --config-file python-wrapper/pyproject.toml .
1111

1212

1313
if [ "${SKIP_NOTEBOOKS:-false}" == "true" ]; then

scripts/clean_notebooks.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ class CustomClearOutputPreprocessor(Preprocessor):
2525
Option to keep cell output for cells with a given metadata tag
2626
"""
2727

28-
def preprocess_cell(self, cell: Any, resources: Any, cell_index: Any) -> tuple[Any, Any]:
28+
def preprocess_cell(
29+
self, cell: Any, resources: Any, cell_index: Any
30+
) -> tuple[Any, Any]:
2931
"""
3032
Apply a transformation on each cell. See base.py for details.
3133
"""
32-
if cell.cell_type == "code" and PRESERVE_CELL_OUTPUT_KEY not in cell["metadata"].get(METADATA_TAG_KEY, []):
34+
if cell.cell_type == "code" and PRESERVE_CELL_OUTPUT_KEY not in cell[
35+
"metadata"
36+
].get(METADATA_TAG_KEY, []):
3337
cell.outputs = []
3438
cell.execution_count = None
3539
return cell, resources
@@ -41,7 +45,9 @@ def main(input_path: Path, output_mode: OutputMode) -> None:
4145

4246
exporter = nbconvert.NotebookExporter()
4347

44-
metadata_cleaner = nbconvert.preprocessors.ClearMetadataPreprocessor(preserve_cell_metadata_mask=METADATA_TAG_KEY)
48+
metadata_cleaner = nbconvert.preprocessors.ClearMetadataPreprocessor(
49+
preserve_cell_metadata_mask=METADATA_TAG_KEY
50+
)
4551
output_cleaner = CustomClearOutputPreprocessor() # type: ignore
4652

4753
exporter.register_preprocessor(metadata_cleaner, enabled=True)
@@ -50,7 +56,9 @@ def main(input_path: Path, output_mode: OutputMode) -> None:
5056
if input_path.is_file():
5157
notebooks = [input_path]
5258
else:
53-
notebooks = [f for f in input_path.iterdir() if f.is_file() and f.suffix == ".ipynb"]
59+
notebooks = [
60+
f for f in input_path.iterdir() if f.is_file() and f.suffix == ".ipynb"
61+
]
5462

5563
logger.info(f"Formatting {len(notebooks)} notebooks.")
5664

@@ -69,7 +77,9 @@ def main(input_path: Path, output_mode: OutputMode) -> None:
6977
if __name__ == "__main__":
7078
parser = argparse.ArgumentParser()
7179
parser.add_argument("-o", "--output", choices=[e.value for e in OutputMode])
72-
parser.add_argument("-i", "--input", default="examples", help="path to the notebook file or folder")
80+
parser.add_argument(
81+
"-i", "--input", default="examples", help="path to the notebook file or folder"
82+
)
7383

7484
args = parser.parse_args()
7585

scripts/makestyle.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ if [ "${SKIP_NOTEBOOKS:-false}" == "true" ]; then
1414
exit 0
1515
fi
1616

17-
GIT_ROOT=$(git rev-parse --show-toplevel)
1817
python "${GIT_ROOT}/scripts/clean_notebooks.py" -i "${GIT_ROOT}/examples/" -o inplace

0 commit comments

Comments
 (0)