diff --git a/.flake8 b/.flake8 index 4e3adcc4..49c91a74 100644 --- a/.flake8 +++ b/.flake8 @@ -1,3 +1,7 @@ [flake8] max-line-length = 88 -ignore = E501, E203, W503 \ No newline at end of file +ignore = E501, E203, W503 +# Exact type comparisons on purpose (pycodestyle 2.11, which Python 3.12 needs, reports them) +per-file-ignores = + pywhat/filter.py: E721 + tests/test_regex_identifier.py: E721 diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 42621d0e..d3117cac 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -43,17 +43,19 @@ jobs: id: python with: python-version: ${{ matrix.python-version }} - # The CI tooling runs on a current Python so it can be installed from - # wheels only (cffi, which Poetry needs on macOS, has no Python 3.8 arm64 - # wheels). The nox sessions still use the matrix Python (--force-python). + # nox runs on a current Python, and its sessions on the matrix Python + # (--force-python). - uses: actions/setup-python@v6 with: python-version: '3.12' - # Pinned: Poetry 2.x removed `install --no-dev` and the bundled `export` - # command. packaging 26.3+ no longer imports on Python 3.8, and Poetry - # loads its own copy inside the session's Python 3.8 environment. + # The package's extension module (py/) is Rust, which pip builds with + # maturin when the session installs the package + - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 + # virtualenv 21, which nox creates the sessions' environments with, no + # longer creates Python 3.8 ones - run: | - python -m pip install --only-binary :all: nox==2025.5.1 poetry==1.8.5 packaging==26.2 + python -m pip install --only-binary :all: nox==2025.5.1 virtualenv==20.39.1 - run: python -m nox --force-python "${{ steps.python.outputs.python-path }}" env: OS: ${{ matrix.os }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..fb97180f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,287 @@ +# The wheels and the sdist of the Python package, for every platform, and their upload to PyPI. +# +# Generated by maturin 1.16.0 (`maturin generate-ci github -o .github/workflows/release.yml`), +# then changed: +# - Wheels are built for pull requests that can change how they build (paths below) and when +# the workflow is run by hand, and kept as the run's artifacts. Version tags (like 5.1.0) +# build them too, and only tags publish them. +# - The wheels are abi3 (pyo3's abi3-py38): one wheel per platform for CPython 3.8 and newer. +# The generated free-threaded (python3.14t) builds are left out: free-threaded Python can't +# load abi3 wheels, and builds from the sdist. +# - Every wheel that the runner can run is installed and tried, and so is the sdist. +# - Actions are pinned to commits. +# - Publishing needs a PYPI_API_TOKEN secret, or PyPI trusted publishing for this workflow and +# the environment "pypi" with the repository variable PYPI_TRUSTED_PUBLISHING set to true. +# Without either, the release job only says so. +name: Release + +on: + push: + tags: + - '[0-9]*' + pull_request: + paths: + - 'Cargo.toml' + - 'Cargo.lock' + - 'src/**' + - 'py/**' + - 'pyproject.toml' + - '.github/workflows/release.yml' + workflow_dispatch: + +concurrency: + group: release-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + +env: + # What the "Try the wheel" steps run, outside the checkout (so the installed package is used). + # LICENCE_FILES are the licence files of the checkout, which the package must carry. + SMOKE_TEST: | + import os + from importlib.metadata import distribution + from pywhat import Identifier, _pywhat + found = Identifier().identify("thm{a_flag}\nbee@skerritt.blog")["Regexes"]["text"] + names = [match["Regex Pattern"]["Name"] for match in found] + assert names == ["TryHackMe Flag Format", "Email Address"], names + assert _pywhat.finditer("[0-9]+", "\u00e9 12 \u20ac345") == [(2, 4), (6, 9)] + files = distribution("pywhat").files or [] + licences = sorted(file.name for file in files if file.parent.name == "licenses") + assert licences == sorted(os.environ["LICENCE_FILES"].split()), licences + print("OK", names, licences) + +jobs: + linux: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: ubuntu-22.04 + target: x86_64 + - runner: ubuntu-22.04 + target: x86 + - runner: ubuntu-22.04 + target: aarch64 + - runner: ubuntu-22.04 + target: armv7 + - runner: ubuntu-22.04 + target: s390x + - runner: ubuntu-22.04 + target: ppc64le + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 + with: + python-version: "3.8" + - name: Build wheels + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + manylinux: auto + - name: Try the wheel + if: ${{ matrix.platform.target == 'x86_64' }} + shell: bash + run: | + # The wheel that was just built, then its dependencies (wheels only) + version=$(basename dist/*.whl | cut -d- -f2) + python -m pip install --only-binary :all: --no-index --no-deps --find-links dist "pywhat==$version" + python -m pip install --only-binary :all: "pywhat==$version" + export LICENCE_FILES="$(ls LICENSE NOTICE 2> /dev/null || true)" + cd "$RUNNER_TEMP" + python -c "$SMOKE_TEST" + pywhat --version + - name: Upload wheels + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 + with: + name: wheels-linux-${{ matrix.platform.target }} + path: dist + + musllinux: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: ubuntu-22.04 + target: x86_64 + - runner: ubuntu-22.04 + target: x86 + - runner: ubuntu-22.04 + target: aarch64 + - runner: ubuntu-22.04 + target: armv7 + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 + with: + python-version: "3.8" + - name: Build wheels + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + manylinux: musllinux_1_2 + - name: Upload wheels + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 + with: + name: wheels-musllinux-${{ matrix.platform.target }} + path: dist + + windows: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: windows-latest + target: x64 + python_arch: x64 + - runner: windows-latest + target: x86 + python_arch: x86 + - runner: windows-11-arm + target: aarch64 + python_arch: arm64 + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 + with: + python-version: "3.13" + architecture: ${{ matrix.platform.python_arch }} + - name: Build wheels + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + - name: Try the wheel + shell: bash + run: | + # The wheel that was just built, then its dependencies (wheels only) + version=$(basename dist/*.whl | cut -d- -f2) + python -m pip install --only-binary :all: --no-index --no-deps --find-links dist "pywhat==$version" + python -m pip install --only-binary :all: "pywhat==$version" + export LICENCE_FILES="$(ls LICENSE NOTICE 2> /dev/null || true)" + cd "$RUNNER_TEMP" + python -c "$SMOKE_TEST" + pywhat --version + - name: Upload wheels + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 + with: + name: wheels-windows-${{ matrix.platform.target }} + path: dist + + macos: + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + platform: + - runner: macos-15-intel + target: x86_64 + - runner: macos-latest + target: aarch64 + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 + with: + python-version: "3.8" + - name: Build wheels + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1 + with: + target: ${{ matrix.platform.target }} + args: --release --out dist + sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} + - name: Try the wheel + shell: bash + run: | + # The wheel that was just built, then its dependencies (wheels only) + version=$(basename dist/*.whl | cut -d- -f2) + python -m pip install --only-binary :all: --no-index --no-deps --find-links dist "pywhat==$version" + python -m pip install --only-binary :all: "pywhat==$version" + export LICENCE_FILES="$(ls LICENSE NOTICE 2> /dev/null || true)" + cd "$RUNNER_TEMP" + python -c "$SMOKE_TEST" + pywhat --version + - name: Upload wheels + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 + with: + name: wheels-macos-${{ matrix.platform.target }} + path: dist + + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + - name: Build sdist + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1 + with: + command: sdist + args: --out dist + # pip builds the extension from the sdist, with Rust + - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 + with: + python-version: "3.12" + - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable + - name: Try the sdist + shell: bash + run: | + # pip builds the wheel from the sdist (with maturin, without build isolation, so + # that the build runs with this maturin), then installs the dependencies + version=$(basename dist/*.tar.gz .tar.gz | cut -d- -f2) + python -m pip install --only-binary :all: maturin==1.16.0 + python -m pip install --only-binary :all: --no-binary pywhat --no-build-isolation --no-index --no-deps --find-links dist "pywhat==$version" + python -m pip install --only-binary :all: "pywhat==$version" + export LICENCE_FILES="$(ls LICENSE NOTICE 2> /dev/null || true)" + cd "$RUNNER_TEMP" + python -c "$SMOKE_TEST" + pywhat --version + - name: Upload sdist + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 + with: + name: wheels-sdist + path: dist + + release: + name: Release + runs-on: ubuntu-latest + if: ${{ startsWith(github.ref, 'refs/tags/') }} + needs: [linux, musllinux, windows, macos, sdist] + # Protection rules (such as required reviewers) of the environment apply to publishing + environment: pypi + permissions: + # Trusted publishing, and signing the attestations + id-token: write + # Used to generate artifact attestation + attestations: write + steps: + - name: Check that publishing is set up + id: setup + shell: bash + env: + PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + PYPI_TRUSTED_PUBLISHING: ${{ vars.PYPI_TRUSTED_PUBLISHING }} + run: | + if [ -n "$PYPI_API_TOKEN" ] || [ "$PYPI_TRUSTED_PUBLISHING" = true ]; then + echo "publish=true" >> "$GITHUB_OUTPUT" + else + echo "::warning::Not published: add a PYPI_API_TOKEN secret, or set up trusted publishing and the repository variable PYPI_TRUSTED_PUBLISHING=true" + fi + - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7 + if: ${{ steps.setup.outputs.publish == 'true' }} + - name: Generate artifact attestation + if: ${{ steps.setup.outputs.publish == 'true' }} + uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4 + with: + subject-path: 'wheels-*/*' + - name: Install uv + if: ${{ steps.setup.outputs.publish == 'true' }} + uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7 + - name: Publish to PyPI + if: ${{ steps.setup.outputs.publish == 'true' }} + run: uv publish 'wheels-*/*' + env: + # Empty without the secret: uv then uses trusted publishing + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.gitignore b/.gitignore index acd4b092..c1b0e962 100644 --- a/.gitignore +++ b/.gitignore @@ -24,8 +24,9 @@ __pycache__/ *$py.class tests/__pycache__/ -# C extensions +# C extensions (and the Rust one, pywhat/_pywhat.*, which pip install -e . builds) *.so +*.pyd # Distribution / packaging .Python diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dfb2f4e0..e1b87f82 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,3 +20,15 @@ Secret scanners take fake API keys, like a Stripe or Shopify key, for leaked sec ] ] ``` + +## Running the tests + +The Python package searches with the regex engine of the Rust crate at the root of the repository, through its extension module `pywhat._pywhat` (`py/`). Building it needs [Rust](https://rustup.rs): + +```console +$ pip install -r requirements.txt +$ pip install -e . # builds the extension into pywhat/; run it again after changing Rust code +$ pytest +``` + +`nox` runs the tests the way CI does. The Rust crate has tests of its own (`cargo test`), see [docs/rust.md](docs/rust.md). diff --git a/Cargo.lock b/Cargo.lock index e6691169..c0885874 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -167,6 +167,12 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hybrid-array" version = "0.4.15" @@ -224,6 +230,12 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + [[package]] name = "proc-macro2" version = "1.0.107" @@ -233,6 +245,63 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "pyo3" +version = "0.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "700d18fa267b73b9b521fd7e13580e2f446916f176cacee1ab63fcc8191f1655" +dependencies = [ + "libc", + "once_cell", + "portable-atomic", + "pyo3-build-config", + "pyo3-ffi", + "pyo3-macros", +] + +[[package]] +name = "pyo3-build-config" +version = "0.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b3fc0c4d08f6bb10e71fe39dfb9e2f59c6eb6854e22ec8092f50c69a4499adb" +dependencies = [ + "target-lexicon", +] + +[[package]] +name = "pyo3-ffi" +version = "0.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc0b8e19df29aad7086cf977bb0c2a2f143e30567eb113e9cf72b62ca698330" +dependencies = [ + "libc", + "pyo3-build-config", +] + +[[package]] +name = "pyo3-macros" +version = "0.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6100e8a4b5eba53afaa5ed078364851a0b2499c553a44c31026b929049b49dc6" +dependencies = [ + "proc-macro2", + "pyo3-macros-backend", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "pyo3-macros-backend" +version = "0.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6143877a16e82b5a727b7127ff4cd86858a24a28d745d72f43e6f227c7b1bdb3" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "pywhat" version = "6.0.0-alpha.1" @@ -249,6 +318,14 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "pywhat-py" +version = "6.0.0-alpha.1" +dependencies = [ + "pyo3", + "pywhat", +] + [[package]] name = "quote" version = "1.0.47" @@ -349,7 +426,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] @@ -378,6 +455,17 @@ dependencies = [ "digest", ] +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "3.0.9" @@ -389,6 +477,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "target-lexicon" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" + [[package]] name = "typenum" version = "1.20.1" @@ -442,7 +536,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn", + "syn 3.0.9", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index ca9614d0..6f8a4249 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,8 @@ [workspace] -members = ["."] +# py/ is the Python extension module, which maturin builds (pyproject.toml); cargo commands +# at the root leave it out +members = [".", "py"] +default-members = ["."] resolver = "2" [workspace.package] diff --git a/Dockerfile b/Dockerfile index 1c51cade..338bbcd4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,16 @@ +# The package has an extension module in Rust, so its wheel is built in an image with Rust, +# from GitHub (PYWHAT_REF: a branch, tag or commit), and installed into the Python image +FROM rust:alpine AS build +ARG PYWHAT_REF=main +RUN apk add --no-cache git musl-dev py3-pip python3 \ + && python3 -m pip wheel --no-cache-dir --no-deps --wheel-dir /wheels \ + "git+https://github.com/bee-san/pyWhat@${PYWHAT_REF}" + FROM python:3.10-alpine -RUN apk add --no-cache git \ - && pip install --no-cache-dir git+https://github.com/bee-san/pyWhat \ - && apk del git \ - && rm -rf /var/cache/apk/* +COPY --from=build /wheels /wheels +# The extension needs libgcc_s, which the wheels on PyPI carry, but this one doesn't +RUN apk add --no-cache libgcc \ + && pip install --no-cache-dir --only-binary :all: /wheels/*.whl \ + && rm -rf /wheels WORKDIR /workdir ENTRYPOINT [ "python", "-m", "pywhat" ] diff --git a/noxfile.py b/noxfile.py index 1b446389..e4b970d1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,64 +1,29 @@ -"""Nox sessions.""" -from os import environ -from typing import Any - -import nox -from nox.sessions import Session - -nox.options.sessions = ["tests"] -if environ.get("CI", None) == "true": - nox.options.sessions.append("coverage") -locations = "src", "tests", "noxfile.py", "docs/conf.py" - - -def install_with_constraints(session: Session, *args: str, **kwargs: Any) -> None: - """Install packages constrained by Poetry's lock file. - This function is a wrapper for nox.sessions.Session.install. It - invokes pip to install packages inside of the session's virtualenv. - Additionally, pip is passed a constraints file generated from - Poetry's lock file, to ensure that the packages are pinned to the - versions specified in poetry.lock. This allows you to manage the - packages as Poetry development dependencies. - Arguments: - session: The Session object. - args: Command-line arguments for pip. - kwargs: Additional keyword arguments for Session.install. - """ - session.run( - "poetry", - "export", - "--without-hashes", - "--with", - "dev", - "--format=requirements.txt", - "--output=requirements.txt", - external=True, - ) - session.install("--constraint=requirements.txt", *args, **kwargs) - - -@nox.session -def tests(session: Session) -> None: - """Run the test suite.""" - session.run("poetry", "install", "--only", "main", external=True) - install_with_constraints( - session, - "pytest", - "pytest-black", - # pytest-cov is not in poetry.lock; newer releases need pluggy>=1.2, - # which conflicts with the locked pytest 7.1 / pluggy 1.0. - "pytest-cov==5.0.0", - "pytest-isort", - "pytest-flake8", - "pytest-mypy", - "types-requests", - "types-orjson", - ) - session.run("pytest", "--cov=./", "--cov-report=xml") - - -@nox.session -def coverage(session: Session) -> None: - """Upload coverage data.""" - install_with_constraints(session, "codecov") - session.run("codecov", "--env", "OS", "PYTHON") +"""Nox sessions.""" +from os import environ + +import nox +from nox.sessions import Session + +nox.options.sessions = ["tests"] +if environ.get("CI", None) == "true": + nox.options.sessions.append("coverage") + + +@nox.session +def tests(session: Session) -> None: + """Run the test suite, on the Rust engine.""" + # The tools, at the versions in requirements.txt (see requirements.in) + session.install("-r", "requirements.txt") + # Builds the extension module pywhat._pywhat with maturin, which needs a Rust + # toolchain (cargo). pytest imports pywhat from the checkout, which comes first on + # sys.path, so the install is editable: maturin puts the extension into pywhat/, + # and the coverage is that of the files of the checkout. + session.install("-e", ".") + session.run("pytest", "--cov=./", "--cov-report=xml") + + +@nox.session +def coverage(session: Session) -> None: + """Upload coverage data.""" + session.install("--constraint=requirements.txt", "codecov") + session.run("codecov", "--env", "OS", "PYTHON") diff --git a/poetry.lock b/poetry.lock deleted file mode 100644 index 53511c4a..00000000 --- a/poetry.lock +++ /dev/null @@ -1,770 +0,0 @@ -[[package]] -name = "atomicwrites" -version = "1.4.0" -description = "Atomic file writes." -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" - -[[package]] -name = "attrs" -version = "21.4.0" -description = "Classes Without Boilerplate" -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" - -[package.extras] -dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"] -docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"] -tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"] -tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"] - -[[package]] -name = "black" -version = "22.3.0" -description = "The uncompromising code formatter." -category = "dev" -optional = false -python-versions = ">=3.6.2" - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typed-ast = {version = ">=1.4.2", markers = "python_version < \"3.8\" and implementation_name == \"cpython\""} -typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - -[[package]] -name = "certifi" -version = "2021.10.8" -description = "Python package for providing Mozilla's CA Bundle." -category = "dev" -optional = false -python-versions = "*" - -[[package]] -name = "charset-normalizer" -version = "2.0.12" -description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -category = "dev" -optional = false -python-versions = ">=3.5.0" - -[package.extras] -unicode_backport = ["unicodedata2"] - -[[package]] -name = "click" -version = "8.1.2" -description = "Composable command line interface toolkit" -category = "main" -optional = false -python-versions = ">=3.7" - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} - -[[package]] -name = "colorama" -version = "0.4.4" -description = "Cross-platform colored terminal text." -category = "main" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" - -[[package]] -name = "commonmark" -version = "0.9.1" -description = "Python parser for the CommonMark Markdown spec" -category = "main" -optional = false -python-versions = "*" - -[package.extras] -test = ["flake8 (==3.7.8)", "hypothesis (==3.55.3)"] - -[[package]] -name = "filelock" -version = "3.6.0" -description = "A platform independent file lock." -category = "dev" -optional = false -python-versions = ">=3.7" - -[package.extras] -docs = ["furo (>=2021.8.17b43)", "sphinx (>=4.1)", "sphinx-autodoc-typehints (>=1.12)"] -testing = ["covdefaults (>=1.2.0)", "coverage (>=4)", "pytest (>=4)", "pytest-cov", "pytest-timeout (>=1.4.2)"] - -[[package]] -name = "flake8" -version = "4.0.1" -description = "the modular source code checker: pep8 pyflakes and co" -category = "dev" -optional = false -python-versions = ">=3.6" - -[package.dependencies] -importlib-metadata = {version = "<4.3", markers = "python_version < \"3.8\""} -mccabe = ">=0.6.0,<0.7.0" -pycodestyle = ">=2.8.0,<2.9.0" -pyflakes = ">=2.4.0,<2.5.0" - -[[package]] -name = "idna" -version = "3.3" -description = "Internationalized Domain Names in Applications (IDNA)" -category = "dev" -optional = false -python-versions = ">=3.5" - -[[package]] -name = "importlib-metadata" -version = "4.2.0" -description = "Read metadata from Python packages" -category = "main" -optional = false -python-versions = ">=3.6" - -[package.dependencies] -typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} -zipp = ">=0.5" - -[package.extras] -docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] -testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"] - -[[package]] -name = "iniconfig" -version = "1.1.1" -description = "iniconfig: brain-dead simple config-ini parsing" -category = "dev" -optional = false -python-versions = "*" - -[[package]] -name = "isort" -version = "5.10.1" -description = "A Python utility / library to sort Python imports." -category = "dev" -optional = false -python-versions = ">=3.6.1,<4.0" - -[package.extras] -pipfile_deprecated_finder = ["pipreqs", "requirementslib"] -requirements_deprecated_finder = ["pipreqs", "pip-api"] -colors = ["colorama (>=0.4.3,<0.5.0)"] -plugins = ["setuptools"] - -[[package]] -name = "mccabe" -version = "0.6.1" -description = "McCabe checker, plugin for flake8" -category = "dev" -optional = false -python-versions = "*" - -[[package]] -name = "mypy" -version = "0.942" -description = "Optional static typing for Python" -category = "dev" -optional = false -python-versions = ">=3.6" - -[package.dependencies] -mypy-extensions = ">=0.4.3" -tomli = ">=1.1.0" -typed-ast = {version = ">=1.4.0,<2", markers = "python_version < \"3.8\""} -typing-extensions = ">=3.10" - -[package.extras] -dmypy = ["psutil (>=4.0)"] -python2 = ["typed-ast (>=1.4.0,<2)"] -reports = ["lxml"] - -[[package]] -name = "mypy-extensions" -version = "0.4.3" -description = "Experimental type system extensions for programs checked with the mypy typechecker." -category = "dev" -optional = false -python-versions = "*" - -[[package]] -name = "orjson" -version = "3.6.8" -description = "Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy" -category = "main" -optional = true -python-versions = ">=3.7" - -[[package]] -name = "packaging" -version = "21.3" -description = "Core utilities for Python packages" -category = "dev" -optional = false -python-versions = ">=3.6" - -[package.dependencies] -pyparsing = ">=2.0.2,<3.0.5 || >3.0.5" - -[[package]] -name = "pathspec" -version = "0.9.0" -description = "Utility library for gitignore style pattern matching of file paths." -category = "dev" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" - -[[package]] -name = "platformdirs" -version = "2.5.2" -description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -category = "dev" -optional = false -python-versions = ">=3.7" - -[package.extras] -docs = ["furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)", "sphinx (>=4)"] -test = ["appdirs (==1.4.4)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)", "pytest (>=6)"] - -[[package]] -name = "pluggy" -version = "1.0.0" -description = "plugin and hook calling mechanisms for python" -category = "dev" -optional = false -python-versions = ">=3.6" - -[package.dependencies] -importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} - -[package.extras] -dev = ["pre-commit", "tox"] -testing = ["pytest", "pytest-benchmark"] - -[[package]] -name = "py" -version = "1.11.0" -description = "library with cross-python path, ini-parsing, io, code, log facilities" -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" - -[[package]] -name = "pycodestyle" -version = "2.8.0" -description = "Python style guide checker" -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" - -[[package]] -name = "pyflakes" -version = "2.4.0" -description = "passive checker of Python programs" -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" - -[[package]] -name = "pygments" -version = "2.12.0" -description = "Pygments is a syntax highlighting package written in Python." -category = "main" -optional = false -python-versions = ">=3.6" - -[[package]] -name = "pyparsing" -version = "3.0.8" -description = "pyparsing module - Classes and methods to define and execute parsing grammars" -category = "dev" -optional = false -python-versions = ">=3.6.8" - -[package.extras] -diagrams = ["railroad-diagrams", "jinja2"] - -[[package]] -name = "pytest" -version = "7.1.2" -description = "pytest: simple powerful testing with Python" -category = "dev" -optional = false -python-versions = ">=3.7" - -[package.dependencies] -atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} -attrs = ">=19.2.0" -colorama = {version = "*", markers = "sys_platform == \"win32\""} -importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} -iniconfig = "*" -packaging = "*" -pluggy = ">=0.12,<2.0" -py = ">=1.8.2" -tomli = ">=1.0.0" - -[package.extras] -testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] - -[[package]] -name = "pytest-black" -version = "0.3.12" -description = "A pytest plugin to enable format checking with black" -category = "dev" -optional = false -python-versions = ">=2.7" - -[package.dependencies] -black = {version = "*", markers = "python_version >= \"3.6\""} -pytest = ">=3.5.0" -toml = "*" - -[[package]] -name = "pytest-flake8" -version = "1.1.1" -description = "pytest plugin to check FLAKE8 requirements" -category = "dev" -optional = false -python-versions = "*" - -[package.dependencies] -flake8 = ">=4.0" -pytest = ">=7.0" - -[[package]] -name = "pytest-isort" -version = "2.0.0" -description = "py.test plugin to check import ordering using isort" -category = "dev" -optional = false -python-versions = "*" - -[package.dependencies] -isort = ">=4.0" - -[package.extras] -tests = ["mock"] - -[[package]] -name = "pytest-mypy" -version = "0.8.1" -description = "Mypy static type checker plugin for Pytest" -category = "dev" -optional = false -python-versions = ">=3.5" - -[package.dependencies] -attrs = ">=19.0" -filelock = ">=3.0" -mypy = [ - {version = ">=0.500", markers = "python_version < \"3.8\""}, - {version = ">=0.700", markers = "python_version >= \"3.8\" and python_version < \"3.9\""}, - {version = ">=0.780", markers = "python_version >= \"3.9\""}, -] -pytest = ">=3.5" - -[[package]] -name = "requests" -version = "2.27.1" -description = "Python HTTP for Humans." -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" - -[package.dependencies] -certifi = ">=2017.4.17" -charset-normalizer = {version = ">=2.0.0,<2.1.0", markers = "python_version >= \"3\""} -idna = {version = ">=2.5,<4", markers = "python_version >= \"3\""} -urllib3 = ">=1.21.1,<1.27" - -[package.extras] -socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"] -use_chardet_on_py3 = ["chardet (>=3.0.2,<5)"] - -[[package]] -name = "rich" -version = "12.2.0" -description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" -category = "main" -optional = false -python-versions = ">=3.6.3,<4.0.0" - -[package.dependencies] -commonmark = ">=0.9.0,<0.10.0" -pygments = ">=2.6.0,<3.0.0" -typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.9\""} - -[package.extras] -jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"] - -[[package]] -name = "toml" -version = "0.10.2" -description = "Python Library for Tom's Obvious, Minimal Language" -category = "dev" -optional = false -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" - -[[package]] -name = "tomli" -version = "2.0.1" -description = "A lil' TOML parser" -category = "dev" -optional = false -python-versions = ">=3.7" - -[[package]] -name = "typed-ast" -version = "1.5.3" -description = "a fork of Python 2 and 3 ast modules with type comment support" -category = "dev" -optional = false -python-versions = ">=3.6" - -[[package]] -name = "types-orjson" -version = "3.6.2" -description = "Typing stubs for orjson" -category = "dev" -optional = false -python-versions = "*" - -[[package]] -name = "types-requests" -version = "2.27.20" -description = "Typing stubs for requests" -category = "dev" -optional = false -python-versions = "*" - -[package.dependencies] -types-urllib3 = "<1.27" - -[[package]] -name = "types-urllib3" -version = "1.26.13" -description = "Typing stubs for urllib3" -category = "dev" -optional = false -python-versions = "*" - -[[package]] -name = "typing-extensions" -version = "4.2.0" -description = "Backported and Experimental Type Hints for Python 3.7+" -category = "main" -optional = false -python-versions = ">=3.7" - -[[package]] -name = "urllib3" -version = "1.26.9" -description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" - -[package.extras] -brotli = ["brotlicffi (>=0.8.0)", "brotli (>=1.0.9)", "brotlipy (>=0.6.0)"] -secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] -socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] - -[[package]] -name = "zipp" -version = "3.8.0" -description = "Backport of pathlib-compatible object wrapper for zip files" -category = "main" -optional = false -python-versions = ">=3.7" - -[package.extras] -docs = ["sphinx", "jaraco.packaging (>=9)", "rst.linker (>=1.9)"] -testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)"] - -[extras] -optimize = ["orjson"] - -[metadata] -lock-version = "1.1" -python-versions = "^3.7" -content-hash = "c7df16c9b4c5c23eb5259af6d9d30561ebd28eb8f201a748f73580d1f3811245" - -[metadata.files] -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-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"}, - {file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"}, -] -black = [ - {file = "black-22.3.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:2497f9c2386572e28921fa8bec7be3e51de6801f7459dffd6e62492531c47e09"}, - {file = "black-22.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:5795a0375eb87bfe902e80e0c8cfaedf8af4d49694d69161e5bd3206c18618bb"}, - {file = "black-22.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e3556168e2e5c49629f7b0f377070240bd5511e45e25a4497bb0073d9dda776a"}, - {file = "black-22.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67c8301ec94e3bcc8906740fe071391bce40a862b7be0b86fb5382beefecd968"}, - {file = "black-22.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:fd57160949179ec517d32ac2ac898b5f20d68ed1a9c977346efbac9c2f1e779d"}, - {file = "black-22.3.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:cc1e1de68c8e5444e8f94c3670bb48a2beef0e91dddfd4fcc29595ebd90bb9ce"}, - {file = "black-22.3.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d2fc92002d44746d3e7db7cf9313cf4452f43e9ea77a2c939defce3b10b5c82"}, - {file = "black-22.3.0-cp36-cp36m-win_amd64.whl", hash = "sha256:a6342964b43a99dbc72f72812bf88cad8f0217ae9acb47c0d4f141a6416d2d7b"}, - {file = "black-22.3.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:328efc0cc70ccb23429d6be184a15ce613f676bdfc85e5fe8ea2a9354b4e9015"}, - {file = "black-22.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06f9d8846f2340dfac80ceb20200ea5d1b3f181dd0556b47af4e8e0b24fa0a6b"}, - {file = "black-22.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:ad4efa5fad66b903b4a5f96d91461d90b9507a812b3c5de657d544215bb7877a"}, - {file = "black-22.3.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:e8477ec6bbfe0312c128e74644ac8a02ca06bcdb8982d4ee06f209be28cdf163"}, - {file = "black-22.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:637a4014c63fbf42a692d22b55d8ad6968a946b4a6ebc385c5505d9625b6a464"}, - {file = "black-22.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:863714200ada56cbc366dc9ae5291ceb936573155f8bf8e9de92aef51f3ad0f0"}, - {file = "black-22.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10dbe6e6d2988049b4655b2b739f98785a884d4d6b85bc35133a8fb9a2233176"}, - {file = "black-22.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:cee3e11161dde1b2a33a904b850b0899e0424cc331b7295f2a9698e79f9a69a0"}, - {file = "black-22.3.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:5891ef8abc06576985de8fa88e95ab70641de6c1fca97e2a15820a9b69e51b20"}, - {file = "black-22.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:30d78ba6bf080eeaf0b7b875d924b15cd46fec5fd044ddfbad38c8ea9171043a"}, - {file = "black-22.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ee8f1f7228cce7dffc2b464f07ce769f478968bfb3dd1254a4c2eeed84928aad"}, - {file = "black-22.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6ee227b696ca60dd1c507be80a6bc849a5a6ab57ac7352aad1ffec9e8b805f21"}, - {file = "black-22.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:9b542ced1ec0ceeff5b37d69838106a6348e60db7b8fdd245294dc1d26136265"}, - {file = "black-22.3.0-py3-none-any.whl", hash = "sha256:bc58025940a896d7e5356952228b68f793cf5fcb342be703c3a2669a1488cb72"}, - {file = "black-22.3.0.tar.gz", hash = "sha256:35020b8886c022ced9282b51b5a875b6d1ab0c387b31a065b84db7c33085ca79"}, -] -certifi = [ - {file = "certifi-2021.10.8-py2.py3-none-any.whl", hash = "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"}, - {file = "certifi-2021.10.8.tar.gz", hash = "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872"}, -] -charset-normalizer = [ - {file = "charset-normalizer-2.0.12.tar.gz", hash = "sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597"}, - {file = "charset_normalizer-2.0.12-py3-none-any.whl", hash = "sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df"}, -] -click = [ - {file = "click-8.1.2-py3-none-any.whl", hash = "sha256:24e1a4a9ec5bf6299411369b208c1df2188d9eb8d916302fe6bf03faed227f1e"}, - {file = "click-8.1.2.tar.gz", hash = "sha256:479707fe14d9ec9a0757618b7a100a0ae4c4e236fac5b7f80ca68028141a1a72"}, -] -colorama = [ - {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, - {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, -] -commonmark = [ - {file = "commonmark-0.9.1-py2.py3-none-any.whl", hash = "sha256:da2f38c92590f83de410ba1a3cbceafbc74fee9def35f9251ba9a971d6d66fd9"}, - {file = "commonmark-0.9.1.tar.gz", hash = "sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"}, -] -filelock = [ - {file = "filelock-3.6.0-py3-none-any.whl", hash = "sha256:f8314284bfffbdcfa0ff3d7992b023d4c628ced6feb957351d4c48d059f56bc0"}, - {file = "filelock-3.6.0.tar.gz", hash = "sha256:9cd540a9352e432c7246a48fe4e8712b10acb1df2ad1f30e8c070b82ae1fed85"}, -] -flake8 = [ - {file = "flake8-4.0.1-py2.py3-none-any.whl", hash = "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d"}, - {file = "flake8-4.0.1.tar.gz", hash = "sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"}, -] -idna = [ - {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, - {file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, -] -importlib-metadata = [ - {file = "importlib_metadata-4.2.0-py3-none-any.whl", hash = "sha256:057e92c15bc8d9e8109738a48db0ccb31b4d9d5cfbee5a8670879a30be66304b"}, - {file = "importlib_metadata-4.2.0.tar.gz", hash = "sha256:b7e52a1f8dec14a75ea73e0891f3060099ca1d8e6a462a4dff11c3e119ea1b31"}, -] -iniconfig = [ - {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, - {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, -] -isort = [ - {file = "isort-5.10.1-py3-none-any.whl", hash = "sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7"}, - {file = "isort-5.10.1.tar.gz", hash = "sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951"}, -] -mccabe = [ - {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, - {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, -] -mypy = [ - {file = "mypy-0.942-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:5bf44840fb43ac4074636fd47ee476d73f0039f4f54e86d7265077dc199be24d"}, - {file = "mypy-0.942-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:dcd955f36e0180258a96f880348fbca54ce092b40fbb4b37372ae3b25a0b0a46"}, - {file = "mypy-0.942-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6776e5fa22381cc761df53e7496a805801c1a751b27b99a9ff2f0ca848c7eca0"}, - {file = "mypy-0.942-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:edf7237137a1a9330046dbb14796963d734dd740a98d5e144a3eb1d267f5f9ee"}, - {file = "mypy-0.942-cp310-cp310-win_amd64.whl", hash = "sha256:64235137edc16bee6f095aba73be5334677d6f6bdb7fa03cfab90164fa294a17"}, - {file = "mypy-0.942-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b840cfe89c4ab6386c40300689cd8645fc8d2d5f20101c7f8bd23d15fca14904"}, - {file = "mypy-0.942-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:2b184db8c618c43c3a31b32ff00cd28195d39e9c24e7c3b401f3db7f6e5767f5"}, - {file = "mypy-0.942-cp36-cp36m-win_amd64.whl", hash = "sha256:1a0459c333f00e6a11cbf6b468b870c2b99a906cb72d6eadf3d1d95d38c9352c"}, - {file = "mypy-0.942-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:4c3e497588afccfa4334a9986b56f703e75793133c4be3a02d06a3df16b67a58"}, - {file = "mypy-0.942-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6f6ad963172152e112b87cc7ec103ba0f2db2f1cd8997237827c052a3903eaa6"}, - {file = "mypy-0.942-cp37-cp37m-win_amd64.whl", hash = "sha256:0e2dd88410937423fba18e57147dd07cd8381291b93d5b1984626f173a26543e"}, - {file = "mypy-0.942-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:246e1aa127d5b78488a4a0594bd95f6d6fb9d63cf08a66dafbff8595d8891f67"}, - {file = "mypy-0.942-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d8d3ba77e56b84cd47a8ee45b62c84b6d80d32383928fe2548c9a124ea0a725c"}, - {file = "mypy-0.942-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:2bc249409a7168d37c658e062e1ab5173300984a2dada2589638568ddc1db02b"}, - {file = "mypy-0.942-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:9521c1265ccaaa1791d2c13582f06facf815f426cd8b07c3a485f486a8ffc1f3"}, - {file = "mypy-0.942-cp38-cp38-win_amd64.whl", hash = "sha256:e865fec858d75b78b4d63266c9aff770ecb6a39dfb6d6b56c47f7f8aba6baba8"}, - {file = "mypy-0.942-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:6ce34a118d1a898f47def970a2042b8af6bdcc01546454726c7dd2171aa6dfca"}, - {file = "mypy-0.942-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:10daab80bc40f84e3f087d896cdb53dc811a9f04eae4b3f95779c26edee89d16"}, - {file = "mypy-0.942-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3841b5433ff936bff2f4dc8d54cf2cdbfea5d8e88cedfac45c161368e5770ba6"}, - {file = "mypy-0.942-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6f7106cbf9cc2f403693bf50ed7c9fa5bb3dfa9007b240db3c910929abe2a322"}, - {file = "mypy-0.942-cp39-cp39-win_amd64.whl", hash = "sha256:7742d2c4e46bb5017b51c810283a6a389296cda03df805a4f7869a6f41246534"}, - {file = "mypy-0.942-py3-none-any.whl", hash = "sha256:a1b383fe99678d7402754fe90448d4037f9512ce70c21f8aee3b8bf48ffc51db"}, - {file = "mypy-0.942.tar.gz", hash = "sha256:17e44649fec92e9f82102b48a3bf7b4a5510ad0cd22fa21a104826b5db4903e2"}, -] -mypy-extensions = [ - {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, - {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, -] -orjson = [ - {file = "orjson-3.6.8-cp310-cp310-macosx_10_7_x86_64.whl", hash = "sha256:3a287a650458de2211db03681b71c3e5cb2212b62f17a39df8ad99fc54855d0f"}, - {file = "orjson-3.6.8-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:5204e25c12cea58e524fc82f7c27ed0586f592f777b33075a92ab7b3eb3687c2"}, - {file = "orjson-3.6.8-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:77e8386393add64f959c044e0fb682364fd0e611a6f477aa13f0e6a733bd6a28"}, - {file = "orjson-3.6.8-cp310-cp310-manylinux_2_24_aarch64.whl", hash = "sha256:279f2d2af393fdf8601020744cb206b91b54ad60fb8401e0761819c7bda1f4e4"}, - {file = "orjson-3.6.8-cp310-cp310-manylinux_2_24_x86_64.whl", hash = "sha256:c31c9f389be7906f978ed4192eb58a4b74a37ad60556a0b88ddc47c576697770"}, - {file = "orjson-3.6.8-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:0db5c5a0c5b89f092d52f6e5a3701660a9d6ffa9e2968b3ce17c2bc4f5eb0414"}, - {file = "orjson-3.6.8-cp310-none-win_amd64.whl", hash = "sha256:eb22485847b9a0c4bbedc668df860126ac931edbed1d456cf41a59f3cb961ed8"}, - {file = "orjson-3.6.8-cp37-cp37m-macosx_10_7_x86_64.whl", hash = "sha256:1a5fe569310bc819279bd4d5f2c349910b104ed3207936246dd5d5e0b085e74a"}, - {file = "orjson-3.6.8-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:ccb356a47ab1067cd3549847e9db1d279a63fe0482d315b3ffd6e7abef35ef77"}, - {file = "orjson-3.6.8-cp37-cp37m-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ab29c069c222248ce302a25855b4e1664f9436e8ae5a131fb0859daf31676d2b"}, - {file = "orjson-3.6.8-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9d2b5e4cba9e774ac011071d9d27760f97f4b8cd46003e971d122e712f971345"}, - {file = "orjson-3.6.8-cp37-cp37m-manylinux_2_24_aarch64.whl", hash = "sha256:c311ec504414d22834d5b972a209619925b48263856a11a14d90230f9682d49c"}, - {file = "orjson-3.6.8-cp37-cp37m-manylinux_2_24_x86_64.whl", hash = "sha256:a3dfec7950b90fb8d143743503ee53fa06b32e6068bdea792fc866284da3d71d"}, - {file = "orjson-3.6.8-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:b890dbbada2cbb26eb29bd43a848426f007f094bb0758df10dfe7a438e1cb4b4"}, - {file = "orjson-3.6.8-cp37-none-win_amd64.whl", hash = "sha256:9143ae2c52771525be9ad11a7a8cc8e7fd75391b107e7e644a9e0050496f6b4f"}, - {file = "orjson-3.6.8-cp38-cp38-macosx_10_7_x86_64.whl", hash = "sha256:33a82199fd42f6436f833e210ae5129c922a5c355629356ca7a8e82964da7285"}, - {file = "orjson-3.6.8-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:90159ea8b9a5a2a98fa33dc7b421cfac4d2ae91ba5e1058f5909e7f059f6b467"}, - {file = "orjson-3.6.8-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:656fbe15d9ef0733e740d9def78f4fdb4153102f4836ee774a05123499005931"}, - {file = "orjson-3.6.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7be3be6153843e0f01351b1313a5ad4723595427680dac2dfff22a37e652ce02"}, - {file = "orjson-3.6.8-cp38-cp38-manylinux_2_24_aarch64.whl", hash = "sha256:dd24f66b6697ee7424f7da575ec6cbffc8ede441114d53470949cda4d97c6e56"}, - {file = "orjson-3.6.8-cp38-cp38-manylinux_2_24_x86_64.whl", hash = "sha256:b07c780f7345ecf5901356dc21dee0669defc489c38ce7b9ab0f5e008cc0385c"}, - {file = "orjson-3.6.8-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:ea32015a5d8a4ce00d348a0de5dc7040e0ad58f970a8fcbb5713a1eac129e493"}, - {file = "orjson-3.6.8-cp38-none-win_amd64.whl", hash = "sha256:c5a3e382194c838988ec128a26b08aa92044e5e055491cc4056142af0c1c54d7"}, - {file = "orjson-3.6.8-cp39-cp39-macosx_10_7_x86_64.whl", hash = "sha256:83a8424e857ae1bf53530e88b4eb2f16ca2b489073b924e655f1575cacd7f52a"}, - {file = "orjson-3.6.8-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:81e1a6a2d67f15007dadacbf9ba5d3d79237e5e33786c028557fe5a2b72f1c9a"}, - {file = "orjson-3.6.8-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:137b539881c77866eba86ff6a11df910daf2eb9ab8f1acae62f879e83d7c38af"}, - {file = "orjson-3.6.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2cbd358f3b3ad539a27e36900e8e7d172d0e1b72ad9dd7d69544dcbc0f067ee7"}, - {file = "orjson-3.6.8-cp39-cp39-manylinux_2_24_aarch64.whl", hash = "sha256:6ab94701542d40b90903ecfc339333f458884979a01cb9268bc662cc67a5f6d8"}, - {file = "orjson-3.6.8-cp39-cp39-manylinux_2_24_x86_64.whl", hash = "sha256:32b6f26593a9eb606b40775826beb0dac152e3d224ea393688fced036045a821"}, - {file = "orjson-3.6.8-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:afd9e329ebd3418cac3cd747769b1d52daa25fa672bbf414ab59f0e0881b32b9"}, - {file = "orjson-3.6.8-cp39-none-win_amd64.whl", hash = "sha256:0c89b419914d3d1f65a1b0883f377abe42a6e44f6624ba1c63e8846cbfc2fa60"}, - {file = "orjson-3.6.8.tar.gz", hash = "sha256:e19d23741c5de13689bb316abfccea15a19c264e3ec8eb332a5319a583595ace"}, -] -packaging = [ - {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, - {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, -] -pathspec = [ - {file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"}, - {file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"}, -] -platformdirs = [ - {file = "platformdirs-2.5.2-py3-none-any.whl", hash = "sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788"}, - {file = "platformdirs-2.5.2.tar.gz", hash = "sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19"}, -] -pluggy = [ - {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, - {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, -] -py = [ - {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, - {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, -] -pycodestyle = [ - {file = "pycodestyle-2.8.0-py2.py3-none-any.whl", hash = "sha256:720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20"}, - {file = "pycodestyle-2.8.0.tar.gz", hash = "sha256:eddd5847ef438ea1c7870ca7eb78a9d47ce0cdb4851a5523949f2601d0cbbe7f"}, -] -pyflakes = [ - {file = "pyflakes-2.4.0-py2.py3-none-any.whl", hash = "sha256:3bb3a3f256f4b7968c9c788781e4ff07dce46bdf12339dcda61053375426ee2e"}, - {file = "pyflakes-2.4.0.tar.gz", hash = "sha256:05a85c2872edf37a4ed30b0cce2f6093e1d0581f8c19d7393122da7e25b2b24c"}, -] -pygments = [ - {file = "Pygments-2.12.0-py3-none-any.whl", hash = "sha256:dc9c10fb40944260f6ed4c688ece0cd2048414940f1cea51b8b226318411c519"}, - {file = "Pygments-2.12.0.tar.gz", hash = "sha256:5eb116118f9612ff1ee89ac96437bb6b49e8f04d8a13b514ba26f620208e26eb"}, -] -pyparsing = [ - {file = "pyparsing-3.0.8-py3-none-any.whl", hash = "sha256:ef7b523f6356f763771559412c0d7134753f037822dad1b16945b7b846f7ad06"}, - {file = "pyparsing-3.0.8.tar.gz", hash = "sha256:7bf433498c016c4314268d95df76c81b842a4cb2b276fa3312cfb1e1d85f6954"}, -] -pytest = [ - {file = "pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"}, - {file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"}, -] -pytest-black = [ - {file = "pytest-black-0.3.12.tar.gz", hash = "sha256:1d339b004f764d6cd0f06e690f6dd748df3d62e6fe1a692d6a5500ac2c5b75a5"}, -] -pytest-flake8 = [ - {file = "pytest-flake8-1.1.1.tar.gz", hash = "sha256:ba4f243de3cb4c2486ed9e70752c80dd4b636f7ccb27d4eba763c35ed0cd316e"}, - {file = "pytest_flake8-1.1.1-py2.py3-none-any.whl", hash = "sha256:e0661a786f8cbf976c185f706fdaf5d6df0b1667c3bcff8e823ba263618627e7"}, -] -pytest-isort = [ - {file = "pytest-isort-2.0.0.tar.gz", hash = "sha256:821a8c5c9c4f3a3c52cfa9c541fbe89ac9e28728125125af53724c4c3f129117"}, - {file = "pytest_isort-2.0.0-py3-none-any.whl", hash = "sha256:ab949c593213dad38ba75db32a0ce361fcddd11d4152be4a2c93b85104cc4376"}, -] -pytest-mypy = [ - {file = "pytest-mypy-0.8.1.tar.gz", hash = "sha256:1fa55723a4bf1d054fcba1c3bd694215a2a65cc95ab10164f5808afd893f3b11"}, - {file = "pytest_mypy-0.8.1-py3-none-any.whl", hash = "sha256:6e68e8eb7ceeb7d1c83a1590912f784879f037b51adfb9c17b95c6b2fc57466b"}, -] -requests = [ - {file = "requests-2.27.1-py2.py3-none-any.whl", hash = "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d"}, - {file = "requests-2.27.1.tar.gz", hash = "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61"}, -] -rich = [ - {file = "rich-12.2.0-py3-none-any.whl", hash = "sha256:c50f3d253bc6a9bb9c79d61a26d510d74abdf1b16881260fab5edfc3edfb082f"}, - {file = "rich-12.2.0.tar.gz", hash = "sha256:ea74bc9dad9589d8eea3e3fd0b136d8bf6e428888955f215824c2894f0da8b47"}, -] -toml = [ - {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, - {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, -] -tomli = [ - {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, - {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, -] -typed-ast = [ - {file = "typed_ast-1.5.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9ad3b48cf2b487be140072fb86feff36801487d4abb7382bb1929aaac80638ea"}, - {file = "typed_ast-1.5.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:542cd732351ba8235f20faa0fc7398946fe1a57f2cdb289e5497e1e7f48cfedb"}, - {file = "typed_ast-1.5.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5dc2c11ae59003d4a26dda637222d9ae924387f96acae9492df663843aefad55"}, - {file = "typed_ast-1.5.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:fd5df1313915dbd70eaaa88c19030b441742e8b05e6103c631c83b75e0435ccc"}, - {file = "typed_ast-1.5.3-cp310-cp310-win_amd64.whl", hash = "sha256:e34f9b9e61333ecb0f7d79c21c28aa5cd63bec15cb7e1310d7d3da6ce886bc9b"}, - {file = "typed_ast-1.5.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f818c5b81966d4728fec14caa338e30a70dfc3da577984d38f97816c4b3071ec"}, - {file = "typed_ast-1.5.3-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3042bfc9ca118712c9809201f55355479cfcdc17449f9f8db5e744e9625c6805"}, - {file = "typed_ast-1.5.3-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:4fff9fdcce59dc61ec1b317bdb319f8f4e6b69ebbe61193ae0a60c5f9333dc49"}, - {file = "typed_ast-1.5.3-cp36-cp36m-win_amd64.whl", hash = "sha256:8e0b8528838ffd426fea8d18bde4c73bcb4167218998cc8b9ee0a0f2bfe678a6"}, - {file = "typed_ast-1.5.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8ef1d96ad05a291f5c36895d86d1375c0ee70595b90f6bb5f5fdbee749b146db"}, - {file = "typed_ast-1.5.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ed44e81517364cb5ba367e4f68fca01fba42a7a4690d40c07886586ac267d9b9"}, - {file = "typed_ast-1.5.3-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f60d9de0d087454c91b3999a296d0c4558c1666771e3460621875021bf899af9"}, - {file = "typed_ast-1.5.3-cp37-cp37m-win_amd64.whl", hash = "sha256:9e237e74fd321a55c90eee9bc5d44be976979ad38a29bbd734148295c1ce7617"}, - {file = "typed_ast-1.5.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:ee852185964744987609b40aee1d2eb81502ae63ee8eef614558f96a56c1902d"}, - {file = "typed_ast-1.5.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:27e46cdd01d6c3a0dd8f728b6a938a6751f7bd324817501c15fb056307f918c6"}, - {file = "typed_ast-1.5.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d64dabc6336ddc10373922a146fa2256043b3b43e61f28961caec2a5207c56d5"}, - {file = "typed_ast-1.5.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:8cdf91b0c466a6c43f36c1964772918a2c04cfa83df8001ff32a89e357f8eb06"}, - {file = "typed_ast-1.5.3-cp38-cp38-win_amd64.whl", hash = "sha256:9cc9e1457e1feb06b075c8ef8aeb046a28ec351b1958b42c7c31c989c841403a"}, - {file = "typed_ast-1.5.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:e20d196815eeffb3d76b75223e8ffed124e65ee62097e4e73afb5fec6b993e7a"}, - {file = "typed_ast-1.5.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:37e5349d1d5de2f4763d534ccb26809d1c24b180a477659a12c4bde9dd677d74"}, - {file = "typed_ast-1.5.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c9f1a27592fac87daa4e3f16538713d705599b0a27dfe25518b80b6b017f0a6d"}, - {file = "typed_ast-1.5.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:8831479695eadc8b5ffed06fdfb3e424adc37962a75925668deeb503f446c0a3"}, - {file = "typed_ast-1.5.3-cp39-cp39-win_amd64.whl", hash = "sha256:20d5118e494478ef2d3a2702d964dae830aedd7b4d3b626d003eea526be18718"}, - {file = "typed_ast-1.5.3.tar.gz", hash = "sha256:27f25232e2dd0edfe1f019d6bfaaf11e86e657d9bdb7b0956db95f560cceb2b3"}, -] -types-orjson = [ - {file = "types-orjson-3.6.2.tar.gz", hash = "sha256:cf9afcc79a86325c7aff251790338109ed6f6b1bab09d2d4262dd18c85a3c638"}, - {file = "types_orjson-3.6.2-py3-none-any.whl", hash = "sha256:22ee9a79236b6b0bfb35a0684eded62ad930a88a56797fa3c449b026cf7dbfe4"}, -] -types-requests = [ - {file = "types-requests-2.27.20.tar.gz", hash = "sha256:63344573cde6c4efd44d867c0158d9fb7e6beb95721cbe9882f3f857ee8a5398"}, - {file = "types_requests-2.27.20-py3-none-any.whl", hash = "sha256:68b8de86552116424ec23b77afc925e111afb6496d3821b183b7d151b3b834d4"}, -] -types-urllib3 = [ - {file = "types-urllib3-1.26.13.tar.gz", hash = "sha256:40f8fb5e8cd7d57e8aefdee3fdd5e930aa1a1bb4179cdadd55226cea588af790"}, - {file = "types_urllib3-1.26.13-py3-none-any.whl", hash = "sha256:ff7500641824f881b2c7bde4cc57e6c3abf03d1e005bae83aca752e77213a5da"}, -] -typing-extensions = [ - {file = "typing_extensions-4.2.0-py3-none-any.whl", hash = "sha256:6657594ee297170d19f67d55c05852a874e7eb634f4f753dbd667855e07c1708"}, - {file = "typing_extensions-4.2.0.tar.gz", hash = "sha256:f1c24655a0da0d1b67f07e17a5e6b2a105894e6824b92096378bb3668ef02376"}, -] -urllib3 = [ - {file = "urllib3-1.26.9-py2.py3-none-any.whl", hash = "sha256:44ece4d53fb1706f667c9bd1c648f5469a2ec925fcf3a776667042d645472c14"}, - {file = "urllib3-1.26.9.tar.gz", hash = "sha256:aabaf16477806a5e1dd19aa41f8c2b7950dd3c746362d7e3223dbe6de6ac448e"}, -] -zipp = [ - {file = "zipp-3.8.0-py3-none-any.whl", hash = "sha256:c4f6e5bbf48e74f7a38e7cc5b0480ff42b0ae5178957d564d18932525d5cf099"}, - {file = "zipp-3.8.0.tar.gz", hash = "sha256:56bf8aadb83c24db6c4b577e13de374ccfb67da2078beba1d037c17980bf43ad"}, -] diff --git a/py/Cargo.toml b/py/Cargo.toml new file mode 100644 index 00000000..30f99549 --- /dev/null +++ b/py/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "pywhat-py" +description = "The Python bindings of the pywhat crate: the module pywhat._pywhat of the pywhat wheel" +version.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +# Built by maturin into the Python package (pyproject.toml), not published as a crate +publish = false + +[lib] +name = "_pywhat" +crate-type = ["cdylib"] + +[dependencies] +pywhat = { path = ".." } +# 0.29 is the last PyO3 that supports Python 3.8: one abi3 wheel for CPython 3.8 and newer +pyo3 = { version = "0.29.3", features = ["abi3-py38"] } diff --git a/py/src/lib.rs b/py/src/lib.rs new file mode 100644 index 00000000..070daaa8 --- /dev/null +++ b/py/src/lib.rs @@ -0,0 +1,167 @@ +//! The module `pywhat._pywhat` of the Python package: the pywhat crate's regex engine. +//! +//! `pywhat.regex_identifier` searches with `finditer(pattern, text)` instead of +//! `re.finditer(pattern, text, re.MULTILINE)`, so the Python API finds what the crate's +//! `Identifier` finds, with the same engines (see `pywhat::engine`). + +use pyo3::create_exception; +use pyo3::exceptions::{PyRuntimeError, PyValueError}; +use pyo3::prelude::*; +use pyo3::types::PyString; +use pywhat::engine::Pattern; +use std::collections::HashMap; +use std::sync::{Arc, LazyLock, Mutex, PoisonError}; + +create_exception!( + pywhat._pywhat, + MatchError, + PyRuntimeError, + "fancy-regex gave up on a search: it backtracked more than 100,000,000 times." +); + +/// A compiled pattern, or why it can't be compiled. +type Compiled = Result, String>; + +/// The patterns compiled so far, by pattern. +static PATTERNS: LazyLock>> = LazyLock::new(Mutex::default); + +/// The most patterns kept compiled. regex.json has about 150 regexes, in two forms each; +/// like Python's `re`, the cache starts over when it is full. +const MAX_PATTERNS: usize = 1024; + +fn compile(pattern: &str) -> Compiled { + let lock = || PATTERNS.lock().unwrap_or_else(PoisonError::into_inner); + if let Some(compiled) = lock().get(pattern) { + return compiled.clone(); + } + // Compiled without the lock: compiling a large pattern takes milliseconds + let compiled = Pattern::new(pattern).map(Arc::new).map_err(|error| error.0); + let mut patterns = lock(); + if patterns.len() >= MAX_PATTERNS { + patterns.clear(); + } + patterns.insert(pattern.to_owned(), compiled.clone()); + compiled +} + +/// Turns byte offsets in `text` into character offsets, which is what Python's `str` +/// indexes by. The spans of a search come in the order of the text, so one pass suffices. +fn to_char_offsets(text: &str, spans: &mut [(usize, usize)]) { + let (mut byte, mut chars) = (0, 0); + for (start, end) in spans.iter_mut() { + for offset in [start, end] { + if *offset < byte { + (byte, chars) = (0, 0); + } + chars += text[byte..*offset].chars().count(); + byte = *offset; + *offset = chars; + } + } +} + +/// A text encoded in UTF-8 for the engine. +struct Utf8 { + text: Box, + /// Whether every character is one byte: the offsets of bytes are those of characters. + ascii: bool, +} + +impl Utf8 { + /// Raises UnicodeEncodeError for lone surrogates, which UTF-8 can't encode. + fn new(text: &Bound<'_, PyString>) -> PyResult { + let utf8 = text.to_cow()?; + Ok(Utf8 { + ascii: utf8.len() == text.len()?, + text: utf8.into(), + }) + } +} + +/// A text, encoded once for finditer(): the searches of a text for many patterns don't +/// encode it every time. Raises UnicodeEncodeError if text isn't valid Unicode (lone +/// surrogates). +#[pyclass(frozen, module = "pywhat._pywhat")] +struct Text(Utf8); + +#[pymethods] +impl Text { + #[new] + fn new(text: &Bound<'_, PyString>) -> PyResult { + Utf8::new(text).map(Text) + } +} + +enum Error { + Pattern(String), + Match(String), +} + +fn search(py: Python<'_>, pattern: &str, text: &Utf8) -> PyResult> { + py.detach(|| { + let compiled = compile(pattern).map_err(Error::Pattern)?; + let mut spans = Vec::new(); + compiled + .find_iter(&text.text, |start, end| spans.push((start, end))) + .map_err(|error| Error::Match(error.0))?; + if !text.ascii { + to_char_offsets(&text.text, &mut spans); + } + Ok(spans) + }) + .map_err(|error| match error { + Error::Pattern(message) => PyValueError::new_err(message), + Error::Match(message) => MatchError::new_err(message), + }) +} + +/// The (start, end) character offsets of every match of pattern in text (a str, or a +/// Text), in order: the spans of re.finditer(pattern, text, re.MULTILINE), found by the +/// pywhat crate's engine. +/// +/// Raises ValueError if the engine can't compile pattern, MatchError if it gives up on the +/// search, and UnicodeEncodeError if text isn't valid Unicode (lone surrogates). +#[pyfunction] +fn finditer( + py: Python<'_>, + pattern: &Bound<'_, PyString>, + text: &Bound<'_, PyAny>, +) -> PyResult> { + let pattern = pattern.to_cow()?; + match text.cast::() { + Ok(prepared) => search(py, &pattern, &prepared.get().0), + Err(_) => search(py, &pattern, &Utf8::new(text.cast::()?)?), + } +} + +#[pymodule] +fn _pywhat(module: &Bound<'_, PyModule>) -> PyResult<()> { + module.add_function(wrap_pyfunction!(finditer, module)?)?; + module.add_class::()?; + module.add("MatchError", module.py().get_type::())?; + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::to_char_offsets; + + #[test] + fn char_offsets() { + let text = "é a€b 😀c"; + let span = |part: &str| { + let start = text.find(part).unwrap(); + (start, start + part.len()) + }; + let chars = |(start, end): (usize, usize)| { + (text[..start].chars().count(), text[..end].chars().count()) + }; + // In the order of the text, as a search finds them, and out of it + for parts in [vec!["é", "a€b", "c"], vec!["c", "é", "a€b"], vec![]] { + let mut spans: Vec<(usize, usize)> = parts.iter().map(|part| span(part)).collect(); + let expected: Vec<(usize, usize)> = spans.iter().map(|&s| chars(s)).collect(); + to_char_offsets(text, &mut spans); + assert_eq!(spans, expected, "{parts:?}"); + } + } +} diff --git a/pyproject.toml b/pyproject.toml index c70a45f8..cb823135 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,42 +1,57 @@ -[tool.poetry] +[build-system] +requires = ["maturin>=1.15,<2"] +build-backend = "maturin" + +[project] name = "pywhat" -version = "5.1.0" +# The version of the Rust workspace (Cargo.toml): 6.0.0-alpha.1 there is 6.0.0a1 here +dynamic = ["version"] description = "What is that thing?" -authors = ["Bee "] -license = "MIT" -documentation = "https://github.com/bee-san/pyWhat/wiki" +authors = [{ name = "Bee", email = "github@skerritt.blog" }] +# file_signatures.json is derived from Wikipedia: CC BY-SA 4.0 (NOTICE, issue #302) +license = "MIT AND CC-BY-SA-4.0" +license-files = ["LICENSE", "NOTICE"] readme = "README.md" +requires-python = ">=3.8" +classifiers = [ + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Programming Language :: Rust", +] +dependencies = [ + "click>=8.0.0,<9.0.0", + "rich>=11.0.0", +] -[tool.poetry.dependencies] -python = "^3.7" -click = "^8.0.0" -rich = ">=11.0.0" -orjson = {version = "^3.6.1", optional = true} - -[tool.poetry.dev-dependencies] -pytest = "^7.0" -black = "^22.1.0" -isort = "^5.9.3" -flake8 = "^4.0" -requests = "^2.26.0" -pytest-black = "^0.3.12" -pytest-isort = "^2.0.0" -pytest-flake8 = "^1.0.7" -pytest-mypy = "^0.8.1" -types-requests = "^2.25.9" -types-orjson = "^3.6.0" - -[tool.poetry.extras] -optimize = ["orjson"] - -[build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" +[project.optional-dependencies] +optimize = ["orjson>=3.6.1,<4.0.0"] -[tool.poetry.scripts] +[project.scripts] pywhat = "pywhat.what:main" what = "pywhat.what:main" +[project.urls] +Documentation = "https://github.com/bee-san/pyWhat/wiki" + +[tool.maturin] +# The extension module pywhat._pywhat (py/), in the Python package pywhat/ +manifest-path = "py/Cargo.toml" +python-source = "." +module-name = "pywhat._pywhat" +strip = true +# Cargo.toml names the crate's benches and examples, and cargo can't read it without their +# files (cargo package leaves them out of the crate, but the sdist builds from Cargo.toml) +include = [ + { path = "benches/**/*.rs", format = "sdist" }, + { path = "examples/**/*.rs", format = "sdist" }, +] + [tool.isort] profile = "black" multi_line_output = 3 @@ -48,6 +63,15 @@ line_length = 88 [tool.mypy] ignore_missing_imports = true +# mypy 0.990 stopped making the arguments whose default is None Optional, which the +# code relies on (identifier.py) +implicit_optional = true + +[[tool.mypy.overrides]] +# Cmd.default() returns what onecmd() returns, a flag that stops the shell, but typeshed +# says it returns None +module = "pywhat.interactive" +disable_error_code = ["override"] [tool.pytest.ini_options] addopts = "--black --isort --flake8 --mypy" diff --git a/pywhat/__init__.py b/pywhat/__init__.py index a84355b2..23a59e7d 100644 --- a/pywhat/__init__.py +++ b/pywhat/__init__.py @@ -1,9 +1,16 @@ +from importlib.metadata import PackageNotFoundError, version + from pywhat.filter import Distribution, Filter from pywhat.helper import AvailableTags, Keys from pywhat.identifier import Identifier, Progress from pywhat.processors import Processor -__version__ = "5.0.0" +try: + # The version of the wheel, which is the version in Cargo.toml + __version__ = version(__name__) +except PackageNotFoundError: # pragma: no cover + # A checkout that isn't installed + __version__ = "unknown" tags = AvailableTags().get_tags() pywhat_tags = tags # left for backward compatibility purposes @@ -20,7 +27,7 @@ ] -del AvailableTags, filter +del AvailableTags, filter, PackageNotFoundError, version def __dir__(): diff --git a/pywhat/_pywhat.pyi b/pywhat/_pywhat.pyi new file mode 100644 index 00000000..06708dad --- /dev/null +++ b/pywhat/_pywhat.pyi @@ -0,0 +1,16 @@ +"""The Rust crate's regex engine (py/src/lib.rs).""" +from typing import List, Tuple, Union + +class MatchError(RuntimeError): + """fancy-regex gave up on a search: it backtracked more than 100,000,000 times.""" + +class Text: + """A text, encoded once for finditer().""" + + def __init__(self, text: str) -> None: ... + +def finditer(pattern: str, text: Union[str, Text]) -> List[Tuple[int, int]]: + """ + The (start, end) character offsets of every match of pattern in text, in + order, like re.finditer(pattern, text, re.MULTILINE). + """ diff --git a/pywhat/regex_identifier.py b/pywhat/regex_identifier.py index 44a8bc9f..bb746d3f 100644 --- a/pywhat/regex_identifier.py +++ b/pywhat/regex_identifier.py @@ -10,6 +10,51 @@ ) from pywhat.ranking import Span, mark_fragments +try: + # The regex engine of the Rust crate (py/ in the repository), which the wheel + # contains. An extension that is there but can't be loaded (a missing system + # library, say) is an error, not a reason to search with re. + import pywhat._pywhat as _pywhat +except ModuleNotFoundError: # pragma: no cover + # A checkout in which the extension isn't built (pip install -e . builds it) + _pywhat = None # type: ignore[assignment] + + +def _re_spans(regex: str, string: str) -> Iterator[Span]: + """The spans of the matches of regex in string, found by Python's re.""" + return (match.span() for match in re.finditer(regex, string, re.MULTILINE)) + + +def _text(string: str) -> Optional["_pywhat.Text"]: + """ + string, encoded once for the searches of the Rust engine, or None if Python's + re searches it: without the engine, or if UTF-8 can't encode string, as it + has lone surrogates (surrogateescape makes them of the bytes of command-line + arguments that aren't UTF-8). + """ + if _pywhat is None: + return None + try: + return _pywhat.Text(string) + except UnicodeEncodeError: + return None + + +def _spans(regex: str, string: str, text: Optional["_pywhat.Text"]) -> Iterable[Span]: + """ + The spans of the matches of regex in string, like re.finditer(regex, string, + re.MULTILINE), found by the Rust engine in text, the string encoded by + _text(). Python's re searches instead if text is None, if the engine can't + compile regex, or if it gives up on the search (fancy-regex's limit of + 100,000,000 backtracking steps), so that nothing is lost. + """ + if text is not None: + try: + return _pywhat.finditer(regex, text) + except (ValueError, _pywhat.MatchError): + pass + return _re_spans(regex, string) + class RegexIdentifier: def __init__(self, processors: Optional[Iterable[Processor]] = None): @@ -59,6 +104,7 @@ def iter_check( for string in text: # The matches of string, with their spans to mark the fragments found: List[Tuple[dict, Span]] = [] + encoded = _text(string) for reg in dist.get_regexes(): if progress is not None: progress(reg["Name"]) @@ -66,9 +112,9 @@ def iter_check( reg["Boundaryless Regex"] if reg in boundaryless else reg["Regex"] ) reg_processors = by_name.get(reg["Name"]) - for matched_regex in re.finditer(regex, string, re.MULTILINE): + for start, end in _spans(regex, string, encoded): reg_match = dict(reg) - matched = self.clean_text(matched_regex.group(0)) + matched = self.clean_text(string[start:end]) if ( reg_match.get("Exploit") is not None @@ -120,7 +166,7 @@ def iter_check( if reg_processors: processed = run_processors(match, reg_processors, dist) if processed is not None: - found.append((processed, matched_regex.span())) + found.append((processed, (start, end))) yield processed # Fragments of longer words or matches are less likely (issue diff --git a/requirements.in b/requirements.in new file mode 100644 index 00000000..b6fe9bd3 --- /dev/null +++ b/requirements.in @@ -0,0 +1,34 @@ +# The development tools (the package's own dependencies are in pyproject.toml). +# requirements.txt pins them and everything they need, for every Python version from 3.8 +# (the newest release that supports each version): +# +# uv pip compile --universal --python-version 3.8 requirements.in -o requirements.txt +# +# The test session in noxfile.py installs requirements.txt, then the package itself. + +# The versions of the package's own dependencies that the tests run with +click==8.1.2 +rich==12.2.0 + +# pytest and the plugins that pyproject.toml turns on. pytest-black 0.6.0, its last +# release, doesn't load on pytest 9 (its hook takes the `path` argument that pytest 9 +# removed). +pytest<9 +pytest-black +pytest-cov +pytest-flake8 +pytest-isort +pytest-mypy +# The newest versions that accept the code as it is: black 24 would reformat 23 files, and +# isort 6 and mypy 1.15 need Python 3.9 +black==23.12.1 +isort==5.13.2 +mypy==1.14.1 +types-orjson +types-requests + +# The upload of the coverage (the "coverage" session, on CI) +codecov + +# scripts/get_file_sigs.py and scripts/get_tlds.py +requests diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..2e00647f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,218 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile --universal --python-version 3.8 requirements.in -o requirements.txt +black==23.12.1 + # via + # -r requirements.in + # pytest-black +certifi==2026.10.23 + # via requests +charset-normalizer==3.5.2 + # via requests +click==8.1.2 + # via + # -r requirements.in + # black +codecov==2.1.13 + # via -r requirements.in +colorama==0.4.6 ; sys_platform == 'win32' + # via + # click + # pytest +commonmark==0.9.2 + # via rich +coverage==7.6.1 ; python_full_version < '3.9' + # via + # codecov + # pytest-cov +coverage==7.10.7 ; python_full_version == '3.9.*' + # via + # codecov + # pytest-cov +coverage==7.16.2 ; python_full_version == '3.10.*' + # via + # codecov + # pytest-cov +coverage==7.17.1 ; python_full_version >= '3.11' + # via + # codecov + # pytest-cov +exceptiongroup==1.3.1 ; python_full_version < '3.11' + # via pytest +filelock==3.16.1 ; python_full_version < '3.9' + # via pytest-mypy +filelock==3.19.1 ; python_full_version == '3.9.*' + # via pytest-mypy +filelock==4.1.0 ; python_full_version == '3.10.*' + # via pytest-mypy +filelock==4.2.9 ; python_full_version >= '3.11' + # via pytest-mypy +flake8==5.0.4 ; python_full_version < '3.9' + # via pytest-flake8 +flake8==7.3.0 ; python_full_version == '3.9.*' + # via pytest-flake8 +flake8==7.4.1 ; python_full_version == '3.10.*' + # via pytest-flake8 +flake8==7.5.0 ; python_full_version >= '3.11' + # via pytest-flake8 +idna==3.15 ; python_full_version < '3.9' + # via requests +idna==3.20 ; python_full_version >= '3.9' + # via requests +iniconfig==2.1.0 ; python_full_version < '3.10' + # via pytest +iniconfig==2.3.1 ; python_full_version >= '3.10' + # via pytest +isort==5.13.2 + # via + # -r requirements.in + # pytest-isort +mccabe==0.7.0 + # via flake8 +mypy==1.14.1 + # via + # -r requirements.in + # pytest-mypy +mypy-extensions==1.1.0 ; python_full_version < '3.10' + # via + # black + # mypy +mypy-extensions==1.2.0 ; python_full_version >= '3.10' + # via + # black + # mypy +packaging==26.2 ; python_full_version < '3.9' + # via + # black + # pytest +packaging==26.3 ; python_full_version >= '3.9' + # via + # black + # pytest +pathspec==0.12.1 ; python_full_version < '3.9' + # via black +pathspec==1.1.1 ; python_full_version >= '3.9' + # via black +platformdirs==4.3.6 ; python_full_version < '3.9' + # via black +platformdirs==4.4.0 ; python_full_version == '3.9.*' + # via black +platformdirs==4.12.4 ; python_full_version == '3.10.*' + # via black +platformdirs==4.14.5 ; python_full_version >= '3.11' + # via black +pluggy==1.5.0 ; python_full_version < '3.9' + # via pytest +pluggy==1.6.0 ; python_full_version == '3.9.*' + # via + # pytest + # pytest-cov +pluggy==1.7.0 ; python_full_version >= '3.10' + # via + # pytest + # pytest-cov +pycodestyle==2.9.1 ; python_full_version < '3.9' + # via flake8 +pycodestyle==2.14.0 ; python_full_version == '3.9.*' + # via flake8 +pycodestyle==2.15.0 ; python_full_version >= '3.10' + # via flake8 +pyflakes==2.5.0 ; python_full_version < '3.9' + # via flake8 +pyflakes==3.4.0 ; python_full_version == '3.9.*' + # via flake8 +pyflakes==4.0.3 ; python_full_version == '3.10.*' + # via flake8 +pyflakes==4.1.0 ; python_full_version >= '3.11' + # via flake8 +pygments==2.19.2 ; python_full_version < '3.9' + # via rich +pygments==2.21.0 ; python_full_version >= '3.9' + # via + # pytest + # rich +pytest==8.3.5 ; python_full_version < '3.9' + # via + # -r requirements.in + # pytest-black + # pytest-cov + # pytest-flake8 + # pytest-isort + # pytest-mypy +pytest==8.4.2 ; python_full_version >= '3.9' + # via + # -r requirements.in + # pytest-black + # pytest-cov + # pytest-flake8 + # pytest-isort + # pytest-mypy +pytest-black==0.6.0 + # via -r requirements.in +pytest-cov==5.0.0 ; python_full_version < '3.9' + # via -r requirements.in +pytest-cov==7.1.0 ; python_full_version >= '3.9' + # via -r requirements.in +pytest-flake8==1.2.2 ; python_full_version < '3.9' + # via -r requirements.in +pytest-flake8==1.3.0 ; python_full_version >= '3.9' + # via -r requirements.in +pytest-isort==4.0.0 + # via -r requirements.in +pytest-mypy==1.0.1 ; python_full_version < '3.10' + # via -r requirements.in +pytest-mypy==1.1.0 ; python_full_version >= '3.10' + # via -r requirements.in +requests==2.32.4 ; python_full_version < '3.9' + # via + # -r requirements.in + # codecov +requests==2.32.5 ; python_full_version == '3.9.*' + # via + # -r requirements.in + # codecov +requests==2.34.2 ; python_full_version >= '3.10' + # via + # -r requirements.in + # codecov +rich==12.2.0 + # via -r requirements.in +toml==0.10.2 + # via pytest-black +tomli==2.5.0 ; python_full_version < '3.11' + # via + # black + # coverage + # mypy + # pytest +types-orjson==3.6.2 + # via -r requirements.in +types-requests==2.32.0.20241016 ; python_full_version < '3.9' + # via -r requirements.in +types-requests==2.32.4.20260107 ; python_full_version == '3.9.*' + # via -r requirements.in +types-requests==2.33.0.20261030 ; python_full_version >= '3.10' + # via -r requirements.in +typing-extensions==4.13.2 ; python_full_version < '3.9' + # via + # black + # exceptiongroup + # mypy + # rich +typing-extensions==4.16.0 ; python_full_version >= '3.9' + # via + # black + # exceptiongroup + # mypy + # rich +urllib3==2.2.3 ; python_full_version < '3.9' + # via + # requests + # types-requests +urllib3==2.6.3 ; python_full_version == '3.9.*' + # via + # requests + # types-requests +urllib3==2.8.0 ; python_full_version >= '3.10' + # via + # requests + # types-requests diff --git a/scripts/golden.py b/scripts/golden.py index 6eea53c9..7ae8bebe 100644 --- a/scripts/golden.py +++ b/scripts/golden.py @@ -24,13 +24,17 @@ ROOT = Path(__file__).resolve().parent.parent sys.path.insert(0, str(ROOT)) -from pywhat import Identifier # noqa: E402 +from pywhat import Identifier, regex_identifier # noqa: E402 from pywhat.filter import Distribution, Filter # noqa: E402 from pywhat.helper import Keys, load_regexes # noqa: E402 from pywhat.printer import get_link # noqa: E402 from pywhat.processors import OpenStreetMapProcessor, default_processors # noqa: E402 from pywhat.ranking import located_matches, top_matches # noqa: E402 +# What Python's re finds, which the Rust crate is compared with: not the Rust engine, +# which the package searches with once its extension is built (pip install -e .) +regex_identifier._pywhat = None # type: ignore[assignment] + AFFIXES = [ "a", "Z", diff --git a/src/engine.rs b/src/engine.rs index 731b99e1..49e6b5b0 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -41,6 +41,61 @@ impl std::fmt::Display for MatchError { impl std::error::Error for MatchError {} +/// A pattern that neither the `regex` crate nor fancy-regex can compile. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct PatternError(pub String); + +impl std::fmt::Display for PatternError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(&self.0) + } +} + +impl std::error::Error for PatternError {} + +/// A regex compiled the way [`crate::Identifier`] compiles the regexes of regex.json, for +/// code that searches with the patterns itself (the Python package's `re.finditer`): in +/// multi-line mode (`^` and `$` match at line breaks, like `re.MULTILINE`), on the `regex` +/// crate if it can be, else guarded or on fancy-regex with its backtracking limit (see the +/// module docs). +/// +/// ``` +/// use pywhat::engine::Pattern; +/// +/// let pattern = Pattern::new(r"(? Result { + Compiled::new(pattern, true) + .map(Pattern) + .map_err(PatternError) + } + + /// Which engine the pattern runs on. + pub fn engine(&self) -> EngineKind { + self.0.engine() + } + + /// Calls `found(start, end)` with the byte offsets of every match in `text`, in order, + /// like `re.finditer(pattern, text, re.MULTILINE)`. Returns fancy-regex's error if it + /// gives up (it backtracked more than 100,000,000 times), after the matches before it. + pub fn find_iter( + &self, + text: &str, + mut found: impl FnMut(usize, usize), + ) -> Result<(), MatchError> { + self.0.find_iter(text, &mut found) + } +} + /// Which engine a pattern runs on. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum EngineKind { @@ -844,4 +899,28 @@ mod tests { // Like Python, a back-reference to a group that did not take part fails assert_eq!(spans(&compiled, "1-2-\n12\n1-2"), vec![(0, 4)]); } + + #[test] + fn patterns_compile_like_the_regexes_of_identify() { + for entry in crate::regexes() { + for (pattern, boundaryless) in + [(&entry.regex, false), (&entry.boundaryless_regex, true)] + { + let compiled = Pattern::new(pattern).unwrap(); + assert_eq!( + Ok(compiled.engine()), + crate::engine_of(entry, boundaryless), + "{}", + entry.name + ); + } + } + } + + #[test] + fn patterns_that_dont_compile() { + assert!(Pattern::new("(").is_err()); + // Python's ASCII flag + assert!(Pattern::new(r"(?a)\w").is_err()); + } } diff --git a/tests/test_rust_engine.py b/tests/test_rust_engine.py new file mode 100644 index 00000000..d9acf680 --- /dev/null +++ b/tests/test_rust_engine.py @@ -0,0 +1,155 @@ +"""The Rust engine of RegexIdentifier (pywhat._pywhat) and its fallback to re.""" +import importlib +import re +import sys +from importlib.metadata import version + +import pytest + +import pywhat +from pywhat import regex_identifier +from pywhat.filter import Distribution, Filter +from pywhat.helper import load_regexes +from pywhat.regex_identifier import RegexIdentifier + +# Text before and after the matches, and in them, that isn't ASCII: the engine +# works on UTF-8 and returns the offsets of characters, as Python counts them +TEXTS = [ + "bee@skerritt.blog thm{flag} 192.168.0.1", + "é bee@skerritt.blog 😀 192.168.0.1 中文 thm{fläg} https://example.com/ünï\n" + "4111 1111 1111 1111 ٣ 1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY €\n" + "😀😀 0x52908400098527886E0F7030069857D2E4169EE7 dQw4w9WgXcQ\n" + "2021-11-16T20:05:19Z 52.6169586, -1.9779857 ✓", +] + +# fancy-regex backtracks 20,000 times at each of the 20,000 positions of the +# first line (where the "c" is preceded by "b") and gives up; Python's re +# finds "ac" on the second line within a second +BACKTRACKING = r"[ab]*c(? Distribution: + """A distribution of the regex called name, with its regex replaced.""" + dist = Distribution(Filter({"Tags": [name]})) + (entry,) = dist.get_regexes() + dist._regexes = [{**entry, "Regex": regex, "Boundaryless Regex": regex}] + return dist + + +def test_the_rust_engine_is_used(): + assert regex_identifier._pywhat is not None, ( + "pywhat._pywhat isn't built, so the tests would run on Python's re: " + "install the package with pip install -e . (or maturin develop)" + ) + + +@pytest.mark.parametrize("text", TEXTS) +def test_the_engine_finds_what_re_finds(text): + engine = regex_identifier._pywhat + encoded = engine.Text(text) + for entry in load_regexes(): + for key in ["Regex", "Boundaryless Regex"]: + expected = [m.span() for m in re.finditer(entry[key], text, re.MULTILINE)] + assert engine.finditer(entry[key], text) == expected, (entry["Name"], key) + assert engine.finditer(entry[key], encoded) == expected, ( + entry["Name"], + key, + ) + + +def test_identify_runs_on_the_engine(re_searches): + found = RegexIdentifier().check(TEXTS, boundaryless=Filter()) + assert "thm{fläg}" in [match["Matched"] for match in found] + assert re_searches == [] + + +def test_lone_surrogates_are_searched_with_re(re_searches): + # surrogateescape gives the bytes of command-line arguments that aren't + # UTF-8 to Python as lone surrogates, which UTF-8 can't encode + with pytest.raises(UnicodeEncodeError): + regex_identifier._pywhat.Text("\udc80") + with pytest.raises(UnicodeEncodeError): + regex_identifier._pywhat.finditer("a", "a\udc80") + dist = Distribution({"Tags": ["TryHackMe Flag Format"]}) + found = RegexIdentifier().check(["\udc80\nthm{a}"], dist=dist) + assert [match["Matched"] for match in found] == ["thm{a}"] + assert len(re_searches) == len(dist.get_regexes()) + + +def test_backtracking_limit_falls_back_to_re(re_searches): + with pytest.raises(regex_identifier._pywhat.MatchError): + regex_identifier._pywhat.finditer(BACKTRACKING, BACKTRACKING_TEXT) + dist = one_regex("TryHackMe Flag Format", BACKTRACKING) + found = RegexIdentifier().check([BACKTRACKING_TEXT], dist=dist) + assert [match["Matched"] for match in found] == ["ac"] + assert re_searches == [BACKTRACKING] + + +def test_patterns_the_engine_cant_compile_fall_back_to_re(re_searches): + # Python's ASCII-only flag, which the regex crate doesn't have + pattern = r"(?a)\w+" + with pytest.raises(ValueError): + regex_identifier._pywhat.finditer(pattern, "é ab") + dist = one_regex("TryHackMe Flag Format", pattern) + found = RegexIdentifier().check(["é ab"], dist=dist) + assert [match["Matched"] for match in found] == ["ab"] + assert re_searches == [pattern] + + +def test_version_is_the_installed_one(): + assert pywhat.__version__ == version("pywhat") + + +class _Extension: + """A finder of pywhat._pywhat that fails to find it, or to load it.""" + + def __init__(self, error: ImportError): + self.error = error + + def find_spec(self, name, path=None, target=None): + if name == "pywhat._pywhat": + raise self.error + return None + + +@pytest.mark.parametrize( + "error, falls_back", + [ + # A checkout in which the extension isn't built: Python's re searches + (ModuleNotFoundError("No module named 'pywhat._pywhat'"), True), + # An extension that is there but can't be loaded is an error + (ImportError("Error loading shared library libgcc_s.so.1"), False), + ], +) +def test_without_the_extension(monkeypatch, error, falls_back): + monkeypatch.delitem(sys.modules, "pywhat._pywhat") + monkeypatch.delattr(pywhat, "_pywhat") + monkeypatch.setattr(sys, "meta_path", [_Extension(error), *sys.meta_path]) + try: + if falls_back: + importlib.reload(regex_identifier) + assert regex_identifier._pywhat is None + found = RegexIdentifier().check(["thm{a}"]) + assert [match["Matched"] for match in found] == ["thm{a}"] + else: + with pytest.raises(ImportError, match="libgcc"): + importlib.reload(regex_identifier) + finally: + monkeypatch.undo() + importlib.reload(regex_identifier) + assert regex_identifier._pywhat is not None