Skip to content

Commit

Permalink
chore: update pre-commit hooks (#300)
Browse files Browse the repository at this point in the history
* chore: update pre-commit hooks

updates:
- [github.com/python-jsonschema/check-jsonschema: 0.27.0 → 0.27.1](python-jsonschema/check-jsonschema@0.27.0...0.27.1)
- [github.com/astral-sh/ruff-pre-commit: v0.1.3 → v0.1.4](astral-sh/ruff-pre-commit@v0.1.3...v0.1.4)

* update ruff

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add ignores

* update test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* cleanup

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
  • Loading branch information
pre-commit-ci[bot] and blink1073 committed Nov 10, 2023
1 parent 7653ba7 commit 0e4a1d0
Show file tree
Hide file tree
Showing 23 changed files with 245 additions and 229 deletions.
8 changes: 6 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
rev: 0.27.1
hooks:
- id: check-github-workflows

Expand Down Expand Up @@ -73,11 +73,15 @@ repos:
]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
rev: v0.1.5
hooks:
- id: ruff
types_or: [python, jupyter]
args: ["--fix", "--show-fixes"]
exclude: "^tests/files/.*.ipynb"
- id: ruff-format
types_or: [python, jupyter]
exclude: "^tests/files/.*.ipynb"

- repo: https://github.com/scientific-python/cookie
rev: "2023.10.27"
Expand Down
10 changes: 5 additions & 5 deletions binder/empty_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import pandas as pd\n",
"import scrapbook as sb"
]
},
Expand All @@ -24,7 +24,7 @@
"metadata": {},
"outputs": [],
"source": [
"data = pd.DataFrame(np.random.randn(20, 2), columns=['a', 'b'])\n",
"data = pd.DataFrame(np.random.randn(20, 2), columns=[\"a\", \"b\"])\n",
"data"
]
},
Expand All @@ -35,7 +35,7 @@
"outputs": [],
"source": [
"# Use scrapbook to store this data in the notebook\n",
"sb.glue('dataframe', data.to_dict())"
"sb.glue(\"dataframe\", data.to_dict())"
]
},
{
Expand All @@ -62,8 +62,8 @@
"source": [
"# Make and display a plot\n",
"fig, ax = plt.subplots()\n",
"ax.scatter(data['a'], data['b'])\n",
"sb.glue('plot', fig, 'display')"
"ax.scatter(data[\"a\"], data[\"b\"])\n",
"sb.glue(\"plot\", fig, \"display\")"
]
}
],
Expand Down
11 changes: 6 additions & 5 deletions binder/run_nbclient.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
"metadata": {},
"outputs": [],
"source": [
"import nbclient\n",
"import nbformat as nbf\n",
"import pandas as pd\n",
"import scrapbook as sb"
"import scrapbook as sb\n",
"\n",
"import nbclient"
]
},
{
Expand Down Expand Up @@ -43,7 +44,7 @@
"outputs": [],
"source": [
"# We use nbformat to represent our empty notebook in-memory\n",
"nb = nbf.read('./empty_notebook.ipynb', nbf.NO_CONVERT)\n",
"nb = nbf.read(\"./empty_notebook.ipynb\", nbf.NO_CONVERT)\n",
"\n",
"# Execute our in-memory notebook, which will now have outputs\n",
"nb = nbclient.execute(nb)"
Expand Down Expand Up @@ -73,7 +74,7 @@
"outputs": [],
"source": [
"# We can access the dataframe that was created and glued into the empty notebook\n",
"pd.DataFrame.from_dict(nb.scraps.get('dataframe').data).head()"
"pd.DataFrame.from_dict(nb.scraps.get(\"dataframe\").data).head()"
]
},
{
Expand All @@ -83,7 +84,7 @@
"outputs": [],
"source": [
"# We can also access the generated plot by \"re-gluing\" the notebook here\n",
"nb.reglue('plot')"
"nb.reglue(\"plot\")"
]
}
],
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ nowarn = "test -W default {args}"
detached = true
dependencies = ["pre-commit"]
[tool.hatch.envs.lint.scripts]
build = "pre-commit run --all-files ruff"
build = [
"pre-commit run --all-files ruff",
"pre-commit run --all-files ruff-format"
]

