From db2dec6834a69f155115e828a14ed659a10e4bf4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Apr 2024 01:43:39 +0000 Subject: [PATCH 1/2] Bump ruff from 0.1.5 to 0.3.7 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.1.5 to 0.3.7. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.1.5...v0.3.7) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- poetry.lock | 38 +++++++++++++++++++------------------- pyproject.toml | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/poetry.lock b/poetry.lock index be5be2d..9eac852 100644 --- a/poetry.lock +++ b/poetry.lock @@ -729,28 +729,28 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "ruff" -version = "0.1.5" +version = "0.3.7" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.1.5-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:32d47fc69261c21a4c48916f16ca272bf2f273eb635d91c65d5cd548bf1f3d96"}, - {file = "ruff-0.1.5-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:171276c1df6c07fa0597fb946139ced1c2978f4f0b8254f201281729981f3c17"}, - {file = "ruff-0.1.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:17ef33cd0bb7316ca65649fc748acc1406dfa4da96a3d0cde6d52f2e866c7b39"}, - {file = "ruff-0.1.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b2c205827b3f8c13b4a432e9585750b93fd907986fe1aec62b2a02cf4401eee6"}, - {file = "ruff-0.1.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bb408e3a2ad8f6881d0f2e7ad70cddb3ed9f200eb3517a91a245bbe27101d379"}, - {file = "ruff-0.1.5-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:f20dc5e5905ddb407060ca27267c7174f532375c08076d1a953cf7bb016f5a24"}, - {file = "ruff-0.1.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:aafb9d2b671ed934998e881e2c0f5845a4295e84e719359c71c39a5363cccc91"}, - {file = "ruff-0.1.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a4894dddb476597a0ba4473d72a23151b8b3b0b5f958f2cf4d3f1c572cdb7af7"}, - {file = "ruff-0.1.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a00a7ec893f665ed60008c70fe9eeb58d210e6b4d83ec6654a9904871f982a2a"}, - {file = "ruff-0.1.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:a8c11206b47f283cbda399a654fd0178d7a389e631f19f51da15cbe631480c5b"}, - {file = "ruff-0.1.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:fa29e67b3284b9a79b1a85ee66e293a94ac6b7bb068b307a8a373c3d343aa8ec"}, - {file = "ruff-0.1.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:9b97fd6da44d6cceb188147b68db69a5741fbc736465b5cea3928fdac0bc1aeb"}, - {file = "ruff-0.1.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:721f4b9d3b4161df8dc9f09aa8562e39d14e55a4dbaa451a8e55bdc9590e20f4"}, - {file = "ruff-0.1.5-py3-none-win32.whl", hash = "sha256:f80c73bba6bc69e4fdc73b3991db0b546ce641bdcd5b07210b8ad6f64c79f1ab"}, - {file = "ruff-0.1.5-py3-none-win_amd64.whl", hash = "sha256:c21fe20ee7d76206d290a76271c1af7a5096bc4c73ab9383ed2ad35f852a0087"}, - {file = "ruff-0.1.5-py3-none-win_arm64.whl", hash = "sha256:82bfcb9927e88c1ed50f49ac6c9728dab3ea451212693fe40d08d314663e412f"}, - {file = "ruff-0.1.5.tar.gz", hash = "sha256:5cbec0ef2ae1748fb194f420fb03fb2c25c3258c86129af7172ff8f198f125ab"}, + {file = "ruff-0.3.7-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:0e8377cccb2f07abd25e84fc5b2cbe48eeb0fea9f1719cad7caedb061d70e5ce"}, + {file = "ruff-0.3.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:15a4d1cc1e64e556fa0d67bfd388fed416b7f3b26d5d1c3e7d192c897e39ba4b"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d28bdf3d7dc71dd46929fafeec98ba89b7c3550c3f0978e36389b5631b793663"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:379b67d4f49774ba679593b232dcd90d9e10f04d96e3c8ce4a28037ae473f7bb"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c060aea8ad5ef21cdfbbe05475ab5104ce7827b639a78dd55383a6e9895b7c51"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:ebf8f615dde968272d70502c083ebf963b6781aacd3079081e03b32adfe4d58a"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d48098bd8f5c38897b03604f5428901b65e3c97d40b3952e38637b5404b739a2"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:da8a4fda219bf9024692b1bc68c9cff4b80507879ada8769dc7e985755d662ea"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c44e0149f1d8b48c4d5c33d88c677a4aa22fd09b1683d6a7ff55b816b5d074f"}, + {file = "ruff-0.3.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:3050ec0af72b709a62ecc2aca941b9cd479a7bf2b36cc4562f0033d688e44fa1"}, + {file = "ruff-0.3.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:a29cc38e4c1ab00da18a3f6777f8b50099d73326981bb7d182e54a9a21bb4ff7"}, + {file = "ruff-0.3.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:5b15cc59c19edca917f51b1956637db47e200b0fc5e6e1878233d3a938384b0b"}, + {file = "ruff-0.3.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:e491045781b1e38b72c91247cf4634f040f8d0cb3e6d3d64d38dcf43616650b4"}, + {file = "ruff-0.3.7-py3-none-win32.whl", hash = "sha256:bc931de87593d64fad3a22e201e55ad76271f1d5bfc44e1a1887edd0903c7d9f"}, + {file = "ruff-0.3.7-py3-none-win_amd64.whl", hash = "sha256:5ef0e501e1e39f35e03c2acb1d1238c595b8bb36cf7a170e7c1df1b73da00e74"}, + {file = "ruff-0.3.7-py3-none-win_arm64.whl", hash = "sha256:789e144f6dc7019d1f92a812891c645274ed08af6037d11fc65fcbc183b7d59f"}, + {file = "ruff-0.3.7.tar.gz", hash = "sha256:d5c1aebee5162c2226784800ae031f660c350e7a3402c4d1f8ea4e97e232e3ba"}, ] [[package]] @@ -794,4 +794,4 @@ zstd = ["zstandard (>=0.18.0)"] [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4" -content-hash = "3ae7f24ba87409214616e93519aa83ca1613912b7698d8769cef3538117fa20f" +content-hash = "5d4ffbf33a17f07f4c24181ac6c847896d416bb987157bc9c10695cf88d4a88b" diff --git a/pyproject.toml b/pyproject.toml index 30a9113..f0a53b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ pandoc = "^2.3" pydash = "^7.0.3" pytest = "^7.4.3" pytest-cov = "^4.0.0" -ruff = "^0.1.5" +ruff = ">=0.1.5,<0.4.0" [tool.black] max-line-length = 88 From 0f3cbe5b547f6bf3901c3d95a5cdd7d0d11e141b Mon Sep 17 00:00:00 2001 From: Samuel Cormier-Iijima Date: Mon, 15 Apr 2024 22:03:16 -0400 Subject: [PATCH 2/2] Additional package updates --- poetry.lock | 204 ++++++------------ prosemirror/__init__.py | 4 +- prosemirror/model/__init__.py | 18 +- prosemirror/model/content.py | 18 +- prosemirror/model/from_dom.py | 31 ++- prosemirror/model/resolvedpos.py | 10 +- prosemirror/model/to_dom.py | 38 ++-- prosemirror/schema/list/schema_list.py | 20 +- prosemirror/test_builder/__init__.py | 22 +- prosemirror/transform/__init__.py | 34 +-- prosemirror/transform/map.py | 18 +- prosemirror/transform/mark_step.py | 2 +- prosemirror/transform/replace.py | 6 +- prosemirror/transform/replace_step.py | 18 +- prosemirror/transform/step.py | 18 +- prosemirror/transform/transform.py | 14 +- pyproject.toml | 33 ++- tests/prosemirror_model/tests/test_mark.py | 28 ++- tests/prosemirror_model/tests/test_node.py | 57 +++-- tests/prosemirror_model/tests/test_resolve.py | 32 ++- .../tests/test_structure.py | 70 +++--- .../prosemirror_transform/tests/test_trans.py | 152 ++++++------- 22 files changed, 360 insertions(+), 487 deletions(-) diff --git a/poetry.lock b/poetry.lock index 9eac852..a584b81 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2,13 +2,13 @@ [[package]] name = "certifi" -version = "2023.7.22" +version = "2024.2.2" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2023.7.22-py3-none-any.whl", hash = "sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"}, - {file = "certifi-2023.7.22.tar.gz", hash = "sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082"}, + {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, + {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, ] [[package]] @@ -216,34 +216,18 @@ files = [ [[package]] name = "exceptiongroup" -version = "1.1.3" +version = "1.2.0" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ - {file = "exceptiongroup-1.1.3-py3-none-any.whl", hash = "sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3"}, - {file = "exceptiongroup-1.1.3.tar.gz", hash = "sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9"}, + {file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"}, + {file = "exceptiongroup-1.2.0.tar.gz", hash = "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"}, ] [package.extras] test = ["pytest (>=6)"] -[[package]] -name = "flake8" -version = "7.0.0" -description = "the modular source code checker: pep8 pyflakes and co" -optional = false -python-versions = ">=3.8.1" -files = [ - {file = "flake8-7.0.0-py2.py3-none-any.whl", hash = "sha256:a6dfbb75e03252917f2473ea9653f7cd799c3064e54d4c8140044c5c065f53c3"}, - {file = "flake8-7.0.0.tar.gz", hash = "sha256:33f96621059e65eec474169085dc92bf26e7b2d47366b70be2f67ab80dc25132"}, -] - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.11.0,<2.12.0" -pyflakes = ">=3.2.0,<3.3.0" - [[package]] name = "idna" version = "3.7" @@ -266,20 +250,6 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] -[[package]] -name = "isort" -version = "5.13.2" -description = "A Python utility / library to sort Python imports." -optional = false -python-versions = ">=3.8.0" -files = [ - {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, - {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, -] - -[package.extras] -colors = ["colorama (>=0.4.6)"] - [[package]] name = "lxml" version = "5.2.1" @@ -453,63 +423,52 @@ source = ["Cython (>=3.0.10)"] [[package]] name = "lxml-stubs" -version = "0.4.0" +version = "0.5.1" description = "Type annotations for the lxml package" optional = false python-versions = "*" files = [ - {file = "lxml-stubs-0.4.0.tar.gz", hash = "sha256:184877b42127256abc2b932ba8bd0ab5ea80bd0b0fee618d16daa40e0b71abee"}, - {file = "lxml_stubs-0.4.0-py3-none-any.whl", hash = "sha256:3b381e9e82397c64ea3cc4d6f79d1255d015f7b114806d4826218805c10ec003"}, + {file = "lxml-stubs-0.5.1.tar.gz", hash = "sha256:e0ec2aa1ce92d91278b719091ce4515c12adc1d564359dfaf81efa7d4feab79d"}, + {file = "lxml_stubs-0.5.1-py3-none-any.whl", hash = "sha256:1f689e5dbc4b9247cb09ae820c7d34daeb1fdbd1db06123814b856dae7787272"}, ] [package.extras] -test = ["coverage[toml] (==5.2)", "pytest (>=6.0.0)", "pytest-mypy-plugins (==1.9.3)"] - -[[package]] -name = "mccabe" -version = "0.7.0" -description = "McCabe checker, plugin for flake8" -optional = false -python-versions = ">=3.6" -files = [ - {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, - {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, -] +test = ["coverage[toml] (>=7.2.5)", "mypy (>=1.2.0)", "pytest (>=7.3.0)", "pytest-mypy-plugins (>=1.10.1)"] [[package]] name = "mypy" -version = "1.8.0" +version = "1.9.0" description = "Optional static typing for Python" optional = false python-versions = ">=3.8" files = [ - {file = "mypy-1.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:485a8942f671120f76afffff70f259e1cd0f0cfe08f81c05d8816d958d4577d3"}, - {file = "mypy-1.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:df9824ac11deaf007443e7ed2a4a26bebff98d2bc43c6da21b2b64185da011c4"}, - {file = "mypy-1.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2afecd6354bbfb6e0160f4e4ad9ba6e4e003b767dd80d85516e71f2e955ab50d"}, - {file = "mypy-1.8.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8963b83d53ee733a6e4196954502b33567ad07dfd74851f32be18eb932fb1cb9"}, - {file = "mypy-1.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:e46f44b54ebddbeedbd3d5b289a893219065ef805d95094d16a0af6630f5d410"}, - {file = "mypy-1.8.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:855fe27b80375e5c5878492f0729540db47b186509c98dae341254c8f45f42ae"}, - {file = "mypy-1.8.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4c886c6cce2d070bd7df4ec4a05a13ee20c0aa60cb587e8d1265b6c03cf91da3"}, - {file = "mypy-1.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d19c413b3c07cbecf1f991e2221746b0d2a9410b59cb3f4fb9557f0365a1a817"}, - {file = "mypy-1.8.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9261ed810972061388918c83c3f5cd46079d875026ba97380f3e3978a72f503d"}, - {file = "mypy-1.8.0-cp311-cp311-win_amd64.whl", hash = "sha256:51720c776d148bad2372ca21ca29256ed483aa9a4cdefefcef49006dff2a6835"}, - {file = "mypy-1.8.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:52825b01f5c4c1c4eb0db253ec09c7aa17e1a7304d247c48b6f3599ef40db8bd"}, - {file = "mypy-1.8.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f5ac9a4eeb1ec0f1ccdc6f326bcdb464de5f80eb07fb38b5ddd7b0de6bc61e55"}, - {file = "mypy-1.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afe3fe972c645b4632c563d3f3eff1cdca2fa058f730df2b93a35e3b0c538218"}, - {file = "mypy-1.8.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:42c6680d256ab35637ef88891c6bd02514ccb7e1122133ac96055ff458f93fc3"}, - {file = "mypy-1.8.0-cp312-cp312-win_amd64.whl", hash = "sha256:720a5ca70e136b675af3af63db533c1c8c9181314d207568bbe79051f122669e"}, - {file = "mypy-1.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:028cf9f2cae89e202d7b6593cd98db6759379f17a319b5faf4f9978d7084cdc6"}, - {file = "mypy-1.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4e6d97288757e1ddba10dd9549ac27982e3e74a49d8d0179fc14d4365c7add66"}, - {file = "mypy-1.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f1478736fcebb90f97e40aff11a5f253af890c845ee0c850fe80aa060a267c6"}, - {file = "mypy-1.8.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:42419861b43e6962a649068a61f4a4839205a3ef525b858377a960b9e2de6e0d"}, - {file = "mypy-1.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:2b5b6c721bd4aabaadead3a5e6fa85c11c6c795e0c81a7215776ef8afc66de02"}, - {file = "mypy-1.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5c1538c38584029352878a0466f03a8ee7547d7bd9f641f57a0f3017a7c905b8"}, - {file = "mypy-1.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4ef4be7baf08a203170f29e89d79064463b7fc7a0908b9d0d5114e8009c3a259"}, - {file = "mypy-1.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7178def594014aa6c35a8ff411cf37d682f428b3b5617ca79029d8ae72f5402b"}, - {file = "mypy-1.8.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ab3c84fa13c04aeeeabb2a7f67a25ef5d77ac9d6486ff33ded762ef353aa5592"}, - {file = "mypy-1.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:99b00bc72855812a60d253420d8a2eae839b0afa4938f09f4d2aa9bb4654263a"}, - {file = "mypy-1.8.0-py3-none-any.whl", hash = "sha256:538fd81bb5e430cc1381a443971c0475582ff9f434c16cd46d2c66763ce85d9d"}, - {file = "mypy-1.8.0.tar.gz", hash = "sha256:6ff8b244d7085a0b425b56d327b480c3b29cafbd2eff27316a004f9a7391ae07"}, + {file = "mypy-1.9.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f8a67616990062232ee4c3952f41c779afac41405806042a8126fe96e098419f"}, + {file = "mypy-1.9.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d357423fa57a489e8c47b7c85dfb96698caba13d66e086b412298a1a0ea3b0ed"}, + {file = "mypy-1.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49c87c15aed320de9b438ae7b00c1ac91cd393c1b854c2ce538e2a72d55df150"}, + {file = "mypy-1.9.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:48533cdd345c3c2e5ef48ba3b0d3880b257b423e7995dada04248725c6f77374"}, + {file = "mypy-1.9.0-cp310-cp310-win_amd64.whl", hash = "sha256:4d3dbd346cfec7cb98e6cbb6e0f3c23618af826316188d587d1c1bc34f0ede03"}, + {file = "mypy-1.9.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:653265f9a2784db65bfca694d1edd23093ce49740b2244cde583aeb134c008f3"}, + {file = "mypy-1.9.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3a3c007ff3ee90f69cf0a15cbcdf0995749569b86b6d2f327af01fd1b8aee9dc"}, + {file = "mypy-1.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2418488264eb41f69cc64a69a745fad4a8f86649af4b1041a4c64ee61fc61129"}, + {file = "mypy-1.9.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:68edad3dc7d70f2f17ae4c6c1b9471a56138ca22722487eebacfd1eb5321d612"}, + {file = "mypy-1.9.0-cp311-cp311-win_amd64.whl", hash = "sha256:85ca5fcc24f0b4aeedc1d02f93707bccc04733f21d41c88334c5482219b1ccb3"}, + {file = "mypy-1.9.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aceb1db093b04db5cd390821464504111b8ec3e351eb85afd1433490163d60cd"}, + {file = "mypy-1.9.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0235391f1c6f6ce487b23b9dbd1327b4ec33bb93934aa986efe8a9563d9349e6"}, + {file = "mypy-1.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d4d5ddc13421ba3e2e082a6c2d74c2ddb3979c39b582dacd53dd5d9431237185"}, + {file = "mypy-1.9.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:190da1ee69b427d7efa8aa0d5e5ccd67a4fb04038c380237a0d96829cb157913"}, + {file = "mypy-1.9.0-cp312-cp312-win_amd64.whl", hash = "sha256:fe28657de3bfec596bbeef01cb219833ad9d38dd5393fc649f4b366840baefe6"}, + {file = "mypy-1.9.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e54396d70be04b34f31d2edf3362c1edd023246c82f1730bbf8768c28db5361b"}, + {file = "mypy-1.9.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:5e6061f44f2313b94f920e91b204ec600982961e07a17e0f6cd83371cb23f5c2"}, + {file = "mypy-1.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:81a10926e5473c5fc3da8abb04119a1f5811a236dc3a38d92015cb1e6ba4cb9e"}, + {file = "mypy-1.9.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b685154e22e4e9199fc95f298661deea28aaede5ae16ccc8cbb1045e716b3e04"}, + {file = "mypy-1.9.0-cp38-cp38-win_amd64.whl", hash = "sha256:5d741d3fc7c4da608764073089e5f58ef6352bedc223ff58f2f038c2c4698a89"}, + {file = "mypy-1.9.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:587ce887f75dd9700252a3abbc9c97bbe165a4a630597845c61279cf32dfbf02"}, + {file = "mypy-1.9.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f88566144752999351725ac623471661c9d1cd8caa0134ff98cceeea181789f4"}, + {file = "mypy-1.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61758fabd58ce4b0720ae1e2fea5cfd4431591d6d590b197775329264f86311d"}, + {file = "mypy-1.9.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:e49499be624dead83927e70c756970a0bc8240e9f769389cdf5714b0784ca6bf"}, + {file = "mypy-1.9.0-cp39-cp39-win_amd64.whl", hash = "sha256:571741dc4194b4f82d344b15e8837e8c5fcc462d66d076748142327626a1b6e9"}, + {file = "mypy-1.9.0-py3-none-any.whl", hash = "sha256:a260627a570559181a9ea5de61ac6297aa5af202f06fd7ab093ce74e7181e43e"}, + {file = "mypy-1.9.0.tar.gz", hash = "sha256:3cc5da0127e6a478cddd906068496a97a7618a21ce9b54bde5bf7e539c7af974"}, ] [package.dependencies] @@ -536,13 +495,13 @@ files = [ [[package]] name = "packaging" -version = "23.2" +version = "24.0" description = "Core utilities for Python packages" optional = false python-versions = ">=3.7" files = [ - {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, - {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, + {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, + {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, ] [[package]] @@ -561,13 +520,13 @@ ply = "*" [[package]] name = "pluggy" -version = "1.3.0" +version = "1.4.0" description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.8" files = [ - {file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"}, - {file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"}, + {file = "pluggy-1.4.0-py3-none-any.whl", hash = "sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981"}, + {file = "pluggy-1.4.0.tar.gz", hash = "sha256:8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be"}, ] [package.extras] @@ -604,54 +563,32 @@ files = [ {file = "ply-3.11.tar.gz", hash = "sha256:00c7c1aaa88358b9c765b6d3000c6eec0ba42abca5351b095321aef446081da3"}, ] -[[package]] -name = "pycodestyle" -version = "2.11.1" -description = "Python style guide checker" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"}, - {file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"}, -] - [[package]] name = "pydash" -version = "7.0.6" +version = "8.0.0" description = "The kitchen sink of Python utility libraries for doing \"stuff\" in a functional way. Based on the Lo-Dash Javascript library." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pydash-7.0.6-py3-none-any.whl", hash = "sha256:10e506935953fde4b0d6fe21a88e17783cd1479256ae96f285b5f89063b4efd6"}, - {file = "pydash-7.0.6.tar.gz", hash = "sha256:7d9df7e9f36f2bbb08316b609480e7c6468185473a21bdd8e65dda7915565a26"}, + {file = "pydash-8.0.0-py3-none-any.whl", hash = "sha256:be2c35df332473a5a939d485422c71a03b19b1a98d6559efb832eadb4a2cfc36"}, + {file = "pydash-8.0.0.tar.gz", hash = "sha256:5a90d98b5f370bb9620f786221579df8f83d54f1f58de6a66f52b1bdba7175d1"}, ] [package.dependencies] -typing-extensions = ">=3.10,<4.6.0 || >4.6.0" +typing-extensions = ">3.10,<4.6.0 || >4.6.0" [package.extras] -dev = ["Sphinx", "black", "build", "coverage", "docformatter", "flake8", "flake8-black", "flake8-bugbear", "flake8-isort", "furo", "importlib-metadata (<5)", "invoke", "isort", "mypy", "pylint", "pytest", "pytest-cov", "pytest-mypy-testing", "sphinx-autodoc-typehints", "tox", "twine", "wheel"] - -[[package]] -name = "pyflakes" -version = "3.2.0" -description = "passive checker of Python programs" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, - {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, -] +dev = ["build", "coverage", "furo", "invoke", "mypy", "pytest", "pytest-cov", "pytest-mypy-testing", "ruff", "sphinx", "sphinx-autodoc-typehints", "tox", "twine", "wheel"] [[package]] name = "pytest" -version = "7.4.4" +version = "8.1.1" description = "pytest: simple powerful testing with Python" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, - {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, + {file = "pytest-8.1.1-py3-none-any.whl", hash = "sha256:2a8386cfc11fa9d2c50ee7b2a57e7d898ef90470a7a34c4b949ff59662bb78b7"}, + {file = "pytest-8.1.1.tar.gz", hash = "sha256:ac978141a75948948817d360297b7aae0fcb9d6ff6bc9ec6d514b85d5a65c044"}, ] [package.dependencies] @@ -659,21 +596,21 @@ colorama = {version = "*", markers = "sys_platform == \"win32\""} exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} iniconfig = "*" packaging = "*" -pluggy = ">=0.12,<2.0" -tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} +pluggy = ">=1.4,<2.0" +tomli = {version = ">=1", markers = "python_version < \"3.11\""} [package.extras] -testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +testing = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "pytest-cov" -version = "4.1.0" +version = "5.0.0" description = "Pytest plugin for measuring coverage." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pytest-cov-4.1.0.tar.gz", hash = "sha256:3904b13dfbfec47f003b8e77fd5b589cd11904a21ddf1ab38a64f204d6a10ef6"}, - {file = "pytest_cov-4.1.0-py3-none-any.whl", hash = "sha256:6ba70b9e97e69fcc3fb45bfeab2d0a138fb65c4d0d6a41ef33983ad114be8c3a"}, + {file = "pytest-cov-5.0.0.tar.gz", hash = "sha256:5837b58e9f6ebd335b0f8060eecce69b662415b16dc503883a02f45dfeb14857"}, + {file = "pytest_cov-5.0.0-py3-none-any.whl", hash = "sha256:4f0764a1219df53214206bf1feea4633c3b558a2925c8b59f144f682861ce652"}, ] [package.dependencies] @@ -681,7 +618,7 @@ coverage = {version = ">=5.2.1", extras = ["toml"]} pytest = ">=4.6" [package.extras] -testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] +testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] [[package]] name = "pywin32" @@ -766,32 +703,33 @@ files = [ [[package]] name = "typing-extensions" -version = "4.9.0" +version = "4.11.0" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, - {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, + {file = "typing_extensions-4.11.0-py3-none-any.whl", hash = "sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a"}, + {file = "typing_extensions-4.11.0.tar.gz", hash = "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0"}, ] [[package]] name = "urllib3" -version = "2.1.0" +version = "2.2.1" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" files = [ - {file = "urllib3-2.1.0-py3-none-any.whl", hash = "sha256:55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3"}, - {file = "urllib3-2.1.0.tar.gz", hash = "sha256:df7aa8afb0148fa78488e7899b2c59b5f4ffcfa82e6c54ccb9dd37c1d7b52d54"}, + {file = "urllib3-2.2.1-py3-none-any.whl", hash = "sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d"}, + {file = "urllib3-2.2.1.tar.gz", hash = "sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19"}, ] [package.extras] brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] +h2 = ["h2 (>=4,<5)"] socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] [metadata] lock-version = "2.0" -python-versions = ">=3.8.1,<4" -content-hash = "5d4ffbf33a17f07f4c24181ac6c847896d416bb987157bc9c10695cf88d4a88b" +python-versions = ">=3.8" +content-hash = "3f9e22b86b62704dda7169950a048347caf5ca71eb9083da481bed7d4da370e5" diff --git a/prosemirror/__init__.py b/prosemirror/__init__.py index b10e880..307e757 100644 --- a/prosemirror/__init__.py +++ b/prosemirror/__init__.py @@ -4,13 +4,13 @@ __all__ = [ "Fragment", + "Mapping", "Mark", "Node", "ResolvedPos", "Schema", "Slice", - "basic_schema", - "Mapping", "Step", "Transform", + "basic_schema", ] diff --git a/prosemirror/model/__init__.py b/prosemirror/model/__init__.py index 4c119e4..d4dd24f 100644 --- a/prosemirror/model/__init__.py +++ b/prosemirror/model/__init__.py @@ -9,17 +9,17 @@ from .to_dom import DOMSerializer __all__ = [ + "ContentMatch", + "DOMParser", + "DOMSerializer", + "Fragment", + "Mark", + "MarkType", "Node", - "ResolvedPos", "NodeRange", - "Fragment", - "Slice", + "NodeType", "ReplaceError", - "Mark", + "ResolvedPos", "Schema", - "NodeType", - "MarkType", - "ContentMatch", - "DOMSerializer", - "DOMParser", + "Slice", ] diff --git a/prosemirror/model/content.py b/prosemirror/model/content.py index 95442d4..3bf6217 100644 --- a/prosemirror/model/content.py +++ b/prosemirror/model/content.py @@ -123,9 +123,9 @@ def search(match: ContentMatch, types: List["NodeType"]) -> Optional[Fragment]: nonlocal seen finished = match.match_fragment(after, start_index) if finished and (not to_end or finished.valid_end): - return Fragment.from_( - [cast("Node", tp.create_and_fill()) for tp in types] - ) + return Fragment.from_([ + cast("Node", tp.create_and_fill()) for tp in types + ]) for i in match.next: type = i.type next = i.next @@ -167,13 +167,11 @@ def compute_wrapping(self, target: "NodeType") -> Optional[List["NodeType"]]: and type.name not in seen and (not current["type"] or match.next[i].next.valid_end) ): - active.append( - { - "match": type.content_match, - "via": current, - "type": type, - } - ) + active.append({ + "match": type.content_match, + "via": current, + "type": type, + }) seen[type.name] = True return None diff --git a/prosemirror/model/from_dom.py b/prosemirror/model/from_dom.py index 1b7bb4a..e1760a1 100644 --- a/prosemirror/model/from_dom.py +++ b/prosemirror/model/from_dom.py @@ -98,15 +98,13 @@ def __init__(self, schema: Schema[Any, Any], rules: List[ParseRule]) -> None: self._styles = [rule for rule in rules if rule.style is not None] - self.normalize_lists = not any( - [ - schema.nodes[r.node].content_match.match_type(schema.nodes[r.node]) - for r in self._tags - if r.node is not None - and r.tag is not None - and re.match(r"^(ul|ol)\b", r.tag) is not None - ] - ) + self.normalize_lists = not any([ + schema.nodes[r.node].content_match.match_type(schema.nodes[r.node]) + for r in self._tags + if r.node is not None + and r.tag is not None + and re.match(r"^(ul|ol)\b", r.tag) is not None + ]) def parse( self, dom_: lxml.html.HtmlElement, options: Optional[ParseOptions] = None @@ -189,10 +187,11 @@ def match_style( if ( style is None or style.index(prop) != 0 - or rule.context - and not context.matches_context(rule.context) - or len(style) > len(prop) - and (ord(style[len(prop)]) != 61 or style[len(prop) + 1 :] != value) + or (rule.context and not context.matches_context(rule.context)) + or ( + len(style) > len(prop) + and (ord(style[len(prop)]) != 61 or style[len(prop) + 1 :] != value) + ) ): continue @@ -929,9 +928,9 @@ def find_in_text(self, text_node: DOMNode) -> None: def matches_context(self, context: str) -> bool: if "|" in context: - return any( - [self.matches_context(s) for s in re.split(r"\s*\|\s*", context)] - ) + return any([ + self.matches_context(s) for s in re.split(r"\s*\|\s*", context) + ]) parts = context.split("/") option = self.options.context diff --git a/prosemirror/model/resolvedpos.py b/prosemirror/model/resolvedpos.py index 2d95f10..dc5e7ec 100644 --- a/prosemirror/model/resolvedpos.py +++ b/prosemirror/model/resolvedpos.py @@ -171,12 +171,10 @@ def min(self, other: "ResolvedPos") -> "ResolvedPos": return other if other.pos < self.pos else self def __str__(self) -> str: - path = "/".join( - [ - f"{self.node(i).type.name}_{self.index(i - 1)}" - for i in range(1, self.depth + 1) - ] - ) + path = "/".join([ + f"{self.node(i).type.name}_{self.index(i - 1)}" + for i in range(1, self.depth + 1) + ]) return f"{path}:{self.parent_offset}" @classmethod diff --git a/prosemirror/model/to_dom.py b/prosemirror/model/to_dom.py index 2e782cb..2c4ff43 100644 --- a/prosemirror/model/to_dom.py +++ b/prosemirror/model/to_dom.py @@ -28,25 +28,23 @@ def __str__(self) -> str: return "".join([str(c) for c in self.children]) -SELF_CLOSING_ELEMENTS = frozenset( - { - "area", - "base", - "br", - "col", - "embed", - "hr", - "img", - "input", - "keygen", - "link", - "meta", - "param", - "source", - "track", - "wbr", - } -) +SELF_CLOSING_ELEMENTS = frozenset({ + "area", + "base", + "br", + "col", + "embed", + "hr", + "img", + "input", + "keygen", + "link", + "meta", + "param", + "source", + "track", + "wbr", +}) class Element(DocumentFragment): @@ -208,7 +206,7 @@ def marks_from_schema( def gather_to_dom( - obj: Mapping[str, Union[NodeType, MarkType]] + obj: Mapping[str, Union[NodeType, MarkType]], ) -> Dict[str, Callable[..., Any]]: result = {} for name in obj: diff --git a/prosemirror/schema/list/schema_list.py b/prosemirror/schema/list/schema_list.py index 8b984c0..8d3ee87 100644 --- a/prosemirror/schema/list/schema_list.py +++ b/prosemirror/schema/list/schema_list.py @@ -30,15 +30,13 @@ def add_list_nodes( nodes: Dict["Nodes", "NodeSpec"], item_content: str, list_group: str ) -> Dict["Nodes", "NodeSpec"]: copy = nodes.copy() - copy.update( - { - cast(Nodes, "ordered_list"): add( - orderd_list, NodeSpec(content="list_item+", group=list_group) - ), - cast(Nodes, "bullet_list"): add( - bullet_list, NodeSpec(content="list_item+", group=list_group) - ), - cast(Nodes, "list_item"): add(list_item, NodeSpec(content=item_content)), - } - ) + copy.update({ + cast(Nodes, "ordered_list"): add( + orderd_list, NodeSpec(content="list_item+", group=list_group) + ), + cast(Nodes, "bullet_list"): add( + bullet_list, NodeSpec(content="list_item+", group=list_group) + ), + cast(Nodes, "list_item"): add(list_item, NodeSpec(content=item_content)), + }) return copy diff --git a/prosemirror/test_builder/__init__.py b/prosemirror/test_builder/__init__.py index 35d4f7f..aea745a 100644 --- a/prosemirror/test_builder/__init__.py +++ b/prosemirror/test_builder/__init__.py @@ -10,21 +10,17 @@ nodes = add_list_nodes(_schema.spec["nodes"], "paragraph block*", "block") -nodes.update( - { - "doc": { - "content": "block+", - "attrs": {"meta": {"default": None}}, - } +nodes.update({ + "doc": { + "content": "block+", + "attrs": {"meta": {"default": None}}, } -) +}) -test_schema: Schema[Any, Any] = Schema( - { - "nodes": nodes, - "marks": _schema.spec["marks"], - } -) +test_schema: Schema[Any, Any] = Schema({ + "nodes": nodes, + "marks": _schema.spec["marks"], +}) out = builders( test_schema, diff --git a/prosemirror/transform/__init__.py b/prosemirror/transform/__init__.py index 9f6044f..4d27c97 100644 --- a/prosemirror/transform/__init__.py +++ b/prosemirror/transform/__init__.py @@ -20,30 +20,30 @@ from .transform import Transform, TransformError __all__ = [ - "Transform", - "TransformError", + "AddMarkStep", + "AddNodeMarkStep", + "AttrStep", + "MapResult", + "Mapping", + "RemoveMarkStep", + "RemoveNodeMarkStep", + "ReplaceAroundStep", + "ReplaceStep", "Step", + "StepMap", "StepResult", - "join_point", + "Transform", + "TransformError", "can_join", "can_split", - "insert_point", - "drop_point", - "lift_target", - "find_wrapping", "close_fragment", "covered_depths", + "drop_point", + "find_wrapping", "fits_trivially", + "insert_point", + "join_point", + "lift_target", "replace_step", - "StepMap", - "MapResult", - "Mapping", - "AttrStep", - "AddMarkStep", - "AddNodeMarkStep", - "RemoveMarkStep", - "ReplaceAroundStep", - "RemoveNodeMarkStep", - "ReplaceStep", "replace_step", ] diff --git a/prosemirror/transform/map.py b/prosemirror/transform/map.py index 1c8d564..e875bed 100644 --- a/prosemirror/transform/map.py +++ b/prosemirror/transform/map.py @@ -58,12 +58,10 @@ def deleted_across(self) -> bool: class Mappable(metaclass=abc.ABCMeta): @abc.abstractmethod - def map(self, pos: int, assoc: int = 1) -> int: - ... + def map(self, pos: int, assoc: int = 1) -> int: ... @abc.abstractmethod - def map_result(self, pos: int, assoc: int = 1) -> MapResult: - ... + def map_result(self, pos: int, assoc: int = 1) -> MapResult: ... class StepMap(Mappable): @@ -92,12 +90,10 @@ def map_result(self, pos: int, assoc: int = 1) -> MapResult: return self._map(pos, assoc, False) @overload - def _map(self, pos: int, assoc: int, simple: Literal[True]) -> int: - ... + def _map(self, pos: int, assoc: int, simple: Literal[True]) -> int: ... @overload - def _map(self, pos: int, assoc: int, simple: Literal[False]) -> MapResult: - ... + def _map(self, pos: int, assoc: int, simple: Literal[False]) -> MapResult: ... def _map(self, pos: int, assoc: int, simple: bool) -> Union[MapResult, int]: diff = 0 @@ -257,12 +253,10 @@ def map_result(self, pos: int, assoc: int = 1) -> MapResult: return self._map(pos, assoc, False) @overload - def _map(self, pos: int, assoc: int, simple: Literal[True]) -> int: - ... + def _map(self, pos: int, assoc: int, simple: Literal[True]) -> int: ... @overload - def _map(self, pos: int, assoc: int, simple: Literal[False]) -> MapResult: - ... + def _map(self, pos: int, assoc: int, simple: Literal[False]) -> MapResult: ... def _map(self, pos: int, assoc: int, simple: bool) -> Union[MapResult, int]: del_info = 0 diff --git a/prosemirror/transform/mark_step.py b/prosemirror/transform/mark_step.py index 5571475..7bb897e 100644 --- a/prosemirror/transform/mark_step.py +++ b/prosemirror/transform/mark_step.py @@ -54,7 +54,7 @@ def invert(self, doc: Optional[Node] = None) -> Step: def map(self, mapping: Mappable) -> Optional[Step]: from_ = mapping.map_result(self.from_, 1) to = mapping.map_result(self.to, -1) - if from_.deleted and to.deleted or from_.pos > to.pos: + if (from_.deleted and to.deleted) or from_.pos > to.pos: return None return AddMarkStep(from_.pos, to.pos, self.mark) diff --git a/prosemirror/transform/replace.py b/prosemirror/transform/replace.py index 37945f0..931554d 100644 --- a/prosemirror/transform/replace.py +++ b/prosemirror/transform/replace.py @@ -44,7 +44,7 @@ def fits_trivially( class _FrontierItem: - __slots__ = ("type", "match") + __slots__ = ("match", "type") def __init__(self, type_: NodeType, match: ContentMatch) -> None: self.type = type_ @@ -52,7 +52,7 @@ def __init__(self, type_: NodeType, match: ContentMatch) -> None: class _Fittable: - __slots__ = ("slice_depth", "frontier_depth", "parent", "inject", "wrap") + __slots__ = ("frontier_depth", "inject", "parent", "slice_depth", "wrap") def __init__( self, @@ -84,7 +84,7 @@ def __init__( class Fitter: - __slots__ = ("to_", "from__", "unplaced", "frontier", "placed") + __slots__ = ("from__", "frontier", "placed", "to_", "unplaced") def __init__(self, from__: ResolvedPos, to_: ResolvedPos, slice: Slice) -> None: self.to_ = to_ diff --git a/prosemirror/transform/replace_step.py b/prosemirror/transform/replace_step.py index 7ab32d2..d45386b 100644 --- a/prosemirror/transform/replace_step.py +++ b/prosemirror/transform/replace_step.py @@ -144,16 +144,14 @@ def apply(self, doc: Node) -> StepResult: return StepResult.from_replace(doc, self.from_, self.to, inserted) def get_map(self) -> StepMap: - return StepMap( - [ - self.from_, - self.gap_from - self.from_, - self.insert, - self.gap_to, - self.to - self.gap_to, - self.slice.size - self.insert, - ] - ) + return StepMap([ + self.from_, + self.gap_from - self.from_, + self.insert, + self.gap_to, + self.to - self.gap_to, + self.slice.size - self.insert, + ]) def invert(self, doc: Node) -> "ReplaceAroundStep": gap = self.gap_to - self.gap_from diff --git a/prosemirror/transform/step.py b/prosemirror/transform/step.py index 5c3a160..fd039d6 100644 --- a/prosemirror/transform/step.py +++ b/prosemirror/transform/step.py @@ -14,26 +14,22 @@ class Step(metaclass=abc.ABCMeta): json_id: str @abc.abstractmethod - def apply(self, _doc: Node) -> "StepResult": - ... + def apply(self, _doc: Node) -> "StepResult": ... def get_map(self) -> StepMap: return StepMap.empty @abc.abstractmethod - def invert(self, _doc: Node) -> "Step": - ... + def invert(self, _doc: Node) -> "Step": ... @abc.abstractmethod - def map(self, _mapping: Mappable) -> Optional["Step"]: - ... + def map(self, _mapping: Mappable) -> Optional["Step"]: ... def merge(self, _other: "Step") -> Optional["Step"]: return None @abc.abstractmethod - def to_json(self) -> JSONDict: - ... + def to_json(self) -> JSONDict: ... @staticmethod def from_json(schema: Schema[Any, Any], json_data: Union[JSONDict, str]) -> "Step": @@ -62,12 +58,10 @@ def step_json_id(id: str, step_class: Type[StepSubclass]) -> Type[StepSubclass]: class StepResult: @overload - def __init__(self, doc: Node, failed: Literal[None]) -> None: - ... + def __init__(self, doc: Node, failed: Literal[None]) -> None: ... @overload - def __init__(self, doc: None, failed: str) -> None: - ... + def __init__(self, doc: None, failed: str) -> None: ... def __init__(self, doc: Optional[Node], failed: Optional[str]) -> None: self.doc = doc diff --git a/prosemirror/transform/transform.py b/prosemirror/transform/transform.py index 7dcacd6..107f524 100644 --- a/prosemirror/transform/transform.py +++ b/prosemirror/transform/transform.py @@ -181,14 +181,12 @@ def iteratee( found["to"] = end found["step"] = step else: - matched.append( - { - "style": style, - "from_": max(pos, from_), - "to": end, - "step": step, - } - ) + matched.append({ + "style": style, + "from_": max(pos, from_), + "to": end, + "step": step, + }) return None self.doc.nodes_between(from_, to, iteratee) diff --git a/pyproject.toml b/pyproject.toml index f0a53b0..379d4b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,35 +11,28 @@ repository = "https://github.com/fellowinsights/prosemirror-py" keywords = ["prosemirror", "collaborative", "editing"] [tool.poetry.dependencies] -python = ">=3.8.1,<4" +python = ">=3.8" typing-extensions = "^4.4.0" -lxml = ">=4.9.2,<6.0.0" +lxml = "^5.2.1" cssselect = "^1.2.0" [tool.poetry.group.dev.dependencies] codecov = "^2.1.13" coverage = "^7.0.5" -flake8 = ">=6,<8" -isort = "^5.11.4" -lxml-stubs = "^0.4.0" -mypy = "1.8.0" +lxml-stubs = "^0.5.1" +mypy = "^1.9.0" pandoc = "^2.3" -pydash = "^7.0.3" -pytest = "^7.4.3" -pytest-cov = "^4.0.0" -ruff = ">=0.1.5,<0.4.0" +pydash = "^8.0.0" +pytest = "^8.1.1" +pytest-cov = "^5.0.0" +ruff = "^0.3.7" -[tool.black] -max-line-length = 88 +[tool.ruff.lint] +select = ["E", "F", "W", "I", "RUF"] +preview = true -[tool.ruff] -select = [ - "E", - "F", - "W", - "I", - "RUF", -] +[tool.ruff.format] +preview = true [tool.mypy] strict = true diff --git a/tests/prosemirror_model/tests/test_mark.py b/tests/prosemirror_model/tests/test_mark.py index fff1878..504986b 100644 --- a/tests/prosemirror_model/tests/test_mark.py +++ b/tests/prosemirror_model/tests/test_mark.py @@ -20,21 +20,19 @@ def link(href, title=None): code = schema.mark("code") -custom_schema = Schema( - { - "nodes": { - "doc": {"content": "paragraph+"}, - "paragraph": {"content": "text*"}, - "text": {}, - }, - "marks": { - "remark": {"attrs": {"id": {}}, "excludes": "", "inclusive": False}, - "user": {"attrs": {"id": {}}, "excludes": "_"}, - "strong": {"excludes": "em-group"}, - "em": {"group": "em-group"}, - }, - } -) +custom_schema = Schema({ + "nodes": { + "doc": {"content": "paragraph+"}, + "paragraph": {"content": "text*"}, + "text": {}, + }, + "marks": { + "remark": {"attrs": {"id": {}}, "excludes": "", "inclusive": False}, + "user": {"attrs": {"id": {}}, "excludes": "_"}, + "strong": {"excludes": "em-group"}, + "em": {"group": "em-group"}, + }, +}) custom = custom_schema.marks remark1 = custom["remark"].create({"id": 1}) diff --git a/tests/prosemirror_model/tests/test_node.py b/tests/prosemirror_model/tests/test_node.py index d613d32..a1e4410 100644 --- a/tests/prosemirror_model/tests/test_node.py +++ b/tests/prosemirror_model/tests/test_node.py @@ -19,27 +19,23 @@ custom_schema: Schema[ Literal["doc", "paragraph", "text", "contact", "hard_break"], str -] = Schema( - { - "nodes": { - "doc": {"content": "paragraph+"}, - "paragraph": {"content": "(text|contact)*"}, - "text": { - "toDebugString": lambda _: "custom_text", - }, - "contact": { - "inline": True, - "attrs": {"name": {}, "email": {}}, - "leafText": ( - lambda node: f"{node.attrs['name']} <{node.attrs['email']}>" - ), - }, - "hard_break": { - "toDebugString": lambda _: "custom_hard_break", - }, +] = Schema({ + "nodes": { + "doc": {"content": "paragraph+"}, + "paragraph": {"content": "(text|contact)*"}, + "text": { + "toDebugString": lambda _: "custom_text", }, - } -) + "contact": { + "inline": True, + "attrs": {"name": {}, "email": {}}, + "leafText": (lambda node: f"{node.attrs['name']} <{node.attrs['email']}>"), + }, + "hard_break": { + "toDebugString": lambda _: "custom_hard_break", + }, + }, +}) class TestToString: @@ -77,9 +73,10 @@ def test_respected_by_fragment(self): assert str(f) == "" def test_should_respect_custom_leafText_spec(self): - contact = custom_schema.nodes["contact"].create_checked( - {"name": "Bob", "email": "bob@example.com"} - ) + contact = custom_schema.nodes["contact"].create_checked({ + "name": "Bob", + "email": "bob@example.com", + }) paragraph = custom_schema.nodes["paragraph"].create_checked( {}, [custom_schema.text("Hello "), contact] ) @@ -201,9 +198,10 @@ def test_works_with_leafText(self): {}, [ custom_schema.text("Hello "), - custom_schema.nodes["contact"].create_checked( - {"name": "Alice", "email": "alice@example.com"} - ), + custom_schema.nodes["contact"].create_checked({ + "name": "Alice", + "email": "alice@example.com", + }), ], ) ], @@ -218,9 +216,10 @@ def test_should_ignore_leafText_spec_when_passing_a_custom_leaf_text(self): {}, [ custom_schema.text("Hello "), - custom_schema.nodes["contact"].create_checked( - {"name": "Alice", "email": "alice@example.com"} - ), + custom_schema.nodes["contact"].create_checked({ + "name": "Alice", + "email": "alice@example.com", + }), ], ) ], diff --git a/tests/prosemirror_model/tests/test_resolve.py b/tests/prosemirror_model/tests/test_resolve.py index 24dc7fa..98ce8d5 100644 --- a/tests/prosemirror_model/tests/test_resolve.py +++ b/tests/prosemirror_model/tests/test_resolve.py @@ -17,23 +17,21 @@ @pytest.mark.parametrize( "pos,exp", list( - enumerate( - [ - [_doc, 0, None, _p1["node"]], - [_doc, _p1, 0, None, "ab"], - [_doc, _p1, 1, "a", "b"], - [_doc, _p1, 2, "ab", None], - [_doc, 4, _p1["node"], _blk["node"]], - [_doc, _blk, 0, None, _p2["node"]], - [_doc, _blk, _p2, 0, None, "cd"], - [_doc, _blk, _p2, 1, "c", "d"], - [_doc, _blk, _p2, 2, "cd", "ef"], - [_doc, _blk, _p2, 3, "e", "f"], - [_doc, _blk, _p2, 4, "ef", None], - [_doc, _blk, 6, _p2["node"], None], - [_doc, 12, _blk["node"], None], - ] - ) + enumerate([ + [_doc, 0, None, _p1["node"]], + [_doc, _p1, 0, None, "ab"], + [_doc, _p1, 1, "a", "b"], + [_doc, _p1, 2, "ab", None], + [_doc, 4, _p1["node"], _blk["node"]], + [_doc, _blk, 0, None, _p2["node"]], + [_doc, _blk, _p2, 0, None, "cd"], + [_doc, _blk, _p2, 1, "c", "d"], + [_doc, _blk, _p2, 2, "cd", "ef"], + [_doc, _blk, _p2, 3, "e", "f"], + [_doc, _blk, _p2, 4, "ef", None], + [_doc, _blk, 6, _p2["node"], None], + [_doc, 12, _blk["node"], None], + ]) ), ) def test_node_resolve(pos, exp): diff --git a/tests/prosemirror_transform/tests/test_structure.py b/tests/prosemirror_transform/tests/test_structure.py index b02e0bf..61205ef 100644 --- a/tests/prosemirror_transform/tests/test_structure.py +++ b/tests/prosemirror_transform/tests/test_structure.py @@ -3,24 +3,22 @@ from prosemirror.model import Schema, Slice from prosemirror.transform import Transform, can_split, find_wrapping, lift_target -schema = Schema( - { - "nodes": { - "doc": {"content": "head? block* sect* closing?"}, - "para": {"content": "text*", "group": "block"}, - "head": {"content": "text*", "marks": ""}, - "figure": {"content": "caption figureimage", "group": "block"}, - "quote": {"content": "block+", "group": "block"}, - "figureimage": {}, - "caption": {"content": "text*", "marks": ""}, - "sect": {"content": "head block* sect*"}, - "closing": {"content": "text*"}, - "text": {"group": "inline"}, - "fixed": {"content": "head para closing", "group": "block"}, - }, - "marks": {"em": {}}, - } -) +schema = Schema({ + "nodes": { + "doc": {"content": "head? block* sect* closing?"}, + "para": {"content": "text*", "group": "block"}, + "head": {"content": "text*", "marks": ""}, + "figure": {"content": "caption figureimage", "group": "block"}, + "quote": {"content": "block+", "group": "block"}, + "figureimage": {}, + "caption": {"content": "text*", "marks": ""}, + "sect": {"content": "head block* sect*"}, + "closing": {"content": "text*"}, + "text": {"group": "inline"}, + "fixed": {"content": "head para closing", "group": "block"}, + }, + "marks": {"em": {}}, +}) def n(name, *content): @@ -106,26 +104,24 @@ def test_can_split(self, pass_, pos, depth, after): def test_doesnt_return_true_when_split_content_doesnt_fit_in_given_node_type( self, ): - s = Schema( - { - "nodes": { - "doc": {"content": "chapter+"}, - "para": {"content": "text*", "group": "block"}, - "head": {"content": "text*", "marks": ""}, - "figure": {"content": "caption figureimage", "group": "block"}, - "quote": {"content": "block+", "group": "block"}, - "figureimage": {}, - "caption": {"content": "text*", "marks": ""}, - "sect": {"content": "head block* sect*"}, - "closing": {"content": "text*"}, - "text": {"group": "inline"}, - "fixed": {"content": "head para closing", "group": "block"}, - "title": {"content": "text*"}, - "chapter": {"content": "title scene+"}, - "scene": {"content": "para+"}, - } + s = Schema({ + "nodes": { + "doc": {"content": "chapter+"}, + "para": {"content": "text*", "group": "block"}, + "head": {"content": "text*", "marks": ""}, + "figure": {"content": "caption figureimage", "group": "block"}, + "quote": {"content": "block+", "group": "block"}, + "figureimage": {}, + "caption": {"content": "text*", "marks": ""}, + "sect": {"content": "head block* sect*"}, + "closing": {"content": "text*"}, + "text": {"group": "inline"}, + "fixed": {"content": "head para closing", "group": "block"}, + "title": {"content": "text*"}, + "chapter": {"content": "title scene+"}, + "scene": {"content": "para+"}, } - ) + }) assert not can_split( s.node( "doc", diff --git a/tests/prosemirror_transform/tests/test_trans.py b/tests/prosemirror_transform/tests/test_trans.py index 32a972f..9e10508 100644 --- a/tests/prosemirror_transform/tests/test_trans.py +++ b/tests/prosemirror_transform/tests/test_trans.py @@ -76,12 +76,10 @@ def test_add_mark(doc, mark, expect, test_transform): def test_does_not_remove_non_excluded_marks_of_the_same_type(): - schema = Schema( - { - "nodes": {"doc": {"content": "text*"}, "text": {}}, - "marks": {"comment": {"excludes": "", "attrs": {"id": {}}}}, - } - ) + schema = Schema({ + "nodes": {"doc": {"content": "text*"}, "text": {}}, + "marks": {"comment": {"excludes": "", "attrs": {"id": {}}}}, + }) tr = Transform( schema.node( "doc", None, schema.text("hi", [schema.mark("comment", {"id": 10})]) @@ -92,12 +90,10 @@ def test_does_not_remove_non_excluded_marks_of_the_same_type(): def test_can_remote_multiple_excluded_marks(): - schema = Schema( - { - "nodes": {"doc": {"content": "text*"}, "text": {}}, - "marks": {"big": {"excludes": "small1 small2"}, "small1": {}, "small2": {}}, - } - ) + schema = Schema({ + "nodes": {"doc": {"content": "text*"}, "text": {}}, + "marks": {"big": {"excludes": "small1 small2"}, "small1": {}, "small2": {}}, + }) tr = Transform( schema.node( "doc", @@ -171,17 +167,15 @@ def test_remove_mark(doc, mark, expect, test_transform): def test_remove_more_than_one_mark_of_same_type_from_block(): - schema = Schema( - { - "nodes": { - "doc": {"content": "text*"}, - "text": {}, - }, - "marks": { - "comment": {"excludes": "", "attrs": {"id": {}}}, - }, - } - ) + schema = Schema({ + "nodes": { + "doc": {"content": "text*"}, + "text": {}, + }, + "marks": { + "comment": {"excludes": "", "attrs": {"id": {}}}, + }, + }) tr = Transform( schema.node( "doc", @@ -772,15 +766,13 @@ def test_replace(doc, source, expect, test_transform): def test_doesnt_fail_when_moving_text_would_solve_unsatisfied_content_constraint(): - s = Schema( - { - "nodes": { - **schema.spec["nodes"], - "title": {"content": "text*"}, - "doc": {"content": "title? block*"}, - }, - } - ) + s = Schema({ + "nodes": { + **schema.spec["nodes"], + "title": {"content": "text*"}, + "doc": {"content": "title? block*"}, + }, + }) tr = Transform(s.node("doc", None, s.node("title", None, s.text("hi")))) tr.replace( 1, @@ -798,15 +790,13 @@ def test_doesnt_fail_when_moving_text_would_solve_unsatisfied_content_constraint def test_pasting_half_open_slice_with_title_and_code_block_into_empty_title(): - s = Schema( - { - "nodes": { - **schema.spec["nodes"], - "title": {"content": "text*"}, - "doc": {"content": "title? block*"}, - }, - } - ) + s = Schema({ + "nodes": { + **schema.spec["nodes"], + "title": {"content": "text*"}, + "doc": {"content": "title? block*"}, + }, + }) tr = Transform(s.node("doc", None, [s.node("title", None, [])])) tr.replace( 1, @@ -824,15 +814,13 @@ def test_pasting_half_open_slice_with_title_and_code_block_into_empty_title(): def test_pasting_half_open_slice_with_heading_and_code_block_into_empty_title(): - s = Schema( - { - "nodes": { - **schema.spec["nodes"], - "title": {"content": "text*"}, - "doc": {"content": "title? block*"}, - }, - } - ) + s = Schema({ + "nodes": { + **schema.spec["nodes"], + "title": {"content": "text*"}, + "doc": {"content": "title? block*"}, + }, + }) tr = Transform(s.node("doc", None, [s.node("title")])) tr.replace( 1, @@ -850,17 +838,15 @@ def test_pasting_half_open_slice_with_heading_and_code_block_into_empty_title(): def test_replacing_in_nodes_with_fixed_content(): - s = Schema( - { - "nodes": { - "doc": {"content": "block+"}, - "a": {"content": "inline*"}, - "b": {"content": "inline*"}, - "block": {"content": "a b"}, - "text": {"group": "inline"}, - } + s = Schema({ + "nodes": { + "doc": {"content": "block+"}, + "a": {"content": "inline*"}, + "b": {"content": "inline*"}, + "block": {"content": "a b"}, + "text": {"group": "inline"}, } - ) + }) doc = s.node( "doc", @@ -879,15 +865,13 @@ def test_replacing_in_nodes_with_fixed_content(): class TestTopLevelMarkReplace: - ms = Schema( - { - "nodes": { - **schema.spec["nodes"], - "doc": {**schema.spec["nodes"]["doc"], "marks": "_"}, # type: ignore - }, - "marks": schema.spec["marks"], - } - ) + ms = Schema({ + "nodes": { + **schema.spec["nodes"], + "doc": {**schema.spec["nodes"]["doc"], "marks": "_"}, # type: ignore + }, + "marks": schema.spec["marks"], + }) def test_preserves_mark_on_block_nodes(self): ms = self.ms @@ -924,12 +908,10 @@ def test_preserves_marks_on_open_slice_block_nodes(self): class TestEnforcingHeadingAndBody: nodes_sepc = schema.spec["nodes"].copy() - nodes_sepc.update( - { - "doc": {**nodes_sepc["doc"], "content": "heading body"}, # type: ignore - "body": {"content": "block+"}, - } - ) + nodes_sepc.update({ + "doc": {**nodes_sepc["doc"], "content": "heading body"}, # type: ignore + "body": {"content": "block+"}, + }) hb_schema = Schema({"nodes": nodes_sepc, "marks": schema.spec["marks"]}) hb = builders( hb_schema, @@ -988,18 +970,16 @@ def test_will_insert_filler_nodes_before_a_node_when_necessary(self): def test_keeps_isolating_nodes_together(): - s = Schema( - { - "nodes": { - **schema.spec["nodes"], - "iso": { - "group": "block", - "content": "block+", - "isolating": True, - }, + s = Schema({ + "nodes": { + **schema.spec["nodes"], + "iso": { + "group": "block", + "content": "block+", + "isolating": True, }, - } - ) + }, + }) doc = s.node("doc", None, [s.node("paragraph", None, [s.text("one")])]) iso = Fragment.from_( s.node("iso", None, [s.node("paragraph", None, [s.text("two")])])