From 00abbf13d25274df5a95b13030a7fb3428021b38 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:25:43 +0100 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#27) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.6 → v0.7.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.6...v0.7.3) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 +- example/compare_to_jsonpickle.ipynb | 72 +++++++++++++++-------------- example/datetime_converter.ipynb | 70 ++++++++++++++-------------- example/example.ipynb | 4 +- 4 files changed, 77 insertions(+), 73 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 494eaa4..21f916a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,11 @@ exclude: '.git|.tox' -default_stages: [commit] +default_stages: [pre-commit] fail_fast: true repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.4.6 + rev: v0.7.3 hooks: # Run the linter. - id: ruff diff --git a/example/compare_to_jsonpickle.ipynb b/example/compare_to_jsonpickle.ipynb index dd16743..25e3899 100644 --- a/example/compare_to_jsonpickle.ipynb +++ b/example/compare_to_jsonpickle.ipynb @@ -8,16 +8,21 @@ }, "outputs": [], "source": [ - "import jsonpickle\n", - "import znjson\n", "import json\n", "import sys\n", - "import numpy as np" + "\n", + "import jsonpickle\n", + "import numpy as np\n", + "\n", + "import znjson" ] }, { "cell_type": "code", "execution_count": 2, + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "data1 = {\"a\": np.arange(1000), \"b\": [x for x in range(100)]}\n", @@ -28,23 +33,23 @@ " \"list\": [1, 2, 3],\n", " \"nested\": {\"numpy\": np.array([1, 2, 3]), \"list\": [1, 2, 3]},\n", "}" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "markdown", - "source": [ - "The following results are not affected by running one timeit before the other." - ], "metadata": { "collapsed": false - } + }, + "source": [ + "The following results are not affected by running one timeit before the other." + ] }, { "cell_type": "code", "execution_count": 3, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -62,14 +67,14 @@ "%timeit json.dumps(data2, cls=znjson.ZnEncoder)\n", "%timeit json.dumps(data3, cls=znjson.ZnEncoder)\n", "%timeit json.dumps(data4, cls=znjson.ZnEncoder)" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": 4, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -87,14 +92,14 @@ "%timeit jsonpickle.dumps(data2)\n", "%timeit jsonpickle.dumps(data3)\n", "%timeit jsonpickle.dumps(data4)" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": 5, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -135,14 +140,14 @@ ], "source": [ "print(json.dumps(data4, cls=znjson.ZnEncoder, indent=2))" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": 6, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -268,14 +273,14 @@ ], "source": [ "print(jsonpickle.dumps(data4, indent=2))" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": 7, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -293,14 +298,14 @@ "print(sys.getsizeof(jsonpickle.dumps(data2)))\n", "print(sys.getsizeof(jsonpickle.dumps(data3)))\n", "print(sys.getsizeof(jsonpickle.dumps(data4)))" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": 8, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -318,10 +323,7 @@ "print(sys.getsizeof(json.dumps(data2, cls=znjson.ZnEncoder)))\n", "print(sys.getsizeof(json.dumps(data3, cls=znjson.ZnEncoder)))\n", "print(sys.getsizeof(json.dumps(data4, cls=znjson.ZnEncoder)))" - ], - "metadata": { - "collapsed": false - } + ] } ], "metadata": { diff --git a/example/datetime_converter.ipynb b/example/datetime_converter.ipynb index 6a04e03..cdb5989 100644 --- a/example/datetime_converter.ipynb +++ b/example/datetime_converter.ipynb @@ -2,33 +2,36 @@ "cells": [ { "cell_type": "markdown", + "metadata": { + "collapsed": false + }, "source": [ "# Write a custom Converter\n", "\n", "In this Example we will write a custom converter for `datetime` objects." - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": 1, + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "import json\n", - "\n", - "from znjson import ConverterBase\n", "from datetime import datetime\n", - "import znjson" - ], - "metadata": { - "collapsed": false - } + "\n", + "import znjson\n", + "from znjson import ConverterBase" + ] }, { "cell_type": "code", "execution_count": 2, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -41,14 +44,14 @@ "source": [ "dt = datetime.now()\n", "print(dt)" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": 3, + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "class DatetimeConverter(ConverterBase):\n", @@ -77,34 +80,34 @@ " def decode(self, value: str) -> datetime:\n", " \"\"\"Create datetime object from str / isoformat\"\"\"\n", " return datetime.fromisoformat(value)" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "markdown", - "source": [ - "To use the new converter we have to add it to `znjson.config.ACTIVE_CONVERTERS` via `znjson.register()`" - ], "metadata": { "collapsed": false - } + }, + "source": [ + "To use the new converter we have to add it to `znjson.config.ACTIVE_CONVERTERS` via `znjson.register()`" + ] }, { "cell_type": "code", "execution_count": 4, + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "znjson.config.register(DatetimeConverter)" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": 5, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -120,14 +123,14 @@ "source": [ "json_string = json.dumps(dt, cls=znjson.ZnEncoder, indent=4)\n", "print(json_string)" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": 6, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -140,10 +143,7 @@ ], "source": [ "json.loads(json_string, cls=znjson.ZnDecoder)" - ], - "metadata": { - "collapsed": false - } + ] } ], "metadata": { diff --git a/example/example.ipynb b/example/example.ipynb index 4147bfc..afc8b09 100644 --- a/example/example.ipynb +++ b/example/example.ipynb @@ -8,8 +8,10 @@ }, "outputs": [], "source": [ - "import numpy as np\n", "import json\n", + "\n", + "import numpy as np\n", + "\n", "import znjson" ] },