diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d064fbf..4da3050 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -62,7 +62,7 @@ jobs: make init-uv make install - - name: Type checking with ty + - name: Type checking with Pyrefly run: make type test: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3c077df..77efa8e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,9 +25,14 @@ repos: - id: ruff-format - id: ruff -# ty -# Note: ty pre-commit hook not yet available (see https://github.com/astral-sh/ty/issues/269) -# Type checking is handled via prek or make type +# pyrefly +- repo: https://github.com/facebook/pyrefly-pre-commit + rev: 1.2.0 # pre-commit hook version, not the pyrefly version (that comes from pyproject.toml) + hooks: + - id: pyrefly-check + name: pyrefly + pass_filenames: false + language: system # use the project's own pyrefly install so versions stay in sync with pyproject.toml # sqlfluff - repo: https://github.com/sqlfluff/sqlfluff diff --git a/Makefile b/Makefile index 593a42b..6088feb 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ lint-sql: uv run sqlfluff lint . type: - uv run ty check + uv run pyrefly check test: uv run pytest -vv -m "not df" diff --git a/README.md b/README.md index 837e5f4..7803839 100644 --- a/README.md +++ b/README.md @@ -33,14 +33,14 @@ uv run prek run # uv run prek run uv run prek run ruff-format uv run prek run ruff -uv run prek run ty +uv run prek run pyrefly-check # To run a particular prek hook against all files (staged and unstaged, before committing): uv run prek run ruff --all-files # run checks regardless of git status uv run ruff format --check src -uv run ty src +uv run pyrefly check uv run ruff src ``` @@ -99,7 +99,7 @@ The checks contained in this repo include (in the order in which they run): * Various checkers and formatters to verify valid file types, file size, and end of line and end of file whitespace/newlines * `ruff format` applies standard code style formatting (just like `black`, but faster) * `ruff` checks code for "lint" -* `ty` is used for static type checking +* `pyrefly` is used for static type checking * `sqlfluff` checks and fixes sql formatting and linting * `uv` checks on valid and aligned pyproject.toml and uv.lock files * `commitlint` enforces commit message conforms to [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) format @@ -107,8 +107,8 @@ The checks contained in this repo include (in the order in which they run): If you want `ruff format` to ignore a particular section of code, you can add the comments `# fmt: off` and `# fmt: on` before and after the respective block of code (same as you would if using `black`). * https://stackoverflow.com/a/58584557 -If you want `ty` to ignore a particular line of code, you can add the comment `# type: ignore` to the end of that line. -If `# type: ignore` is added to the very top of a file, `ty` will ignore the entire file. +If you want `pyrefly` to ignore a particular line of code, you can add the comment `# pyrefly: ignore` to the end of +that line (`# type: ignore` is also respected). If you absolutely must commit without adhering to the prek hooks, then you can use `git commit -n ...` where `-n` is shorthand for `--no-verify`. diff --git a/pyproject.toml b/pyproject.toml index 0ccc701..96e0dda 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,12 +28,12 @@ dev = [ "mkdocstrings[python] >=0.25.2,<1", "nox >=2024.4.15,<2025", "prek >=0.1.0,<1", + "pyrefly >=1.2.0,<2", "pytest >=8.3.2,<9", "pytest-cov >=5.0.0,<6", "python-semantic-release >=10.0.0,<11", "ruff >=0.6.2,<1", "sqlfluff >=3.1.1,<4", - "ty >=0.0.11,<1", ] @@ -53,10 +53,11 @@ fail_under = 70 show_missing = true -#### -# Ty -#### -[tool.ty] +######### +# Pyrefly +######### +[tool.pyrefly] +project-includes = ["src", "tests", "noxfile.py"] ###### diff --git a/src/sample/placeholder.py b/src/sample/placeholder.py index c024db1..c905dff 100644 --- a/src/sample/placeholder.py +++ b/src/sample/placeholder.py @@ -7,7 +7,7 @@ import sample -MODULE_DIR = Path(sample.__file__).resolve().parent # type: ignore +MODULE_DIR = Path(sample.__file__).resolve().parent SQL_DIR = MODULE_DIR / "sql" diff --git a/uv.lock b/uv.lock index c70b79a..e40f58b 100644 --- a/uv.lock +++ b/uv.lock @@ -1266,6 +1266,25 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/00/ae/55d347eda5a4c57a2a042fe2e7616d14981115f566b9f8f69901aba3c0c6/pymdown_extensions-10.14-py3-none-any.whl", hash = "sha256:202481f716cc8250e4be8fce997781ebf7917701b59652458ee47f2401f818b5", size = 264264 }, ] +[[package]] +name = "pyrefly" +version = "1.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7d/82/df301034ff7705b51ab212039958910434e1e9bd4765cde435538221fc35/pyrefly-1.3.0.tar.gz", hash = "sha256:e96a0bf3abdc41cf40f7d2ef274bb610f4e6e4b387b366aea102902839073388", size = 6678024 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/36/98/47bf19b6caef77852c7e1c03d71ef48a5f452bf041503d883e0bca6fc4c8/pyrefly-1.3.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:dd6c61e4c307eaaf3cf25fb329c4e7c9ff0376c42d5900362be2fd3333578a69", size = 15088089 }, + { url = "https://files.pythonhosted.org/packages/4c/77/454615aa5db04903c99ced321295e32242c4b188be1a08f40b617ed72984/pyrefly-1.3.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:14c56defaa804747f18e03d11b539e71b71c8251a2b9f58e73dea80e2f6adfd9", size = 14431422 }, + { url = "https://files.pythonhosted.org/packages/01/f2/142e190b9432f802682b0b0794f71e2010e936de0541492cc43678d647af/pyrefly-1.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:64285b1261681933f97cb11f3ba2e4445ff02a266707e4e2b7a279db0424c9f2", size = 14880659 }, + { url = "https://files.pythonhosted.org/packages/d9/2f/60598fe38f29f22d11d9f4b5c7fee1cbbb0d5b0cb7db6b373761d57f5f75/pyrefly-1.3.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:46a90d6e48415dfa5d8d9c94ea5b9b61d7149dab87348952f2e000cf45145664", size = 16116073 }, + { url = "https://files.pythonhosted.org/packages/c2/0a/33e49756fe3341dbb13789622cb8c9b6350d2710ceb47b8b0521f134ceea/pyrefly-1.3.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e0cc33b35204b8e1b09396313024580d25a041de2f2f527e6496fc099282b967", size = 16049648 }, + { url = "https://files.pythonhosted.org/packages/b0/fe/be59429726af4c0c3585951a937232d957182364cd2a621f74f4298a176e/pyrefly-1.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e94ff692911596d257462320a2ef1435c93c20c80d631404961282f4cc22a6cc", size = 15439725 }, + { url = "https://files.pythonhosted.org/packages/2b/73/bb834e88afea6c0de6960be2102c0cc1d817193c1efc3f6db9b450df191c/pyrefly-1.3.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:5705bec5438aa4e3b65b0d2ea7613f6bdbdc57f8848bd4b7940bbab37f230d8c", size = 14900386 }, + { url = "https://files.pythonhosted.org/packages/c7/64/1adbc6ece9090bbd2e4ed1300918ab709166119426a21102639912ea65bb/pyrefly-1.3.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:fe60cb6d7cdf6c9bb236c0a7efc4b9839cfe7ef834b07d637862f95a642699ef", size = 15478065 }, + { url = "https://files.pythonhosted.org/packages/d0/5c/e1351611d2e205718394237381220ab70f0e21cb297db024eafead19acf9/pyrefly-1.3.0-py3-none-win32.whl", hash = "sha256:4fb4cd5e5007e99208e44f749edaf37a03c0a56c98da7422c2dd60fde0f294b0", size = 14130445 }, + { url = "https://files.pythonhosted.org/packages/3c/92/1d78e2ab1f9f1055ea43164d336903c95e608bede06ed182dc4b4f2c5390/pyrefly-1.3.0-py3-none-win_amd64.whl", hash = "sha256:f809fa5b447012adb8861efeb8f6435146788a39d9251d79dc38731a5d241893", size = 15067598 }, + { url = "https://files.pythonhosted.org/packages/b3/6f/459f56dc345c32f8597acef13675e7e67679fb56bc3fd8f0a280eaeb8c02/pyrefly-1.3.0-py3-none-win_arm64.whl", hash = "sha256:3a3fb7c07dfb9b43d4205d8e85a83aaefc85377d0437dc8469c132836a8a7e5d", size = 14347403 }, +] + [[package]] name = "pytest" version = "8.3.4" @@ -1588,12 +1607,12 @@ dev = [ { name = "mkdocstrings", extra = ["python"] }, { name = "nox" }, { name = "prek" }, + { name = "pyrefly" }, { name = "pytest" }, { name = "pytest-cov" }, { name = "python-semantic-release" }, { name = "ruff" }, { name = "sqlfluff" }, - { name = "ty" }, ] [package.metadata] @@ -1606,12 +1625,12 @@ dev = [ { name = "mkdocstrings", extras = ["python"], specifier = ">=0.25.2,<1" }, { name = "nox", specifier = ">=2024.4.15,<2025" }, { name = "prek", specifier = ">=0.1.0,<1" }, + { name = "pyrefly", specifier = ">=1.2.0,<2" }, { name = "pytest", specifier = ">=8.3.2,<9" }, { name = "pytest-cov", specifier = ">=5.0.0,<6" }, { name = "python-semantic-release", specifier = ">=10.0.0,<11" }, { name = "ruff", specifier = ">=0.6.2,<1" }, { name = "sqlfluff", specifier = ">=3.1.1,<4" }, - { name = "ty", specifier = ">=0.0.11,<1" }, ] [[package]] @@ -1744,31 +1763,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d0/30/dc54f88dd4a2b5dc8a0279bdd7270e735851848b762aeb1c1184ed1f6b14/tqdm-4.67.1-py3-none-any.whl", hash = "sha256:26445eca388f82e72884e0d580d5464cd801a3ea01e63e5601bdff9ba6a48de2", size = 78540 }, ] -[[package]] -name = "ty" -version = "0.0.11" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/bc/45/5ae578480168d4b3c08cf8e5eac3caf8eb7acdb1a06a9bed7519564bd9b4/ty-0.0.11.tar.gz", hash = "sha256:ebcbc7d646847cb6610de1da4ffc849d8b800e29fd1e9ebb81ba8f3fbac88c25", size = 4920340 } -wheels = [ - { url = "https://files.pythonhosted.org/packages/0f/34/b1d05cdcd01589a8d2e63011e0a1e24dcefdc2a09d024fee3e27755963f6/ty-0.0.11-py3-none-linux_armv6l.whl", hash = "sha256:68f0b8d07b0a2ea7ec63a08ba2624f853e4f9fa1a06fce47fb453fa279dead5a", size = 9521748 }, - { url = "https://files.pythonhosted.org/packages/43/21/f52d93f4b3784b91bfbcabd01b84dc82128f3a9de178536bcf82968f3367/ty-0.0.11-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:cbf82d7ef0618e9ae3cc3c37c33abcfa302c9b3e3b8ff11d71076f98481cb1a8", size = 9454903 }, - { url = "https://files.pythonhosted.org/packages/ad/01/3a563dba8b1255e474c35e1c3810b7589e81ae8c41df401b6a37c8e2cde9/ty-0.0.11-py3-none-macosx_11_0_arm64.whl", hash = "sha256:121987c906e02264c3b511b95cb9f8a3cdd66f3283b8bbab678ca3525652e304", size = 8823417 }, - { url = "https://files.pythonhosted.org/packages/6f/b1/99b87222c05d3a28fb7bbfb85df4efdde8cb6764a24c1b138f3a615283dd/ty-0.0.11-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:999390b6cc045fe5e1b3da1c2c9ae8e8c0def23b69455e7c9191ba9ffd747023", size = 9290785 }, - { url = "https://files.pythonhosted.org/packages/3d/9f/598809a8fff2194f907ba6de07ac3d7b7788342592d8f8b98b1b50c2fb49/ty-0.0.11-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ed504d78eb613c49be3c848f236b345b6c13dc6bcfc4b202790a60a97e1d8f35", size = 9359392 }, - { url = "https://files.pythonhosted.org/packages/71/3e/aeea2a97b38f3dcd9f8224bf83609848efa4bc2f484085508165567daa7b/ty-0.0.11-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7fedc8b43cc8a9991e0034dd205f957a8380dd29bfce36f2a35b5d321636dfd9", size = 9852973 }, - { url = "https://files.pythonhosted.org/packages/72/40/86173116995e38f954811a86339ac4c00a2d8058cc245d3e4903bc4a132c/ty-0.0.11-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:0808bdfb7efe09881bf70249b85b0498fb8b75fbb036ce251c496c20adb10075", size = 10796113 }, - { url = "https://files.pythonhosted.org/packages/69/71/97c92c401dacae9baa3696163ebe8371635ebf34ba9fda781110d0124857/ty-0.0.11-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:07185b3e38b18c562056dfbc35fb51d866f872977ea1ebcd64ca24a001b5b4f1", size = 10432137 }, - { url = "https://files.pythonhosted.org/packages/18/10/9ab43f3cfc5f7792f6bc97620f54d0a0a81ef700be84ea7f6be330936a99/ty-0.0.11-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b5c72f1ada8eb5be984502a600f71d1a3099e12fb6f3c0607aaba2f86f0e9d80", size = 10240520 }, - { url = "https://files.pythonhosted.org/packages/74/18/8dd4fe6df1fd66f3e83b4798eddb1d8482d9d9b105f25099b76703402ebb/ty-0.0.11-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:25f88e8789072830348cb59b761d5ced70642ed5600673b4bf6a849af71eca8b", size = 9973340 }, - { url = "https://files.pythonhosted.org/packages/e4/0b/fb2301450cf8f2d7164944d6e1e659cac9ec7021556cc173d54947cf8ef4/ty-0.0.11-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:f370e1047a62dcedcd06e2b27e1f0b16c7f8ea2361d9070fcbf0d0d69baaa192", size = 9262101 }, - { url = "https://files.pythonhosted.org/packages/f7/8c/d6374af023541072dee1c8bcfe8242669363a670b7619e6fffcc7415a995/ty-0.0.11-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:52be34047ed6177bfcef9247459a767ec03d775714855e262bca1fb015895e8a", size = 9382756 }, - { url = "https://files.pythonhosted.org/packages/0d/44/edd1e63ffa8d49d720c475c2c1c779084e5efe50493afdc261938705d10a/ty-0.0.11-py3-none-musllinux_1_2_i686.whl", hash = "sha256:b9e5762ccb3778779378020b8d78f936b3f52ea83f18785319cceba3ae85d8e6", size = 9553944 }, - { url = "https://files.pythonhosted.org/packages/35/cd/4afdb0d182d23d07ff287740c4954cc6dde5c3aed150ec3f2a1d72b00f71/ty-0.0.11-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:e9334646ee3095e778e3dbc45fdb2bddfc16acc7804283830ad84991ece16dd7", size = 10060365 }, - { url = "https://files.pythonhosted.org/packages/d1/94/a009ad9d8b359933cfea8721c689c0331189be28650d74dcc6add4d5bb09/ty-0.0.11-py3-none-win32.whl", hash = "sha256:44cfb7bb2d6784bd7ffe7b5d9ea90851d9c4723729c50b5f0732d4b9a2013cfc", size = 9040448 }, - { url = "https://files.pythonhosted.org/packages/df/04/5a5dfd0aec0ea99ead1e824ee6e347fb623c464da7886aa1e3660fb0f36c/ty-0.0.11-py3-none-win_amd64.whl", hash = "sha256:1bb205db92715d4a13343bfd5b0c59ce8c0ca0daa34fb220ec9120fc66ccbda7", size = 9780112 }, - { url = "https://files.pythonhosted.org/packages/ad/07/47d4fccd7bcf5eea1c634d518d6cb233f535a85d0b63fcd66815759e2fa0/ty-0.0.11-py3-none-win_arm64.whl", hash = "sha256:4688bd87b2dc5c85da277bda78daba14af2e66f3dda4d98f3604e3de75519eba", size = 9194038 }, -] - [[package]] name = "typing-extensions" version = "4.12.2"