[tool.hatch.envs.typing]
dependencies = [ "pre-commit"]
Expand Down Expand Up @@ -176,7 +179,6 @@ module = [
ignore_missing_imports = true

[tool.ruff]
target-version = "py38"
line-length = 100

[tool.ruff.lint]
Expand All @@ -197,6 +199,7 @@ ignore = [
# S101 Use of `assert` detected
"tests/*" = ["S101"]
"nbclient/client.py" = ["S101"]
"*.ipynb" = ["B", "E402", "T201", "F821", "A001", "E722", "S110", "RUF001"]

[tool.interrogate]
ignore-init-module=true
Expand Down
1 change: 1 addition & 0 deletions tests/files/Autokill.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"source": [
"import os\n",
"import signal\n",
"\n",
"pid = os.getpid()\n",
"os.kill(pid, signal.SIGTERM)"
]
Expand Down
2 changes: 1 addition & 1 deletion tests/files/Check History in Memory.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"outputs": [],
"source": [
"ip = get_ipython()\n",
"assert ip.history_manager.hist_file == ':memory:'"
"assert ip.history_manager.hist_file == \":memory:\""
]
}
],
Expand Down
13 changes: 6 additions & 7 deletions tests/files/Clear Output.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"metadata": {},
"outputs": [],
"source": [
"from __future__ import print_function\n",
"from IPython.display import clear_output"
]
},
Expand Down Expand Up @@ -53,7 +52,7 @@
}
],
"source": [
"print(\"Hello world\", end='')\n",
"print(\"Hello world\", end=\"\")\n",
"clear_output(wait=True) # no output after this"
]
},
Expand All @@ -71,9 +70,9 @@
}
],
"source": [
"print(\"Hello\", end='')\n",
"print(\"Hello\", end=\"\")\n",
"clear_output(wait=True) # here we have new output after wait=True\n",
"print(\"world\", end='')"
"print(\"world\", end=\"\")"
]
},
{
Expand Down Expand Up @@ -120,7 +119,7 @@
"metadata": {},
"outputs": [],
"source": [
"handle1.update('world')"
"handle1.update(\"world\")"
]
},
{
Expand Down Expand Up @@ -169,7 +168,7 @@
"source": [
"handle4 = display(\"Hello\", display_id=\"id4\")\n",
"clear_output(wait=True)\n",
"print('world', end='')"
"print(\"world\", end=\"\")"
]
},
{
Expand All @@ -178,7 +177,7 @@
"metadata": {},
"outputs": [],
"source": [
"handle4.update('Hello world') # it is cleared, so it should not show up in the above cell"
"handle4.update(\"Hello world\") # it is cleared, so it should not show up in the above cell"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion tests/files/Error.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
],
"source": [
"0/0"
"0 / 0"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion tests/files/Inline Image.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
}
],
"source": [
"Image('python.png')"
"Image(\"python.png\")"
]
}
],
Expand Down
96 changes: 48 additions & 48 deletions tests/files/Interrupt.ipynb
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-31d18a52bf41>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mwhile\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;32mcontinue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"source": [
"while True: continue"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"done\n"
]
}
],
"source": [
"print(\"done\")"
]
}
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 0
}
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-31d18a52bf41>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mwhile\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;32mcontinue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"source": [
"while True: continue"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"done\n"
]
}
],
"source": [
"print(\"done\")"
]
}
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 0
}
5 changes: 3 additions & 2 deletions tests/files/JupyterWidgets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
],
"source": [
"import ipywidgets\n",
"label = ipywidgets.Label('Hello World')\n",
"\n",
"label = ipywidgets.Label(\"Hello World\")\n",
"display(label)"
]
},
Expand All @@ -33,7 +34,7 @@
"outputs": [],
"source": [
"# it should also handle custom msg'es\n",
"label.send({'msg': 'Hello'})"
"label.send({\"msg\": \"Hello\"})"
]
}
],
Expand Down
4 changes: 2 additions & 2 deletions tests/files/Other Comms.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"outputs": [],
"source": [
"comm = create_comm('this-comm-tests-a-missing-handler', data={'id': 'foo'})"
"comm = create_comm(\"this-comm-tests-a-missing-handler\", data={\"id\": \"foo\"})"
]
},
{
Expand All @@ -39,7 +39,7 @@
},
"outputs": [],
"source": [
"comm.send(data={'id': 'bar'})"
"comm.send(data={\"id\": \"bar\"})"
]
}
],
Expand Down
Loading

0 comments on commit 0e4a1d0

Please sign in to comment.