diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..7131543 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,35 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +# Have at most one workflow instance per PR or branch SHA +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +jobs: + test: + permissions: + contents: read + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - run: pipx install poetry==$POETRY_VERSION + env: + POETRY_VERSION: 1.8.2 + - name: Set up python + uses: actions/setup-python@v5 + with: + python-version: "3.8" + cache: poetry + - run: poetry check + - run: poetry install --no-interaction + - name: Add poetry venv to path + run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH + - run: ruff check --output-format=github . + - run: mypy + - uses: jakebailey/pyright-action@v2 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..d32dde2 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,80 @@ +name: release + +on: + push: + branches: + - main + tags: + - v* + release: + types: + - published + workflow_dispatch: + # XXX(ddn): For testing + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: hynek/build-and-inspect-python-package@v2 + + check-install: + # Create clean python environment to verify package works from scratch + runs-on: ubuntu-latest + needs: + - build + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.8' + - uses: actions/download-artifact@v4 + with: + name: Packages + path: dist + - run: pip install pyright mypy + - run: pip install ./dist/google_re2_stubs*.whl + - run: pyright tests/api + - run: mypy tests/api + + release-test-pypi: + name: Release to test.pypi.org + runs-on: ubuntu-latest + environment: test-pypi + permissions: + # Required for trusted publishing + id-token: write + needs: + - build + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + steps: + - uses: actions/download-artifact@v4 + with: + name: Packages + path: dist + - name: Upload package to test.pypi.org + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + release-pypi: + name: Release to pypi.org + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/google-re2-stubs + permissions: + # Required for trusted publishing + id-token: write + needs: + - build + if: github.event.action == 'published' + steps: + - uses: actions/download-artifact@v4 + with: + name: Packages + path: dist + - name: Upload package to pypi.org + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/README.md b/README.md new file mode 100644 index 0000000..1a2a6f4 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# google-re2-stubs [![CI](https://github.com/ddn0/google-re2-stubs/actions/workflows/ci.yaml/badge.svg)](https://github.com/ddn0/google-re2-stubs/actions/workflows/ci.yaml) + +Python stubs for [google-re2](https://github.com/google/re2) package. diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..88a724d --- /dev/null +++ b/poetry.lock @@ -0,0 +1,220 @@ +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. + +[[package]] +name = "google-re2" +version = "1.0" +description = "RE2 Python bindings" +optional = false +python-versions = "~=3.7" +files = [ + {file = "google-re2-1.0.tar.gz", hash = "sha256:21c8adc296360de1ff426baa38c712eada622c2858d195eb487e415d94194e91"}, + {file = "google_re2-1.0-1-cp310-cp310-macosx_11_0_universal2.whl", hash = "sha256:1c448df3829f4653eff97aa52bcd91871db39f326178bac7b7aafe19cf4eed70"}, + {file = "google_re2-1.0-1-cp310-cp310-macosx_12_0_universal2.whl", hash = "sha256:dd92402d4147f3e296a1b28523189283d9be84ab1b78e3f4ab337fb730bf8763"}, + {file = "google_re2-1.0-1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:8a3e0dd5e6d50d73c3e28fffd9aa37904f0ba1b085da79d826fdd3551bbdacbf"}, + {file = "google_re2-1.0-1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:caa3985049720bcdc00299cc01cfae14f7468360a830b4512bf8889507517fce"}, + {file = "google_re2-1.0-1-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:39243332e4819e4d08bf76264f9c2468893cc44060d4652999d70d8a54226da9"}, + {file = "google_re2-1.0-1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:cca03214c327506d433fafaf54781201b68e6346e891258b38946e22b7d40b56"}, + {file = "google_re2-1.0-1-cp37-cp37m-macosx_11_0_universal2.whl", hash = "sha256:4ba1c563b38d2165d7559d3c9744e3b8ecc15d622eff7bbf34a605c996c93ad8"}, + {file = "google_re2-1.0-1-cp37-cp37m-macosx_12_0_universal2.whl", hash = "sha256:4e17a5a974074a6dbc3231641775bc6f6cf3624b795bbcbacc4bf1714e1527e3"}, + {file = "google_re2-1.0-1-cp37-cp37m-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:046f038e9d4494334c9a94b413aa7ae3289b91ce3313d1493634bb9b44c080e2"}, + {file = "google_re2-1.0-1-cp37-cp37m-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:47ab6806cae6f9be44f550996a26a000ff655b8ae861d952636af47beeb29b6e"}, + {file = "google_re2-1.0-1-cp37-cp37m-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0ebe0fc67400b1adb49f0938ddae26accadd94cea64e34f296715fa84448c2e9"}, + {file = "google_re2-1.0-1-cp37-cp37m-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1d8ac79eb282f004d1bf2a231aac414089732bf210b23a6278ab339a1bee9f48"}, + {file = "google_re2-1.0-1-cp38-cp38-macosx_11_0_universal2.whl", hash = "sha256:ae77c6d3ea207e3581681f61ec81e4da9f030b61d17b04b63af81022fe7ad0e5"}, + {file = "google_re2-1.0-1-cp38-cp38-macosx_12_0_universal2.whl", hash = "sha256:46e7c280985a06434b1c63081e6d99686c750784f98bd73831869962ca9bcc2c"}, + {file = "google_re2-1.0-1-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:161f7050cf8d6480a2fa56363ae8220a75f1d5fd3c41adb1f1405757cf3edc14"}, + {file = "google_re2-1.0-1-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:1d0ac89ff672fc699c563d5f11c27277228594fa9501cb610d094d32d4c6cf2b"}, + {file = "google_re2-1.0-1-cp38-cp38-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d1d0b83c947d50e743cc28e1c2d7eb8243f4422dc84dca9035b705b9eef2c063"}, + {file = "google_re2-1.0-1-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:cfbf2b0f4295a02872c35a24e300f6b2c22d6f3e6e5a6a1ce3047e752b731b7e"}, + {file = "google_re2-1.0-1-cp39-cp39-macosx_11_0_universal2.whl", hash = "sha256:ac76e3b75af7b7a9389a2811ae605da6698403cd038a3de20aa2009978ff9b3a"}, + {file = "google_re2-1.0-1-cp39-cp39-macosx_12_0_universal2.whl", hash = "sha256:a1f2dd7adccf232790cc726ff4b6b5b0f7b4ab20e5f4655256856bdbb9094820"}, + {file = "google_re2-1.0-1-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:604ed232fc73854b6e7cb42cb9bd72055513f8f26156ab0ee661025fc061c7c3"}, + {file = "google_re2-1.0-1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:15de87bc7d9ca0e526db01ebc73062879a92071f97fb07d82ec5e499e34f92fa"}, + {file = "google_re2-1.0-1-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6f2a0bc9b63bf102b62962381c16c7a9068be3664b208f08586efa25a961913d"}, + {file = "google_re2-1.0-1-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0e921ad4ef30c27f78742936f350ebc6fa50e4505cfed98f5c1d99075497883f"}, + {file = "google_re2-1.0-2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:38b25e85b9bc714045a967f11f9563ccf418d698ebff5bdf4c1c56443fb3b82a"}, + {file = "google_re2-1.0-2-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:645f7df9dbb5d6204bb171b39c7e49d200de4cb3317c4c7dd0ebe677aaa758e3"}, + {file = "google_re2-1.0-2-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:2c4de981a3b57bb17267977ef4c33addf42d25ec6543b400a584fbf8e0a453f8"}, + {file = "google_re2-1.0-2-cp310-cp310-macosx_12_0_x86_64.whl", hash = "sha256:1dc85223cf66491eb4f1dcc270d0dc0454eaefc8352275b97647505a62ab537e"}, + {file = "google_re2-1.0-2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:a4e4bd1d93a1e76902ed68bde0fe1645c7ca649d9c11ab6c465cf29f8d267e22"}, + {file = "google_re2-1.0-2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:e56cb326158ed36f9baca5c984507951029c39021e9fe44187243cff479cb151"}, + {file = "google_re2-1.0-2-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:94880849ff4cac3234b72ab04112fe0c7f0d52558065547215844df46aa798b4"}, + {file = "google_re2-1.0-2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:04960e583e79fcae1fb05ffba95fcafb33701d26e75c6be5ee36c86b2a6bd663"}, + {file = "google_re2-1.0-2-cp310-cp310-win_amd64.whl", hash = "sha256:9af1e335ea5d43add3f6894b13a7db621ec20cfd619ddd4f6e6a7fc4ebd41f69"}, + {file = "google_re2-1.0-2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:69c94fdaf5011e5ad0900913e7d2dca08310056f378ebb29c7dfa56511eb6791"}, + {file = "google_re2-1.0-2-cp311-cp311-macosx_11_0_x86_64.whl", hash = "sha256:16dca3f18c091a83957bdaa644823447c490b67721485420b1ffed527efb2ccf"}, + {file = "google_re2-1.0-2-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:f043b10862ad996c7bfdea0c7625777412b7aa32ec6f4f37a038c47ffc2e2d76"}, + {file = "google_re2-1.0-2-cp311-cp311-macosx_12_0_x86_64.whl", hash = "sha256:2f3371c7e08e2e66586a9094c8ae0c63398491a4b386e7951eab450b504e5d17"}, + {file = "google_re2-1.0-2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:786af188ceb095717cc2dbc3256ab43c676182b67f298d739e71fc90c1ea6974"}, + {file = "google_re2-1.0-2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:0585b7c4534512527471b29c283fd7bde41a684ac5ef16332b7b817d47538e7b"}, + {file = "google_re2-1.0-2-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d597b188cd780010e737792c40145f99731a9b68cac2611c25ca1c8c9b7b7b3b"}, + {file = "google_re2-1.0-2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3618b009beb9eeb264c7b8f8855b5c6bdc811afd7eee53c00ee5d5c87d052309"}, + {file = "google_re2-1.0-2-cp311-cp311-win_amd64.whl", hash = "sha256:ebe6cd1dc3ed49aebe64925ec86eb45ebbf75b2bbfb78ef38b12c8e0c08217c9"}, + {file = "google_re2-1.0-2-cp37-cp37m-macosx_11_0_arm64.whl", hash = "sha256:f8c93ca6483a7e787ca69ac2361dcb51e89d7ae632df835b541592f9b4af3de3"}, + {file = "google_re2-1.0-2-cp37-cp37m-macosx_11_0_x86_64.whl", hash = "sha256:30f4815944ea80725b6311eb55a6eacf3e103f192a0937cd14662e250e9b5e09"}, + {file = "google_re2-1.0-2-cp37-cp37m-macosx_12_0_arm64.whl", hash = "sha256:12894f8f92ddc4e166a2b5fa173f0eb602c779e091844774b8695de0a91bb301"}, + {file = "google_re2-1.0-2-cp37-cp37m-macosx_12_0_x86_64.whl", hash = "sha256:7819e686165af66ef9979016bb25cec6a5e64ff0cf14406aeb7c63e0c47b877b"}, + {file = "google_re2-1.0-2-cp37-cp37m-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:1b431808dd59513baf0e6d0a86366e0e7aba589c02c2983e352f263470a26a52"}, + {file = "google_re2-1.0-2-cp37-cp37m-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:76024104af03c9099806c7ca5b6f3a432d553e8b40bf37356308f23490993532"}, + {file = "google_re2-1.0-2-cp37-cp37m-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6e23d685d3b4dcd7a42c06c7cda72d3edb5140690e4470343d0b8c9ea47f7f5a"}, + {file = "google_re2-1.0-2-cp37-cp37m-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5671eacb045aaf0c2e488b7bd52b2f52f5e6270b727e4335f89c75bca34f51ae"}, + {file = "google_re2-1.0-2-cp37-cp37m-win_amd64.whl", hash = "sha256:ec9a2010100ef57ca2c954d15630fe6659152a668efe221d779c06d9214379c1"}, + {file = "google_re2-1.0-2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e85c855516db6f9239ae84e35a5d081cc40a822ce882d7d3d1ef2be3b25c9d4a"}, + {file = "google_re2-1.0-2-cp38-cp38-macosx_11_0_x86_64.whl", hash = "sha256:20487b89dd43f6fe6a790bc29ac5277b8d68936876d34bfffaf04fdcb046ec1e"}, + {file = "google_re2-1.0-2-cp38-cp38-macosx_12_0_arm64.whl", hash = "sha256:b0fcb09e0ec7a16a6daa94cc0703bebc6b948f0543aa2b37941391c55326c941"}, + {file = "google_re2-1.0-2-cp38-cp38-macosx_12_0_x86_64.whl", hash = "sha256:67f292a89693234716b1450b952c93a5ec1397b32b86bd807344c9c0afc9c60e"}, + {file = "google_re2-1.0-2-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:15635fa75e8b996ce3be584ca5e783378211115d22231cb3750330455c68d473"}, + {file = "google_re2-1.0-2-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:33b4abfe90529d0eee19d6cd5dd44ba3adff40b83dd0318306a17229e4c4907e"}, + {file = "google_re2-1.0-2-cp38-cp38-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5a13a3b53bcf315f279c7a30ac05b51bfd7407cbad2c69891a87d7bce01d11e1"}, + {file = "google_re2-1.0-2-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:76ebda2a2a93c55951e35c2ee5f991232e04403e1229df70710136cfff02b552"}, + {file = "google_re2-1.0-2-cp38-cp38-win_amd64.whl", hash = "sha256:c1602d3a75e4d5cf24beeae810866ed0c7d9b981f24fce48a5b544c3a2144e84"}, + {file = "google_re2-1.0-2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:61e9c8368036c0efc8d7996af9446e87c0e67e59fcebed08c6fd85be6844cd3e"}, + {file = "google_re2-1.0-2-cp39-cp39-macosx_11_0_x86_64.whl", hash = "sha256:f026c523ad182cc2eac5f56e617f331d805699add62fd48d7cd550e44f1f63de"}, + {file = "google_re2-1.0-2-cp39-cp39-macosx_12_0_arm64.whl", hash = "sha256:24ae8918826afeb9b59f31fedb38309ad3b87626a2e15c640c288732c9a891fe"}, + {file = "google_re2-1.0-2-cp39-cp39-macosx_12_0_x86_64.whl", hash = "sha256:b6f0c72e47d9e6e772f8a8d60fce55485702e8126b09c51235c4a8c449179b49"}, + {file = "google_re2-1.0-2-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:2cd5a5268f22ee5164042452199143ef53c602c0cf3d12f039cd91d7082fa252"}, + {file = "google_re2-1.0-2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:3d9fa038be85dc181bec115490023fec072525e26a5093783e094b1ea141acab"}, + {file = "google_re2-1.0-2-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e4fee619aea3e24eeeccbaf1072d41d0e3c89a7048fb56c184e1e7d1637a11e9"}, + {file = "google_re2-1.0-2-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ae3951d28a61b3f94c51f205f4729f450636a9c856326c022e4f9577f0c3104a"}, + {file = "google_re2-1.0-2-cp39-cp39-win_amd64.whl", hash = "sha256:e86b36ac6c9bbb450b2dbec9de987ad9498b1922eaf8e7341f51dba32a966a39"}, +] + +[[package]] +name = "mypy" +version = "1.10.0" +description = "Optional static typing for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "mypy-1.10.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:da1cbf08fb3b851ab3b9523a884c232774008267b1f83371ace57f412fe308c2"}, + {file = "mypy-1.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:12b6bfc1b1a66095ab413160a6e520e1dc076a28f3e22f7fb25ba3b000b4ef99"}, + {file = "mypy-1.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9e36fb078cce9904c7989b9693e41cb9711e0600139ce3970c6ef814b6ebc2b2"}, + {file = "mypy-1.10.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:2b0695d605ddcd3eb2f736cd8b4e388288c21e7de85001e9f85df9187f2b50f9"}, + {file = "mypy-1.10.0-cp310-cp310-win_amd64.whl", hash = "sha256:cd777b780312ddb135bceb9bc8722a73ec95e042f911cc279e2ec3c667076051"}, + {file = "mypy-1.10.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3be66771aa5c97602f382230165b856c231d1277c511c9a8dd058be4784472e1"}, + {file = "mypy-1.10.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:8b2cbaca148d0754a54d44121b5825ae71868c7592a53b7292eeb0f3fdae95ee"}, + {file = "mypy-1.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1ec404a7cbe9fc0e92cb0e67f55ce0c025014e26d33e54d9e506a0f2d07fe5de"}, + {file = "mypy-1.10.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e22e1527dc3d4aa94311d246b59e47f6455b8729f4968765ac1eacf9a4760bc7"}, + {file = "mypy-1.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:a87dbfa85971e8d59c9cc1fcf534efe664d8949e4c0b6b44e8ca548e746a8d53"}, + {file = "mypy-1.10.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:a781f6ad4bab20eef8b65174a57e5203f4be627b46291f4589879bf4e257b97b"}, + {file = "mypy-1.10.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b808e12113505b97d9023b0b5e0c0705a90571c6feefc6f215c1df9381256e30"}, + {file = "mypy-1.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f55583b12156c399dce2df7d16f8a5095291354f1e839c252ec6c0611e86e2e"}, + {file = "mypy-1.10.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:4cf18f9d0efa1b16478c4c129eabec36148032575391095f73cae2e722fcf9d5"}, + {file = "mypy-1.10.0-cp312-cp312-win_amd64.whl", hash = "sha256:bc6ac273b23c6b82da3bb25f4136c4fd42665f17f2cd850771cb600bdd2ebeda"}, + {file = "mypy-1.10.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9fd50226364cd2737351c79807775136b0abe084433b55b2e29181a4c3c878c0"}, + {file = "mypy-1.10.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f90cff89eea89273727d8783fef5d4a934be2fdca11b47def50cf5d311aff727"}, + {file = "mypy-1.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fcfc70599efde5c67862a07a1aaf50e55bce629ace26bb19dc17cece5dd31ca4"}, + {file = "mypy-1.10.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:075cbf81f3e134eadaf247de187bd604748171d6b79736fa9b6c9685b4083061"}, + {file = "mypy-1.10.0-cp38-cp38-win_amd64.whl", hash = "sha256:3f298531bca95ff615b6e9f2fc0333aae27fa48052903a0ac90215021cdcfa4f"}, + {file = "mypy-1.10.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:fa7ef5244615a2523b56c034becde4e9e3f9b034854c93639adb667ec9ec2976"}, + {file = "mypy-1.10.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3236a4c8f535a0631f85f5fcdffba71c7feeef76a6002fcba7c1a8e57c8be1ec"}, + {file = "mypy-1.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a2b5cdbb5dd35aa08ea9114436e0d79aceb2f38e32c21684dcf8e24e1e92821"}, + {file = "mypy-1.10.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:92f93b21c0fe73dc00abf91022234c79d793318b8a96faac147cd579c1671746"}, + {file = "mypy-1.10.0-cp39-cp39-win_amd64.whl", hash = "sha256:28d0e038361b45f099cc086d9dd99c15ff14d0188f44ac883010e172ce86c38a"}, + {file = "mypy-1.10.0-py3-none-any.whl", hash = "sha256:f8c083976eb530019175aabadb60921e73b4f45736760826aa1689dda8208aee"}, + {file = "mypy-1.10.0.tar.gz", hash = "sha256:3d087fcbec056c4ee34974da493a826ce316947485cef3901f511848e687c131"}, +] + +[package.dependencies] +mypy-extensions = ">=1.0.0" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = ">=4.1.0" + +[package.extras] +dmypy = ["psutil (>=4.0)"] +install-types = ["pip"] +mypyc = ["setuptools (>=50)"] +reports = ["lxml"] + +[[package]] +name = "mypy-extensions" +version = "1.0.0" +description = "Type system extensions for programs checked with the mypy type checker." +optional = false +python-versions = ">=3.5" +files = [ + {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, + {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, +] + +[[package]] +name = "nodeenv" +version = "1.9.1" +description = "Node.js virtual environment builder" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9"}, + {file = "nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f"}, +] + +[[package]] +name = "pyright" +version = "1.1.365" +description = "Command line wrapper for pyright" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pyright-1.1.365-py3-none-any.whl", hash = "sha256:194d767a039f9034376b7ec8423841880ac6efdd061f3e283b4ad9fcd484a659"}, + {file = "pyright-1.1.365.tar.gz", hash = "sha256:d7e69000939aed4bf823707086c30c84c005bdd39fac2dfb370f0e5be16c2ef2"}, +] + +[package.dependencies] +nodeenv = ">=1.6.0" + +[package.extras] +all = ["twine (>=3.4.1)"] +dev = ["twine (>=3.4.1)"] + +[[package]] +name = "ruff" +version = "0.4.7" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.4.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e089371c67892a73b6bb1525608e89a2aca1b77b5440acf7a71dda5dac958f9e"}, + {file = "ruff-0.4.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:10f973d521d910e5f9c72ab27e409e839089f955be8a4c8826601a6323a89753"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:59c3d110970001dfa494bcd95478e62286c751126dfb15c3c46e7915fc49694f"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fa9773c6c00f4958f73b317bc0fd125295110c3776089f6ef318f4b775f0abe4"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07fc80bbb61e42b3b23b10fda6a2a0f5a067f810180a3760c5ef1b456c21b9db"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:fa4dafe3fe66d90e2e2b63fa1591dd6e3f090ca2128daa0be33db894e6c18648"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a7c0083febdec17571455903b184a10026603a1de078428ba155e7ce9358c5f6"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ad1b20e66a44057c326168437d680a2166c177c939346b19c0d6b08a62a37589"}, + {file = "ruff-0.4.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cbf5d818553add7511c38b05532d94a407f499d1a76ebb0cad0374e32bc67202"}, + {file = "ruff-0.4.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:50e9651578b629baec3d1513b2534de0ac7ed7753e1382272b8d609997e27e83"}, + {file = "ruff-0.4.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:8874a9df7766cb956b218a0a239e0a5d23d9e843e4da1e113ae1d27ee420877a"}, + {file = "ruff-0.4.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:b9de9a6e49f7d529decd09381c0860c3f82fa0b0ea00ea78409b785d2308a567"}, + {file = "ruff-0.4.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:13a1768b0691619822ae6d446132dbdfd568b700ecd3652b20d4e8bc1e498f78"}, + {file = "ruff-0.4.7-py3-none-win32.whl", hash = "sha256:769e5a51df61e07e887b81e6f039e7ed3573316ab7dd9f635c5afaa310e4030e"}, + {file = "ruff-0.4.7-py3-none-win_amd64.whl", hash = "sha256:9e3ab684ad403a9ed1226894c32c3ab9c2e0718440f6f50c7c5829932bc9e054"}, + {file = "ruff-0.4.7-py3-none-win_arm64.whl", hash = "sha256:10f2204b9a613988e3484194c2c9e96a22079206b22b787605c255f130db5ed7"}, + {file = "ruff-0.4.7.tar.gz", hash = "sha256:2331d2b051dc77a289a653fcc6a42cce357087c5975738157cd966590b18b5e1"}, +] + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +optional = false +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.7.1" +description = "Backported and Experimental Type Hints for Python 3.7+" +optional = false +python-versions = ">=3.7" +files = [ + {file = "typing_extensions-4.7.1-py3-none-any.whl", hash = "sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36"}, + {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"}, +] + +[metadata] +lock-version = "2.0" +python-versions = "^3.8.0" +content-hash = "b8a738977802388836f09fd0369e25d73d6623ed9e9132e2f0156b9e10a7387c" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b44fe3c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,154 @@ +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + +[tool.poetry] +# PEP-621 (standard project specification) will be part of Poetry 2.0 +# https://github.com/python-poetry/roadmap/issues/3 +# until then, use [tool.poetry] instead of [project] +name = "google-re2-stubs" +description = "Typestubs for google-re2" +authors = ["Donald Nguyen"] +license = "MIT" +version = "0.1.0" +readme = "README.md" +packages = [ + { include = "re2-stubs", from = "src" } +] + +[tool.poetry.dependencies] +google-re2 = ">=1.0" +python = "^3.8.0" + +[tool.poetry.group.dev.dependencies] +pyright = "^1.1.365" +mypy = "^1.10.0" +ruff = "^0.4.7" + +[tool.ruff] +force-exclude = true +line-length = 88 +target-version = "py38" +src = ["src", "tests"] + +[tool.ruff.lint] +select = [ + "B", + "C", + "COM", + "D", + "DTZ", + "E", + "ERA", + "EXE", + "F", + "FA", + "FBT", + "FIX", + "G", + "I", + "ICN", + "INP", + "ISC002", + "N", + "NPY", + "PD", + "PERF", + "PGH", + "PIE", + "PL", + "PLC", + "PLR", + "PT", + "PTH", + "PYI", + "Q", + "RET", + "RSE", + "RUF", + "SIM", + "SLF", + "SLOT", + "T10", + "T20", + "TD", + "TID", + "TRY", + "UP", + "W", + "YTT", +] + +ignore = [ + # Conflicts with ruff format + "COM812", + # Allow explicit concatenation + "ISC003", + # Having issue link with TODO is not necessary + "TD003", + # Allow TODO to exist + "FIX002", + # Do not complain about raising exception without arguments + "RSE102", + # Allow non-trivial exception messages + "TRY003", + # Allow use of print + "T201", + # Don't require docstrings on public methods + "D102", + # Don't require docstrings on public functions + "D103", + # Don't require docstrings on magic methods + "D105", + # Don't complain about __init__ method docstrings + "D107", + # Commented out code is allowed + "ERA001", + # We use `+` to concat long log messages across lines + "G003", +] +[tool.ruff.lint.per-file-ignores] +"src/**.pyi" = [ + "N801", + "N802", + "N818", + "FBT001", + "FBT002", +] + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.lint.pylint] +max-args = 8 + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint.pycodestyle] +max-doc-length = 88 + +[tool.ruff.lint.flake8-tidy-imports] +ban-relative-imports = "all" + +[tool.ruff.lint.isort] +known-first-party = [ + "re2", +] + +[tool.pyright] +include = ["src", "tests"] +typeCheckingMode = "strict" +# Enable additional checks beyond strict +reportCallInDefaultInitializer = "error" +reportImplicitOverride = "error" +reportImplicitStringConcatenation = "error" +reportImportCycles = "error" +reportPropertyTypeMismatch = "error" +reportShadowedImports = "error" +reportUninitializedInstanceVariable = "error" +reportUnnecessaryTypeIgnoreComment = "error" + +[tool.mypy] +strict = true +packages = "re2-stubs" diff --git a/src/re2-stubs/__init__.pyi b/src/re2-stubs/__init__.pyi new file mode 100644 index 0000000..2915770 --- /dev/null +++ b/src/re2-stubs/__init__.pyi @@ -0,0 +1,297 @@ +from typing import AnyStr, Generic, Iterator, Literal, TypeVar, overload + +# References: +# - https://github.com/google/re2/blob/main/re2/re2.h and +# - https://github.com/python/typeshed/blob/main/stdlib/re.pyi +# - and re2 implementation + +_T = TypeVar("_T") + +class error(Exception): ... + +class Options: + max_mem: int | None + encoding: int + posix_syntax: bool | None + longest_match: bool | None + log_errors: bool | None + never_nl: bool | None + dot_nl: bool | None + never_capture: bool | None + case_sensitive: bool | None + perl_classes: bool | None + word_boundary: bool | None + one_line: bool | None + +def compile( + pattern: _Regexp[AnyStr] | AnyStr, options: Options | None = None +) -> _Regexp[AnyStr]: ... +@overload +def search( + pattern: _Regexp[str] | str, text: str, options: Options | None = None +) -> _Match[str] | None: ... +@overload +def search( + pattern: _Regexp[bytes] | bytes, text: bytes, options: Options | None = None +) -> _Match[bytes] | None: ... +@overload +def match( + pattern: _Regexp[str] | str, text: str, options: Options | None = None +) -> _Match[str] | None: ... +@overload +def match( + pattern: _Regexp[bytes] | bytes, text: bytes, options: Options | None = None +) -> _Match[bytes] | None: ... +@overload +def fullmatch( + pattern: _Regexp[str] | str, text: str, options: Options | None = None +) -> _Match[str] | None: ... +@overload +def fullmatch( + pattern: _Regexp[bytes] | bytes, text: bytes, options: Options | None = None +) -> _Match[bytes] | None: ... +@overload +def finditer( + pattern: _Regexp[str] | str, text: str, options: Options | None = None +) -> Iterator[_Match[str]]: ... +@overload +def finditer( + pattern: _Regexp[bytes] | bytes, text: bytes, options: Options | None = None +) -> Iterator[_Match[bytes]]: ... +@overload +def findall( + pattern: _Regexp[str] | str, text: str, options: Options | None = None +) -> list[str]: ... +@overload +def findall( + pattern: _Regexp[bytes] | bytes, text: bytes, options: Options | None = None +) -> list[bytes]: ... +@overload +def split( + pattern: _Regexp[str] | str, + text: str, + maxsplit: int = 0, + options: Options | None = None, +) -> list[str]: ... +@overload +def split( + pattern: _Regexp[bytes] | bytes, + text: bytes, + maxsplit: int = 0, + options: Options | None = None, +) -> list[bytes]: ... +@overload +def subn( + pattern: _Regexp[str] | str, + repl: str, + text: str, + count: int = 0, + options: Options | None = None, +) -> tuple[str, int]: ... +@overload +def subn( + pattern: _Regexp[bytes] | bytes, + repl: bytes, + text: bytes, + count: int = 0, + options: Options | None = None, +) -> tuple[bytes, int]: ... +@overload +def sub( + pattern: _Regexp[str] | str, + repl: str, + text: str, + count: int = 0, + options: Options | None = None, +) -> str: ... +@overload +def sub( + pattern: _Regexp[bytes] | bytes, + repl: bytes, + text: bytes, + count: int = 0, + options: Options | None = None, +) -> bytes: ... +def escape(pattern: AnyStr) -> AnyStr: ... +def purge() -> None: ... + +class _Regexp(Generic[AnyStr]): + def __init__(self, pattern: AnyStr, options: Options) -> None: ... + @overload + def search( + self: _Regexp[str], text: str, pos: int | None = None, endpos: int | None = None + ) -> _Match[str] | None: ... + @overload + def search( + self: _Regexp[bytes], + text: bytes, + pos: int | None = None, + endpos: int | None = None, + ) -> _Match[bytes] | None: ... + @overload + def match( + self: _Regexp[str], text: str, pos: int | None = None, endpos: int | None = None + ) -> _Match[str] | None: ... + @overload + def match( + self: _Regexp[bytes], + text: bytes, + pos: int | None = None, + endpos: int | None = None, + ) -> _Match[bytes] | None: ... + @overload + def fullmatch( + self: _Regexp[str], text: str, pos: int | None = None, endpos: int | None = None + ) -> _Match[str] | None: ... + @overload + def fullmatch( + self: _Regexp[bytes], + text: bytes, + pos: int | None = None, + endpos: int | None = None, + ) -> _Match[bytes] | None: ... + @overload + def finditer( + self: _Regexp[str], text: str, pos: int | None = None, endpos: int | None = None + ) -> Iterator[_Match[str]]: ... + @overload + def finditer( + self: _Regexp[bytes], + text: bytes, + pos: int | None = None, + endpos: int | None = None, + ) -> Iterator[_Match[bytes]]: ... + @overload + def findall( + self: _Regexp[str], text: str, pos: int | None = None, endpos: int | None = None + ) -> list[str]: ... + @overload + def findall( + self: _Regexp[bytes], + text: bytes, + pos: int | None = None, + endpos: int | None = None, + ) -> list[bytes]: ... + @overload + def split(self: _Regexp[str], text: str, maxsplit: int = 0) -> list[str]: ... + @overload + def split(self: _Regexp[bytes], text: bytes, maxsplit: int = 0) -> list[bytes]: ... + @overload + def subn( + self: _Regexp[str], repl: str, text: str, count: int = 0 + ) -> tuple[str, int]: ... + @overload + def subn( + self: _Regexp[bytes], repl: bytes, text: bytes, count: int = 0 + ) -> tuple[bytes, int]: ... + @overload + def sub(self: _Regexp[str], repl: str, text: str, count: int = 0) -> str: ... + @overload + def sub( + self: _Regexp[bytes], repl: bytes, text: bytes, count: int = 0 + ) -> bytes: ... + @property + def pattern(self) -> AnyStr: ... + @property + def options(self) -> Options: ... + @property + def groups(self) -> int: ... + @property + def groupindex(self) -> dict[AnyStr, int]: ... + @property + def programsize(self) -> int: ... + @property + def reverseprogramsize(self) -> int: ... + @property + def programfanout(self) -> int: ... + @property + def reverseprogramfanout(self) -> int: ... + def possiblematchrange(self, maxlen: int) -> tuple[AnyStr, AnyStr]: ... + +class _Match(Generic[AnyStr]): + def __init__( + self, + regexp: _Regexp[AnyStr], + text: AnyStr, + pos: int, + endpos: int, + spans: dict[int, tuple[int, int]], + ) -> None: ... + @overload + def expand(self: _Match[str], template: str) -> str: ... + @overload + def expand(self: _Match[bytes], template: bytes) -> bytes: ... + @overload + def __getitem__(self: _Match[str], group: int | str) -> str | None: ... + @overload + def __getitem__(self: _Match[bytes], group: int | bytes) -> bytes | None: ... + @overload + def group(self: _Match[str], group: Literal[0] = 0, /) -> str: ... + @overload + def group(self: _Match[bytes], group: Literal[0] = 0, /) -> bytes: ... + @overload + def group(self: _Match[str], group: str | int, /) -> str: ... + @overload + def group(self: _Match[bytes], group: bytes | int, /) -> bytes: ... + @overload + def group( + self: _Match[str], group1: str | int, group2: str | int, /, *groups: str | int + ) -> tuple[str, ...]: ... + @overload + def group( + self: _Match[bytes], + group1: bytes | int, + group2: bytes | int, + /, + *groups: bytes | int, + ) -> tuple[bytes, ...]: ... + @overload + def groups(self: _Match[str]) -> tuple[str, ...]: ... + @overload + def groups(self: _Match[bytes]) -> tuple[bytes, ...]: ... + @overload + def groups(self: _Match[str], default: _T) -> tuple[str | _T, ...]: ... + @overload + def groups(self: _Match[bytes], default: _T) -> tuple[bytes | _T, ...]: ... + @overload + def groupdict(self: _Match[str]) -> dict[str, str]: ... + @overload + def groupdict(self: _Match[bytes]) -> dict[bytes, bytes]: ... + @overload + def groupdict(self: _Match[str], default: _T) -> dict[str, str | _T]: ... + @overload + def groupdict(self: _Match[bytes], default: _T) -> dict[bytes, bytes | _T]: ... + def start(self, group: int = 0) -> int: ... + def end(self, group: int = 0) -> int: ... + def span(self, group: int = 0) -> tuple[int, int]: ... + @property + def re(self) -> _Regexp[AnyStr]: ... + @property + def string(self) -> AnyStr: ... + @property + def pos(self) -> int: ... + @property + def endpos(self) -> int: ... + @property + def lastindex(self) -> int | None: ... + @property + def lastgroup(self) -> int | None: ... + +class Set: + def __init__(self, anchor: int, options: Options | None = None) -> None: ... + @classmethod + def SearchSet(cls, options: Options | None = None) -> Set: ... + @classmethod + def MatchSet(cls, options: Options | None = None) -> Set: ... + @classmethod + def FullMatchSet(cls, options: Options | None = None) -> Set: ... + def Add(self, pattern: AnyStr) -> int: ... + def Compile(self) -> None: ... + def Match(self, text: AnyStr) -> bool | None: ... + +class Filter: + def __init__(self) -> None: ... + def Add(self, pattern: AnyStr, options: Options | None = None) -> int: ... + def Compile(self) -> None: ... + def Match(self, text: AnyStr, potential: bool = False) -> list[int]: ... + def re(self, index: int) -> _Regexp[AnyStr]: ... diff --git a/src/re2-stubs/py.typed b/src/re2-stubs/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/tests/api/__init__.py b/tests/api/__init__.py new file mode 100644 index 0000000..7b70a5c --- /dev/null +++ b/tests/api/__init__.py @@ -0,0 +1 @@ +"""Test completeness of stub with examples of re2 use.""" diff --git a/tests/api/example.py b/tests/api/example.py new file mode 100644 index 0000000..3ae132e --- /dev/null +++ b/tests/api/example.py @@ -0,0 +1,17 @@ +"""Test completeness of stub with examples of re2 use.""" + +import re2 + + +def str_match() -> None: + pat = re2.compile(r"pattern") + m_str = pat.match("text") + if m_str: + assert isinstance(m_str.group(0), str) + + +def bytes_match() -> None: + pat = re2.compile(b"pattern") + m_bytes = pat.match(b"text") + if m_bytes: + assert isinstance(m_bytes.group(0), bytes)