diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44f8f6f..9e86d96 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] os: [macos-latest, windows-latest, ubuntu-latest] steps: - uses: actions/checkout@v1 @@ -80,7 +80,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] # ubuntu wheel is built in `manylinux_build.yml` os: [macos-latest, windows-latest] diff --git a/.github/workflows/manylinux_build.yml b/.github/workflows/manylinux_build.yml index 7fbc8c1..b67e1f8 100644 --- a/.github/workflows/manylinux_build.yml +++ b/.github/workflows/manylinux_build.yml @@ -9,15 +9,11 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: - - 3.6 - - 3.7 - - 3.8 - - 3.9 + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] container: - image: quay.io/pypa/manylinux2010_x86_64 + image: quay.io/pypa/manylinux2014_x86_64 env: - PATH: /root/.cargo/bin:/root/.local/bin:/opt/python/cp36-cp36m/bin:/opt/python/cp37-cp37m/bin:/opt/python/cp38-cp38/bin:/opt/rh/devtoolset-2/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/python/cp35-cp35m/bin:/opt/python/cp36-cp36m/bin:/opt/python/cp37-cp37m/bin:/opt/python/cp38-cp38/bin:/opt/python/cp39-cp39/bin:/opt/rh/devtoolset-8/root/usr/bin + PATH: /root/.cargo/bin:/root/.local/bin:/opt/python/cp36-cp36m/bin:/opt/python/cp37-cp37m/bin:/opt/python/cp38-cp38/bin:/opt/rh/devtoolset-2/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/python/cp35-cp35m/bin:/opt/python/cp36-cp36m/bin:/opt/python/cp37-cp37m/bin:/opt/python/cp38-cp38/bin:/opt/python/cp39-cp39/bin:/opt/python/cp310-cp310/bin:/opt/python/cp310-cp310/bin:/opt/rh/devtoolset-8/root/usr/bin:/opt/_internal/cpython-3.11.1/bin:/opt/_internal/cpython-3.10.1/bin options: --user root env: HOME: /root @@ -27,6 +23,8 @@ jobs: - name: Install rust run: | curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal + - name: install gcc + run: yum -y install gcc - name: Test rust lib run: cargo test diff --git a/python/.gitignore b/python/.gitignore index 99ac6b2..115b1f6 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -153,4 +153,4 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk - +/.venv37 diff --git a/python/Cargo.toml b/python/Cargo.toml index b92000e..aaf7d38 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -7,12 +7,12 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -textspan = "0.5.2" +textspanrs = { package = "textspan", version = "0.5.2"} [lib] name = "textspan" crate-type = ["cdylib"] [dependencies.pyo3] -version = "^0.13" +version = "0.17.3" features = ["extension-module"] diff --git a/python/poetry.lock b/python/poetry.lock index e913c4e..b46452f 100644 --- a/python/poetry.lock +++ b/python/poetry.lock @@ -1,207 +1,204 @@ -[[package]] -category = "dev" -description = "Asyncio support for PEP-567 contextvars backport." -marker = "python_version < \"3.7\"" -name = "aiocontextvars" -optional = false -python-versions = ">=3.5" -version = "0.2.2" - -[package.dependencies] -[package.dependencies.contextvars] -python = "<3.7" -version = "2.4" +# This file is automatically @generated by Poetry and should not be changed by hand. [[package]] -category = "dev" -description = "Atomic file writes." -marker = "sys_platform == \"win32\"" -name = "atomicwrites" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "1.4.0" - -[[package]] -category = "dev" -description = "Classes Without Boilerplate" name = "attrs" +version = "22.2.0" +description = "Classes Without Boilerplate" +category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "19.3.0" +python-versions = ">=3.6" +files = [ + {file = "attrs-22.2.0-py3-none-any.whl", hash = "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836"}, + {file = "attrs-22.2.0.tar.gz", hash = "sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99"}, +] [package.extras] -azure-pipelines = ["coverage", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface", "pytest-azurepipelines"] -dev = ["coverage", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface", "sphinx", "pre-commit"] -docs = ["sphinx", "zope.interface"] -tests = ["coverage", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface"] +cov = ["attrs[tests]", "coverage-enable-subprocess", "coverage[toml] (>=5.3)"] +dev = ["attrs[docs,tests]"] +docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope.interface"] +tests = ["attrs[tests-no-zope]", "zope.interface"] +tests-no-zope = ["cloudpickle", "cloudpickle", "hypothesis", "hypothesis", "mypy (>=0.971,<0.990)", "mypy (>=0.971,<0.990)", "pympler", "pympler", "pytest (>=4.3.0)", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-mypy-plugins", "pytest-xdist[psutil]", "pytest-xdist[psutil]"] [[package]] -category = "dev" -description = "Cross-platform colored terminal text." -marker = "sys_platform == \"win32\"" name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -version = "0.4.3" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] [[package]] +name = "docstring-parser" +version = "0.7.3" +description = "" category = "dev" -description = "PEP 567 Backport" -marker = "python_version < \"3.7\"" -name = "contextvars" optional = false -python-versions = "*" -version = "2.4" - -[package.dependencies] -immutables = ">=0.9" +python-versions = "~=3.5" +files = [ + {file = "docstring_parser-0.7.3.tar.gz", hash = "sha256:cde5fbf8b846433dfbde1e0f96b7f909336a634d5df34a38cb75050c7346734a"}, +] [[package]] +name = "exceptiongroup" +version = "1.1.0" +description = "Backport of PEP 654 (exception groups)" category = "dev" -description = "" -name = "docstring-parser" optional = false -python-versions = "~=3.6" -version = "0.7.2" +python-versions = ">=3.7" +files = [ + {file = "exceptiongroup-1.1.0-py3-none-any.whl", hash = "sha256:327cbda3da756e2de031a3107b81ab7b3770a602c4d16ca618298c526f4bec1e"}, + {file = "exceptiongroup-1.1.0.tar.gz", hash = "sha256:bcb67d800a4497e1b404c2dd44fca47d3b7a5e5433dbab67f96c1a685cdfdf23"}, +] + +[package.extras] +test = ["pytest (>=6)"] [[package]] -category = "dev" -description = "A library for automatically generating command line interfaces." name = "fire" +version = "0.3.1" +description = "A library for automatically generating command line interfaces." +category = "dev" optional = false python-versions = "*" -version = "0.3.1" +files = [ + {file = "fire-0.3.1.tar.gz", hash = "sha256:9736a16227c3d469e5d2d296bce5b4d8fa8d7851e953bda327a455fc2994307f"}, +] [package.dependencies] six = "*" termcolor = "*" [[package]] -category = "dev" -description = "A library for property-based testing" name = "hypothesis" +version = "6.61.0" +description = "A library for property-based testing" +category = "dev" optional = false -python-versions = ">=3.5.2" -version = "5.23.11" +python-versions = ">=3.7" +files = [ + {file = "hypothesis-6.61.0-py3-none-any.whl", hash = "sha256:7bb22d22e35db99d5724bbf5bdc686b46add94a0f228bf1be249c47ec46b9c7f"}, + {file = "hypothesis-6.61.0.tar.gz", hash = "sha256:fbf7da30aea839d88898f74bcc027f0f997060498a8a7605880688c8a2166215"}, +] [package.dependencies] attrs = ">=19.2.0" +exceptiongroup = {version = ">=1.0.0", markers = "python_version < \"3.11\""} sortedcontainers = ">=2.1.0,<3.0.0" [package.extras] -all = ["django (>=2.2)", "dpcontracts (>=0.4)", "lark-parser (>=0.6.5)", "numpy (>=1.9.0)", "pandas (>=0.19)", "pytest (>=4.3)", "python-dateutil (>=1.4)", "pytz (>=2014.1)"] +all = ["backports.zoneinfo (>=0.2.1)", "black (>=19.10b0)", "click (>=7.0)", "django (>=3.2)", "dpcontracts (>=0.4)", "importlib-metadata (>=3.6)", "lark (>=0.10.1)", "libcst (>=0.3.16)", "numpy (>=1.9.0)", "pandas (>=1.0)", "pytest (>=4.6)", "python-dateutil (>=1.4)", "pytz (>=2014.1)", "redis (>=3.0.0)", "rich (>=9.0.0)", "tzdata (>=2022.7)"] +cli = ["black (>=19.10b0)", "click (>=7.0)", "rich (>=9.0.0)"] +codemods = ["libcst (>=0.3.16)"] dateutil = ["python-dateutil (>=1.4)"] -django = ["pytz (>=2014.1)", "django (>=2.2)"] +django = ["django (>=3.2)"] dpcontracts = ["dpcontracts (>=0.4)"] -lark = ["lark-parser (>=0.6.5)"] +ghostwriter = ["black (>=19.10b0)"] +lark = ["lark (>=0.10.1)"] numpy = ["numpy (>=1.9.0)"] -pandas = ["pandas (>=0.19)"] -pytest = ["pytest (>=4.3)"] +pandas = ["pandas (>=1.0)"] +pytest = ["pytest (>=4.6)"] pytz = ["pytz (>=2014.1)"] +redis = ["redis (>=3.0.0)"] +zoneinfo = ["backports.zoneinfo (>=0.2.1)", "tzdata (>=2022.7)"] [[package]] -category = "dev" -description = "Immutable Collections" -marker = "python_version < \"3.7\"" -name = "immutables" -optional = false -python-versions = ">=3.5" -version = "0.14" - -[[package]] -category = "dev" -description = "Read metadata from Python packages" -marker = "python_version < \"3.8\"" name = "importlib-metadata" +version = "6.0.0" +description = "Read metadata from Python packages" +category = "dev" optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" -version = "1.7.0" +python-versions = ">=3.7" +files = [ + {file = "importlib_metadata-6.0.0-py3-none-any.whl", hash = "sha256:7efb448ec9a5e313a57655d35aa54cd3e01b7e1fbcf72dce1bf06119420f5bad"}, + {file = "importlib_metadata-6.0.0.tar.gz", hash = "sha256:e354bedeb60efa6affdcc8ae121b73544a7aa74156d047311948f6d711cd378d"}, +] [package.dependencies] +typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} zipp = ">=0.5" [package.extras] -docs = ["sphinx", "rst.linker"] -testing = ["packaging", "pep517", "importlib-resources (>=1.3)"] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +perf = ["ipython"] +testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)"] [[package]] -category = "dev" -description = "iniconfig: brain-dead simple config-ini parsing" name = "iniconfig" +version = "1.1.1" +description = "iniconfig: brain-dead simple config-ini parsing" +category = "dev" optional = false python-versions = "*" -version = "1.0.1" +files = [ + {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, + {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, +] [[package]] -category = "dev" -description = "Python logging made (stupidly) simple" name = "loguru" +version = "0.5.3" +description = "Python logging made (stupidly) simple" +category = "dev" optional = false python-versions = ">=3.5" -version = "0.5.1" +files = [ + {file = "loguru-0.5.3-py3-none-any.whl", hash = "sha256:f8087ac396b5ee5f67c963b495d615ebbceac2796379599820e324419d53667c"}, + {file = "loguru-0.5.3.tar.gz", hash = "sha256:b28e72ac7a98be3d28ad28570299a393dfcd32e5e3f6a353dec94675767b6319"}, +] [package.dependencies] -colorama = ">=0.3.4" -win32-setctime = ">=1.0.0" - -[package.dependencies.aiocontextvars] -python = "<3.7" -version = ">=0.2.0" +colorama = {version = ">=0.3.4", markers = "sys_platform == \"win32\""} +win32-setctime = {version = ">=1.0.0", markers = "sys_platform == \"win32\""} [package.extras] -dev = ["codecov (>=2.0.15)", "colorama (>=0.3.4)", "flake8 (>=3.7.7)", "isort (>=4.3.20)", "tox (>=3.9.0)", "tox-travis (>=0.12)", "pytest (>=4.6.2)", "pytest-cov (>=2.7.1)", "Sphinx (>=2.2.1)", "sphinx-autobuild (>=0.7.1)", "sphinx-rtd-theme (>=0.4.3)", "black (>=19.3b0)"] - -[[package]] -category = "dev" -description = "More routines for operating on iterables, beyond itertools" -name = "more-itertools" -optional = false -python-versions = ">=3.5" -version = "8.4.0" +dev = ["Sphinx (>=2.2.1)", "black (>=19.10b0)", "codecov (>=2.0.15)", "colorama (>=0.3.4)", "flake8 (>=3.7.7)", "isort (>=5.1.1)", "pytest (>=4.6.2)", "pytest-cov (>=2.7.1)", "sphinx-autobuild (>=0.7.1)", "sphinx-rtd-theme (>=0.4.3)", "tox (>=3.9.0)", "tox-travis (>=0.12)"] [[package]] -category = "dev" -description = "Core utilities for Python packages" name = "packaging" +version = "22.0" +description = "Core utilities for Python packages" +category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "20.4" - -[package.dependencies] -pyparsing = ">=2.0.2" -six = "*" +python-versions = ">=3.7" +files = [ + {file = "packaging-22.0-py3-none-any.whl", hash = "sha256:957e2148ba0e1a3b282772e791ef1d8083648bc131c8ab0c1feba110ce1146c3"}, + {file = "packaging-22.0.tar.gz", hash = "sha256:2198ec20bd4c017b8f9717e00f0c8714076fc2fd93816750ab48e2c41de2cfd3"}, +] [[package]] -category = "dev" -description = "plugin and hook calling mechanisms for python" name = "pluggy" +version = "1.0.0" +description = "plugin and hook calling mechanisms for python" +category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "0.13.1" +python-versions = ">=3.6" +files = [ + {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, + {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, +] [package.dependencies] -[package.dependencies.importlib-metadata] -python = "<3.8" -version = ">=0.12" +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} [package.extras] dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] [[package]] -category = "dev" -description = "library with cross-python path, ini-parsing, io, code, log facilities" -name = "py" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "1.9.0" - -[[package]] -category = "dev" -description = "" name = "pydoc-md" +version = "0.1.0" +description = "" +category = "dev" optional = false python-versions = ">=3.6,<4.0" -version = "0.1.0" +files = [ + {file = "pydoc-md-0.1.0.tar.gz", hash = "sha256:5b64025c83d9230438bab6019ce570876a15a77e7f6bb83e0d1320ed34492700"}, + {file = "pydoc_md-0.1.0-py3-none-any.whl", hash = "sha256:b2bcf3df7aa51d0bb40db9a67e5607caba64b7cdb1d791f40d2d7ef372449f85"}, +] [package.dependencies] docstring_parser = ">=0.7.2,<0.8.0" @@ -209,205 +206,125 @@ fire = ">=0.3.1,<0.4.0" loguru = ">=0.5.1,<0.6.0" [[package]] -category = "dev" -description = "Python parsing module" -name = "pyparsing" -optional = false -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" -version = "2.4.7" - -[[package]] -category = "dev" -description = "pytest: simple powerful testing with Python" name = "pytest" +version = "7.2.0" +description = "pytest: simple powerful testing with Python" +category = "dev" optional = false -python-versions = ">=3.5" -version = "6.0.1" +python-versions = ">=3.7" +files = [ + {file = "pytest-7.2.0-py3-none-any.whl", hash = "sha256:892f933d339f068883b6fd5a459f03d85bfcb355e4981e146d2c7616c21fef71"}, + {file = "pytest-7.2.0.tar.gz", hash = "sha256:c4014eb40e10f11f355ad4e3c2fb2c6c6d1919c73f3b5a433de4708202cade59"}, +] [package.dependencies] -atomicwrites = ">=1.0" -attrs = ">=17.4.0" -colorama = "*" +attrs = ">=19.2.0" +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} iniconfig = "*" -more-itertools = ">=4.0.0" packaging = "*" -pluggy = ">=0.12,<1.0" -py = ">=1.8.2" -toml = "*" - -[package.dependencies.importlib-metadata] -python = "<3.8" -version = ">=0.12" +pluggy = ">=0.12,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} [package.extras] -checkqa_mypy = ["mypy (0.780)"] -testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] +testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] [[package]] -category = "dev" -description = "Python 2 and 3 compatibility utilities" name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -version = "1.15.0" +files = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] [[package]] -category = "dev" -description = "Sorted Containers -- Sorted List, Sorted Dict, Sorted Set" name = "sortedcontainers" +version = "2.4.0" +description = "Sorted Containers -- Sorted List, Sorted Dict, Sorted Set" +category = "dev" optional = false python-versions = "*" -version = "2.2.2" +files = [ + {file = "sortedcontainers-2.4.0-py2.py3-none-any.whl", hash = "sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0"}, + {file = "sortedcontainers-2.4.0.tar.gz", hash = "sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88"}, +] [[package]] -category = "dev" -description = "ANSII Color formatting for output in terminal." name = "termcolor" +version = "2.1.1" +description = "ANSI color formatting for output in terminal" +category = "dev" optional = false -python-versions = "*" -version = "1.1.0" +python-versions = ">=3.7" +files = [ + {file = "termcolor-2.1.1-py3-none-any.whl", hash = "sha256:fa852e957f97252205e105dd55bbc23b419a70fec0085708fc0515e399f304fd"}, + {file = "termcolor-2.1.1.tar.gz", hash = "sha256:67cee2009adc6449c650f6bcf3bdeed00c8ba53a8cda5362733c53e0a39fb70b"}, +] + +[package.extras] +tests = ["pytest", "pytest-cov"] [[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" category = "dev" -description = "Python Library for Tom's Obvious, Minimal Language" -name = "toml" optional = false -python-versions = "*" -version = "0.10.1" +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] [[package]] +name = "typing-extensions" +version = "4.4.0" +description = "Backported and Experimental Type Hints for Python 3.7+" category = "dev" -description = "A small Python utility to set file creation time on Windows" -marker = "sys_platform == \"win32\"" +optional = false +python-versions = ">=3.7" +files = [ + {file = "typing_extensions-4.4.0-py3-none-any.whl", hash = "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e"}, + {file = "typing_extensions-4.4.0.tar.gz", hash = "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa"}, +] + +[[package]] name = "win32-setctime" +version = "1.1.0" +description = "A small Python utility to set file creation time on Windows" +category = "dev" optional = false python-versions = ">=3.5" -version = "1.0.1" +files = [ + {file = "win32_setctime-1.1.0-py3-none-any.whl", hash = "sha256:231db239e959c2fe7eb1d7dc129f11172354f98361c4fa2d6d2d7e278baa8aad"}, + {file = "win32_setctime-1.1.0.tar.gz", hash = "sha256:15cf5750465118d6929ae4de4eb46e8edae9a5634350c01ba582df868e932cb2"}, +] [package.extras] -dev = ["pytest (>=4.6.2)", "black (>=19.3b0)"] +dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] [[package]] -category = "dev" -description = "Backport of pathlib-compatible object wrapper for zip files" -marker = "python_version < \"3.8\"" name = "zipp" +version = "3.11.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +category = "dev" optional = false -python-versions = ">=3.6" -version = "3.1.0" +python-versions = ">=3.7" +files = [ + {file = "zipp-3.11.0-py3-none-any.whl", hash = "sha256:83a28fcb75844b5c0cdaf5aa4003c2d728c77e05f5aeabe8e95e56727005fbaa"}, + {file = "zipp-3.11.0.tar.gz", hash = "sha256:a7a22e05929290a67401440b39690ae6563279bced5f314609d9d03798f56766"}, +] [package.extras] -docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] -testing = ["jaraco.itertools", "func-timeout"] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)"] +testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] [metadata] -content-hash = "56f656eaeb0471f4b059ae3c3a1a259ee036a4a875d180b908cbb54327bea2c6" -python-versions = "^3.6" - -[metadata.files] -aiocontextvars = [ - {file = "aiocontextvars-0.2.2-py2.py3-none-any.whl", hash = "sha256:885daf8261818767d8f7cbd79f9d4482d118f024b6586ef6e67980236a27bfa3"}, - {file = "aiocontextvars-0.2.2.tar.gz", hash = "sha256:f027372dc48641f683c559f247bd84962becaacdc9ba711d583c3871fb5652aa"}, -] -atomicwrites = [ - {file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"}, - {file = "atomicwrites-1.4.0.tar.gz", hash = "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"}, -] -attrs = [ - {file = "attrs-19.3.0-py2.py3-none-any.whl", hash = "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c"}, - {file = "attrs-19.3.0.tar.gz", hash = "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72"}, -] -colorama = [ - {file = "colorama-0.4.3-py2.py3-none-any.whl", hash = "sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff"}, - {file = "colorama-0.4.3.tar.gz", hash = "sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"}, -] -contextvars = [ - {file = "contextvars-2.4.tar.gz", hash = "sha256:f38c908aaa59c14335eeea12abea5f443646216c4e29380d7bf34d2018e2c39e"}, -] -docstring-parser = [ - {file = "docstring_parser-0.7.2.tar.gz", hash = "sha256:8ef4dd7122a0a8a2e057c400968f920628cec8bda207a7355d8f3a05672ffd8d"}, -] -fire = [ - {file = "fire-0.3.1.tar.gz", hash = "sha256:9736a16227c3d469e5d2d296bce5b4d8fa8d7851e953bda327a455fc2994307f"}, -] -hypothesis = [ - {file = "hypothesis-5.23.11-py3-none-any.whl", hash = "sha256:c0ed9cbbba273fb4ff4148ff539b73b52d5b6422b1bb86a7901f8cbb43f49db3"}, - {file = "hypothesis-5.23.11.tar.gz", hash = "sha256:69882d263175bd4731200c35c1bdfdc0a6c1af08a85672cdc51af26b18e3cac7"}, -] -immutables = [ - {file = "immutables-0.14-cp35-cp35m-macosx_10_14_x86_64.whl", hash = "sha256:860666fab142401a5535bf65cbd607b46bc5ed25b9d1eb053ca8ed9a1a1a80d6"}, - {file = "immutables-0.14-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:ce01788878827c3f0331c254a4ad8d9721489a5e65cc43e19c80040b46e0d297"}, - {file = "immutables-0.14-cp36-cp36m-macosx_10_14_x86_64.whl", hash = "sha256:8797eed4042f4626b0bc04d9cf134208918eb0c937a8193a2c66df5041e62d2e"}, - {file = "immutables-0.14-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:33ce2f977da7b5e0dddd93744862404bdb316ffe5853ec853e53141508fa2e6a"}, - {file = "immutables-0.14-cp36-cp36m-win_amd64.whl", hash = "sha256:6c8eace4d98988c72bcb37c05e79aae756832738305ae9497670482a82db08bc"}, - {file = "immutables-0.14-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:ab6c18b7b2b2abc83e0edc57b0a38bf0915b271582a1eb8c7bed1c20398f8040"}, - {file = "immutables-0.14-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:c099212fd6504513a50e7369fe281007c820cf9d7bb22a336486c63d77d6f0b2"}, - {file = "immutables-0.14-cp37-cp37m-win_amd64.whl", hash = "sha256:714aedbdeba4439d91cb5e5735cb10631fc47a7a69ea9cc8ecbac90322d50a4a"}, - {file = "immutables-0.14-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:1c11050c49e193a1ec9dda1747285333f6ba6a30bbeb2929000b9b1192097ec0"}, - {file = "immutables-0.14-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:c453e12b95e1d6bb4909e8743f88b7f5c0c97b86a8bc0d73507091cb644e3c1e"}, - {file = "immutables-0.14-cp38-cp38-win_amd64.whl", hash = "sha256:ef9da20ec0f1c5853b5c8f8e3d9e1e15b8d98c259de4b7515d789a606af8745e"}, - {file = "immutables-0.14.tar.gz", hash = "sha256:a0a1cc238b678455145bae291d8426f732f5255537ed6a5b7645949704c70a78"}, -] -importlib-metadata = [ - {file = "importlib_metadata-1.7.0-py2.py3-none-any.whl", hash = "sha256:dc15b2969b4ce36305c51eebe62d418ac7791e9a157911d58bfb1f9ccd8e2070"}, - {file = "importlib_metadata-1.7.0.tar.gz", hash = "sha256:90bb658cdbbf6d1735b6341ce708fc7024a3e14e99ffdc5783edea9f9b077f83"}, -] -iniconfig = [ - {file = "iniconfig-1.0.1-py3-none-any.whl", hash = "sha256:80cf40c597eb564e86346103f609d74efce0f6b4d4f30ec8ce9e2c26411ba437"}, - {file = "iniconfig-1.0.1.tar.gz", hash = "sha256:e5f92f89355a67de0595932a6c6c02ab4afddc6fcdc0bfc5becd0d60884d3f69"}, -] -loguru = [ - {file = "loguru-0.5.1-py3-none-any.whl", hash = "sha256:e5d362a43cd2fc2da63551d79a6830619c4d5b3a8b976515748026f92f351b61"}, - {file = "loguru-0.5.1.tar.gz", hash = "sha256:70201d5fce26da89b7a5f168caa2bb674e06b969829f56737db1d6472e53e7c3"}, -] -more-itertools = [ - {file = "more-itertools-8.4.0.tar.gz", hash = "sha256:68c70cc7167bdf5c7c9d8f6954a7837089c6a36bf565383919bb595efb8a17e5"}, - {file = "more_itertools-8.4.0-py3-none-any.whl", hash = "sha256:b78134b2063dd214000685165d81c154522c3ee0a1c0d4d113c80361c234c5a2"}, -] -packaging = [ - {file = "packaging-20.4-py2.py3-none-any.whl", hash = "sha256:998416ba6962ae7fbd6596850b80e17859a5753ba17c32284f67bfff33784181"}, - {file = "packaging-20.4.tar.gz", hash = "sha256:4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8"}, -] -pluggy = [ - {file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"}, - {file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"}, -] -py = [ - {file = "py-1.9.0-py2.py3-none-any.whl", hash = "sha256:366389d1db726cd2fcfc79732e75410e5fe4d31db13692115529d34069a043c2"}, - {file = "py-1.9.0.tar.gz", hash = "sha256:9ca6883ce56b4e8da7e79ac18787889fa5206c79dcc67fb065376cd2fe03f342"}, -] -pydoc-md = [ - {file = "pydoc-md-0.1.0.tar.gz", hash = "sha256:5b64025c83d9230438bab6019ce570876a15a77e7f6bb83e0d1320ed34492700"}, - {file = "pydoc_md-0.1.0-py3-none-any.whl", hash = "sha256:b2bcf3df7aa51d0bb40db9a67e5607caba64b7cdb1d791f40d2d7ef372449f85"}, -] -pyparsing = [ - {file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"}, - {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, -] -pytest = [ - {file = "pytest-6.0.1-py3-none-any.whl", hash = "sha256:8b6007800c53fdacd5a5c192203f4e531eb2a1540ad9c752e052ec0f7143dbad"}, - {file = "pytest-6.0.1.tar.gz", hash = "sha256:85228d75db9f45e06e57ef9bf4429267f81ac7c0d742cc9ed63d09886a9fe6f4"}, -] -six = [ - {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"}, - {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"}, -] -sortedcontainers = [ - {file = "sortedcontainers-2.2.2-py2.py3-none-any.whl", hash = "sha256:c633ebde8580f241f274c1f8994a665c0e54a17724fecd0cae2f079e09c36d3f"}, - {file = "sortedcontainers-2.2.2.tar.gz", hash = "sha256:4e73a757831fc3ca4de2859c422564239a31d8213d09a2a666e375807034d2ba"}, -] -termcolor = [ - {file = "termcolor-1.1.0.tar.gz", hash = "sha256:1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b"}, -] -toml = [ - {file = "toml-0.10.1-py2.py3-none-any.whl", hash = "sha256:bda89d5935c2eac546d648028b9901107a595863cb36bae0c73ac804a9b4ce88"}, - {file = "toml-0.10.1.tar.gz", hash = "sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f"}, -] -win32-setctime = [ - {file = "win32_setctime-1.0.1-py3-none-any.whl", hash = "sha256:568fd636c68350bcc54755213fe01966fe0a6c90b386c0776425944a0382abef"}, - {file = "win32_setctime-1.0.1.tar.gz", hash = "sha256:b47e5023ec7f0b4962950902b15bc56464a380d869f59d27dbf9ab423b23e8f9"}, -] -zipp = [ - {file = "zipp-3.1.0-py3-none-any.whl", hash = "sha256:aa36550ff0c0b7ef7fa639055d797116ee891440eac1a56f378e2d3179e0320b"}, - {file = "zipp-3.1.0.tar.gz", hash = "sha256:c599e4d75c98f6798c509911d08a22e6c021d074469042177c8c86fb92eefd96"}, -] +lock-version = "2.0" +python-versions = "^3.7" +content-hash = "89365fe557cd87888c4381f25176c19c8bae28c217c89aaac2db05b33cc85f79" diff --git a/python/pyproject.toml b/python/pyproject.toml index faa8c0f..53e4eae 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [tool.poetry] name = "pytextspan" -version = "0.5.4" +version = "0.5.5" description = "" authors = [ "Yohei Tamura ",] license = "MIT" @@ -18,11 +18,11 @@ files = [ "src/lib.rs", "Cargo.toml",] tag_prefix = "python/" [tool.poetry.dependencies] -python = "^3.6" +python = "^3.7" [tool.poetry.dev-dependencies] -pytest = "^6.0.1" -hypothesis = "^5.23.11" +pytest = "^7.2" +hypothesis = "^6.61.0" pydoc-md = "^0.1.0" [tool.pytest.ini_options] diff --git a/python/src/lib.rs b/python/src/lib.rs index 895c457..01cea7c 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -1,5 +1,5 @@ use pyo3::prelude::*; -use textspan::Span; +use textspanrs::Span; #[pymodule] fn textspan(_py: Python, m: &PyModule) -> PyResult<()> { @@ -18,15 +18,15 @@ fn textspan(_py: Python, m: &PyModule) -> PyResult<()> { /// >>> original_text = "FOo.BåR baZ"; /// >>> textspan.align_spans(spans, text, original_text) /// [[(0, 3)], [(4, 7)]] - #[pyfn(m, "align_spans")] - #[text_signature = "(spans, text, original_text)"] + #[pyfn(m)] + #[pyo3(text_signature = "(spans, text, original_text)")] pub fn align_spans( _py: Python, spans: Vec, text: &str, original_text: &str, ) -> PyResult>> { - Ok(textspan::align_spans(&spans, text, original_text)) + Ok(textspanrs::align_spans(&spans, text, original_text)) } /// Converts the spans by the given `mapping`. @@ -43,14 +43,14 @@ fn textspan(_py: Python, m: &PyModule) -> PyResult<()> { /// >>> mapping = [[0, 1], [], [2], [4, 5, 6]] /// >>> textspan.align_spans_by_mapping(spans, mapping) /// [[(0, 2)], [(4, 7)]] - #[pyfn(m, "align_spans_by_mapping")] - #[text_signature = "(spans, mapping)"] + #[pyfn(m)] + #[pyo3(text_signature = "(spans, mapping)")] pub fn align_spans_by_mapping( _py: Python, spans: Vec, mapping: Vec>, ) -> PyResult>> { - Ok(textspan::align_spans_by_mapping(&spans, &mapping)) + Ok(textspanrs::align_spans_by_mapping(&spans, &mapping)) } /// Returns the span indices of `original_text` from the tokens based on the shortest edit script (SES). @@ -64,14 +64,14 @@ fn textspan(_py: Python, m: &PyModule) -> PyResult<()> { /// >>> textspan.get_original_spans(tokens, "FO.o BåR") /// [[(0, 2), (3, 4)], [(6, 9)]] /// - #[pyfn(m, "get_original_spans")] - #[text_signature = "(tokens, original_text)"] + #[pyfn(m)] + #[pyo3(text_signature = "(tokens, original_text)")] pub fn get_original_spans( _py: Python, tokens: Vec<&str>, original_text: &str, ) -> PyResult>> { - Ok(textspan::get_original_spans(&tokens, original_text)) + Ok(textspanrs::get_original_spans(&tokens, original_text)) } /// Remove overlapping spans from given `spans`. @@ -86,10 +86,10 @@ fn textspan(_py: Python, m: &PyModule) -> PyResult<()> { /// >>> assert textspan.remove_span_overlaps(spans) == [(0, 3), (5, 7)] /// /// - #[pyfn(m, "remove_span_overlaps")] - #[text_signature = "(spans)"] + #[pyfn(m)] + #[pyo3(text_signature = "(spans)")] pub fn remove_span_overlaps(_py: Python, spans: Vec) -> PyResult> { - Ok(textspan::remove_span_overlaps(&spans)) + Ok(textspanrs::remove_span_overlaps(&spans)) } /// Remove overlapping spans from given `spans`, and returns remained span indices. @@ -104,10 +104,10 @@ fn textspan(_py: Python, m: &PyModule) -> PyResult<()> { /// >>> assert textspan.remove_span_overlaps_idx(spans) == [1, 3] /// /// - #[pyfn(m, "remove_span_overlaps_idx")] - #[text_signature = "(spans)"] + #[pyfn(m)] + #[pyo3(text_signature = "(spans)")] pub fn remove_span_overlaps_idx(_py: Python, spans: Vec) -> PyResult> { - Ok(textspan::remove_span_overlaps_idx(&spans)) + Ok(textspanrs::remove_span_overlaps_idx(&spans)) } fn to_tuple(x: Result) -> (T, bool) { @@ -121,25 +121,25 @@ fn textspan(_py: Python, m: &PyModule) -> PyResult<()> { /// >>> import textspan /// >>> spans = [(0, 3), (3, 4), (4, 9), (9, 12)] /// >>> assert textspan.lift_spans_index((2, 10), spans) == (0, 4) - #[pyfn(m, "lift_span_index")] - #[text_signature = "(span, target_spans)"] + #[pyfn(m)] + #[pyo3(text_signature = "(span, target_spans)")] pub fn lift_span_index( _py: Python, span: Span, target_spans: Vec, ) -> PyResult<((usize, bool), (usize, bool))> { - let (l, r) = textspan::lift_span_index(span, &target_spans); + let (l, r) = textspanrs::lift_span_index(span, &target_spans); Ok((to_tuple(l), to_tuple(r))) } - #[pyfn(m, "lift_spans_index")] - #[text_signature = "(spans, target_spans)"] + #[pyfn(m)] + #[pyo3(text_signature = "(spans, target_spans)")] pub fn lift_spans_index( _py: Python, spans: Vec, target_spans: Vec, ) -> PyResult> { - Ok(textspan::lift_spans_index(&spans, &target_spans) + Ok(textspanrs::lift_spans_index(&spans, &target_spans) .into_iter() .map(|(l, r)| (to_tuple(l), to_tuple(r))) .collect()) diff --git a/src/lib.rs b/src/lib.rs index b62b989..adcc609 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,13 +88,13 @@ pub fn align_spans_by_mapping>(spans: &[Span], mapping: &[T]) let mut pret = vec![]; for item in mapping.iter().take(end).skip(start) { for &y in item.as_ref() { - if prevy != None && prevy.unwrap() + 1 < y { + if prevy.is_some() && prevy.unwrap() + 1 < y { pret.push((l.unwrap(), r.unwrap())); l = None; } else { r = Some(y + 1); } - if l == None { + if l.is_none() { l = Some(y); r = Some(y + 1); } @@ -432,7 +432,7 @@ mod tests { let rev = |x: usize| mapping.iter().position(|y| y.contains(&x)).unwrap(); let l = rev(ret[0][0].0); assert!( - mapping[start].is_empty() || mapping[l].iter().any(|x| mapping[start].contains(&x)), + mapping[start].is_empty() || mapping[l].iter().any(|x| mapping[start].contains(x)), "compare start. ret: {:?} l : {} @@ -444,7 +444,7 @@ mod tests { let r = rev(ret[ret.len() - 1][ret[0].len() - 1].1 - 1); assert!( mapping[end - 1].is_empty() - || mapping[end - 1].iter().any(|x| mapping[r].contains(&x)), + || mapping[end - 1].iter().any(|x| mapping[r].contains(x)), "compare end ret: {:?} r : {}