diff --git a/basedpyright/run_node.py b/basedpyright/run_node.py index 08e9369a8..417e04b66 100644 --- a/basedpyright/run_node.py +++ b/basedpyright/run_node.py @@ -3,8 +3,10 @@ import sys from pathlib import Path -from nodejs import node +from nodejs_wheel.executable import ( # pyright:ignore[reportMissingTypeStubs] + node, # pyright:ignore[reportUnknownVariableType] +) def run(script_name: str): - sys.exit(node.call([Path(__file__).parent / f"{script_name}.js", *sys.argv[1:]])) + sys.exit(node([Path(__file__).parent / f"{script_name}.js", *sys.argv[1:]])) diff --git a/pdm.lock b/pdm.lock index c43d93693..92a92c3b5 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev"] strategy = ["cross_platform", "inherit_metadata"] lock_version = "4.4.1" -content_hash = "sha256:a037bb0c35be29e00e36638b807e8328a76a211a8a36ce9729ddc53dc176e8e2" +content_hash = "sha256:eadd7e5f2c97f96087d37063cd9bd3616b2f058f6a8b32323781bd20b3fcb2b8" [[package]] name = "astroid" @@ -35,13 +35,13 @@ files = [ [[package]] name = "dill" -version = "0.3.7" -requires_python = ">=3.7" +version = "0.3.8" +requires_python = ">=3.8" summary = "serialize all of Python" groups = ["dev"] files = [ - {file = "dill-0.3.7-py3-none-any.whl", hash = "sha256:76b122c08ef4ce2eedcd4d1abd8e641114bfc6c2867f49f3c41facf65bf19f5e"}, - {file = "dill-0.3.7.tar.gz", hash = "sha256:cc1c8b182eb3013e24bd475ff2e9295af86c1a38eb1aff128dac8962a9ce3c03"}, + {file = "dill-0.3.8-py3-none-any.whl", hash = "sha256:c36ca9ffb54365bdd2f8eb3eff7d2a21237f8452b57ace88b1ac615b7e815bd7"}, + {file = "dill-0.3.8.tar.gz", hash = "sha256:3ebe3c479ad625c4553aca177444d89b486b1d84982eeacded644afc0cf797ca"}, ] [[package]] @@ -67,62 +67,43 @@ files = [ ] [[package]] -name = "nodejs-bin" -version = "18.4.0a4" -requires_python = "~=3.5" -summary = " Node.js is an open-source, cross-platform, back-end JavaScript\nruntime environment that runs on the V8 engine and executes JavaScript code\noutside a web browser." -groups = ["default", "dev"] -files = [ - {file = "nodejs_bin-18.4.0a4-py3-none-macosx_10_9_x86_64.whl", hash = "sha256:16cb1abf7fe8c11c574e1e474d9f934a0df49a480290eae6e733d8bb09512e22"}, - {file = "nodejs_bin-18.4.0a4-py3-none-macosx_11_0_arm64.whl", hash = "sha256:068ca987ed83ea1123775fafe5dc22d8f2ff920d7d31571e1bfe6fb1093833eb"}, - {file = "nodejs_bin-18.4.0a4-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:06cfeaa4d26eec94d8edb9927525ce94eb96dadc81f7d1daed42d1a7d003a4c9"}, - {file = "nodejs_bin-18.4.0a4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:431ee3529f4fb226ddcfd4f14cb37e7df31238c42dfd051f4bf8f0c21029b133"}, - {file = "nodejs_bin-18.4.0a4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:21f1f77ddc8fe05353bb6d6ee8e5a62edb3a8dcdb2740a5f9307fd8d9eef6691"}, - {file = "nodejs_bin-18.4.0a4-py3-none-win32.whl", hash = "sha256:59671fdc563dabb8be8a0b6dae4169d780482b3c9e0fba3f9aa2b7ee8d2261ac"}, - {file = "nodejs_bin-18.4.0a4-py3-none-win_amd64.whl", hash = "sha256:cbd509218b4b17f75ee7841f9c21d5cacc1626d3b823a652a6627dbad18228ec"}, -] - -[[package]] -name = "nodejs-bin" -version = "18.4.0a4" -extras = ["cmd"] -requires_python = "~=3.5" -summary = " Node.js is an open-source, cross-platform, back-end JavaScript\nruntime environment that runs on the V8 engine and executes JavaScript code\noutside a web browser." +name = "nodejs-wheel" +version = "20.13.0.post1" +requires_python = ">=3.7" +summary = "unoffical Node.js package" groups = ["dev"] dependencies = [ - "nodejs-bin==18.4.0a4", - "nodejs-cmd", + "nodejs-wheel-binaries==20.13.0", ] files = [ - {file = "nodejs_bin-18.4.0a4-py3-none-macosx_10_9_x86_64.whl", hash = "sha256:16cb1abf7fe8c11c574e1e474d9f934a0df49a480290eae6e733d8bb09512e22"}, - {file = "nodejs_bin-18.4.0a4-py3-none-macosx_11_0_arm64.whl", hash = "sha256:068ca987ed83ea1123775fafe5dc22d8f2ff920d7d31571e1bfe6fb1093833eb"}, - {file = "nodejs_bin-18.4.0a4-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:06cfeaa4d26eec94d8edb9927525ce94eb96dadc81f7d1daed42d1a7d003a4c9"}, - {file = "nodejs_bin-18.4.0a4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:431ee3529f4fb226ddcfd4f14cb37e7df31238c42dfd051f4bf8f0c21029b133"}, - {file = "nodejs_bin-18.4.0a4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:21f1f77ddc8fe05353bb6d6ee8e5a62edb3a8dcdb2740a5f9307fd8d9eef6691"}, - {file = "nodejs_bin-18.4.0a4-py3-none-win32.whl", hash = "sha256:59671fdc563dabb8be8a0b6dae4169d780482b3c9e0fba3f9aa2b7ee8d2261ac"}, - {file = "nodejs_bin-18.4.0a4-py3-none-win_amd64.whl", hash = "sha256:cbd509218b4b17f75ee7841f9c21d5cacc1626d3b823a652a6627dbad18228ec"}, + {file = "nodejs_wheel-20.13.0.post1-py3-none-any.whl", hash = "sha256:6a2c726a04d0052d9825073e692cb7e85e90ee0e19ad70f46345a17b3be3d3b5"}, + {file = "nodejs_wheel-20.13.0.post1.tar.gz", hash = "sha256:2007749ac8f28599279e5007b12d3f4788bad449cd23fcb30f528a7de1e31c47"}, ] [[package]] -name = "nodejs-cmd" -version = "0.0.1a0" -requires_python = "~=3.5" -summary = "Additional Standard Command Line Commands For nodejs-bin" -groups = ["dev"] +name = "nodejs-wheel-binaries" +version = "20.13.0" +requires_python = ">=3.7" +summary = "unoffical Node.js package" +groups = ["default", "dev"] files = [ - {file = "nodejs-cmd-0.0.1a0.tar.gz", hash = "sha256:fd71e7384892405bff93dcd203423cb80f5a8f15f37775dc7ee106388cc35da2"}, - {file = "nodejs_cmd-0.0.1a0-py3-none-any.whl", hash = "sha256:a88e06d0ff5d1768cbf89fb5eda3383fa3b229ff2a496f6898dae503a1a1dcba"}, + {file = "nodejs_wheel_binaries-20.13.0-py2.py3-none-macosx_10_9_x86_64.whl", hash = "sha256:67c17094e39c3897d6f558c5cf6e43657b40a469298743ed776eef93bb243582"}, + {file = "nodejs_wheel_binaries-20.13.0-py2.py3-none-macosx_11_0_arm64.whl", hash = "sha256:a4278164fc6969ea628d43f4068bcbad65bdc3f0e08f5ed1f9677fa15bc6b01c"}, + {file = "nodejs_wheel_binaries-20.13.0-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:25d4dbd4bc15a0fd56a026e7d4fe95e4ef3f9e2d10b79a5ad6d472f71d338710"}, + {file = "nodejs_wheel_binaries-20.13.0-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fd0bd0f7c3be733db96001188791740286d1c856da62615fbc424189b903552b"}, + {file = "nodejs_wheel_binaries-20.13.0-py2.py3-none-win_amd64.whl", hash = "sha256:27097d803050aa92b422b9fbd68f43b3878007473220b13134df958548447571"}, + {file = "nodejs_wheel_binaries-20.13.0.tar.gz", hash = "sha256:4978db6f8fe383be64f2f7e5808f5004cff18ddf6a0bbc36433f92cec6fd02db"}, ] [[package]] name = "platformdirs" -version = "4.1.0" +version = "4.2.1" requires_python = ">=3.8" -summary = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +summary = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." groups = ["dev"] files = [ - {file = "platformdirs-4.1.0-py3-none-any.whl", hash = "sha256:11c8f37bcca40db96d8144522d925583bdb7a31f7b0e37e3ed4318400a8e2380"}, - {file = "platformdirs-4.1.0.tar.gz", hash = "sha256:906d548203468492d432bcb294d4bc2fff751bf84971fbb2c10918cc206ee420"}, + {file = "platformdirs-4.2.1-py3-none-any.whl", hash = "sha256:17d5a1161b3fd67b390023cb2d3b026bbd40abde6fdb052dfbd3a29c3ba22ee1"}, + {file = "platformdirs-4.2.1.tar.gz", hash = "sha256:031cd18d4ec63ec53e82dceaac0417d218a6863f7745dfcc9efe7793b7039bdf"}, ] [[package]] @@ -151,28 +132,28 @@ files = [ [[package]] name = "ruff" -version = "0.3.4" +version = "0.4.3" requires_python = ">=3.7" summary = "An extremely fast Python linter and code formatter, written in Rust." groups = ["dev"] files = [ - {file = "ruff-0.3.4-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:60c870a7d46efcbc8385d27ec07fe534ac32f3b251e4fc44b3cbfd9e09609ef4"}, - {file = "ruff-0.3.4-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6fc14fa742e1d8f24910e1fff0bd5e26d395b0e0e04cc1b15c7c5e5fe5b4af91"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d3ee7880f653cc03749a3bfea720cf2a192e4f884925b0cf7eecce82f0ce5854"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cf133dd744f2470b347f602452a88e70dadfbe0fcfb5fd46e093d55da65f82f7"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3f3860057590e810c7ffea75669bdc6927bfd91e29b4baa9258fd48b540a4365"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:986f2377f7cf12efac1f515fc1a5b753c000ed1e0a6de96747cdf2da20a1b369"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c4fd98e85869603e65f554fdc5cddf0712e352fe6e61d29d5a6fe087ec82b76c"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:64abeed785dad51801b423fa51840b1764b35d6c461ea8caef9cf9e5e5ab34d9"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:df52972138318bc7546d92348a1ee58449bc3f9eaf0db278906eb511889c4b50"}, - {file = "ruff-0.3.4-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:98e98300056445ba2cc27d0b325fd044dc17fcc38e4e4d2c7711585bd0a958ed"}, - {file = "ruff-0.3.4-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:519cf6a0ebed244dce1dc8aecd3dc99add7a2ee15bb68cf19588bb5bf58e0488"}, - {file = "ruff-0.3.4-py3-none-musllinux_1_2_i686.whl", hash = "sha256:bb0acfb921030d00070539c038cd24bb1df73a2981e9f55942514af8b17be94e"}, - {file = "ruff-0.3.4-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:cf187a7e7098233d0d0c71175375c5162f880126c4c716fa28a8ac418dcf3378"}, - {file = "ruff-0.3.4-py3-none-win32.whl", hash = "sha256:af27ac187c0a331e8ef91d84bf1c3c6a5dea97e912a7560ac0cef25c526a4102"}, - {file = "ruff-0.3.4-py3-none-win_amd64.whl", hash = "sha256:de0d5069b165e5a32b3c6ffbb81c350b1e3d3483347196ffdf86dc0ef9e37dd6"}, - {file = "ruff-0.3.4-py3-none-win_arm64.whl", hash = "sha256:6810563cc08ad0096b57c717bd78aeac888a1bfd38654d9113cb3dc4d3f74232"}, - {file = "ruff-0.3.4.tar.gz", hash = "sha256:f0f4484c6541a99862b693e13a151435a279b271cff20e37101116a21e2a1ad1"}, + {file = "ruff-0.4.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b70800c290f14ae6fcbb41bbe201cf62dfca024d124a1f373e76371a007454ce"}, + {file = "ruff-0.4.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:08a0d6a22918ab2552ace96adeaca308833873a4d7d1d587bb1d37bae8728eb3"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eba1f14df3c758dd7de5b55fbae7e1c8af238597961e5fb628f3de446c3c40c5"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:819fb06d535cc76dfddbfe8d3068ff602ddeb40e3eacbc90e0d1272bb8d97113"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0bfc9e955e6dc6359eb6f82ea150c4f4e82b660e5b58d9a20a0e42ec3bb6342b"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:510a67d232d2ebe983fddea324dbf9d69b71c4d2dfeb8a862f4a127536dd4cfb"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dc9ff11cd9a092ee7680a56d21f302bdda14327772cd870d806610a3503d001f"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:29efff25bf9ee685c2c8390563a5b5c006a3fee5230d28ea39f4f75f9d0b6f2f"}, + {file = "ruff-0.4.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:18b00e0bcccf0fc8d7186ed21e311dffd19761cb632241a6e4fe4477cc80ef6e"}, + {file = "ruff-0.4.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:262f5635e2c74d80b7507fbc2fac28fe0d4fef26373bbc62039526f7722bca1b"}, + {file = "ruff-0.4.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:7363691198719c26459e08cc17c6a3dac6f592e9ea3d2fa772f4e561b5fe82a3"}, + {file = "ruff-0.4.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:eeb039f8428fcb6725bb63cbae92ad67b0559e68b5d80f840f11914afd8ddf7f"}, + {file = "ruff-0.4.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:927b11c1e4d0727ce1a729eace61cee88a334623ec424c0b1c8fe3e5f9d3c865"}, + {file = "ruff-0.4.3-py3-none-win32.whl", hash = "sha256:25cacda2155778beb0d064e0ec5a3944dcca9c12715f7c4634fd9d93ac33fd30"}, + {file = "ruff-0.4.3-py3-none-win_amd64.whl", hash = "sha256:7a1c3a450bc6539ef00da6c819fb1b76b6b065dec585f91456e7c0d6a0bbc725"}, + {file = "ruff-0.4.3-py3-none-win_arm64.whl", hash = "sha256:71ca5f8ccf1121b95a59649482470c5601c60a416bf189d553955b0338e34614"}, + {file = "ruff-0.4.3.tar.gz", hash = "sha256:ff0a3ef2e3c4b6d133fbedcf9586abfbe38d076041f2dc18ffb2c7e0485d5a07"}, ] [[package]] @@ -189,23 +170,23 @@ files = [ [[package]] name = "tomlkit" -version = "0.12.3" +version = "0.12.4" requires_python = ">=3.7" summary = "Style preserving TOML library" groups = ["dev"] files = [ - {file = "tomlkit-0.12.3-py3-none-any.whl", hash = "sha256:b0a645a9156dc7cb5d3a1f0d4bab66db287fcb8e0430bdd4664a095ea16414ba"}, - {file = "tomlkit-0.12.3.tar.gz", hash = "sha256:75baf5012d06501f07bee5bf8e801b9f343e7aac5a92581f20f80ce632e6b5a4"}, + {file = "tomlkit-0.12.4-py3-none-any.whl", hash = "sha256:5cd82d48a3dd89dee1f9d64420aa20ae65cfbd00668d6f094d7578a78efbb77b"}, + {file = "tomlkit-0.12.4.tar.gz", hash = "sha256:7ca1cfc12232806517a8515047ba66a19369e71edf2439d0f5824f91032b6cc3"}, ] [[package]] name = "typing-extensions" -version = "4.9.0" +version = "4.11.0" requires_python = ">=3.8" summary = "Backported and Experimental Type Hints for Python 3.8+" groups = ["dev"] marker = "python_version < \"3.11\"" files = [ - {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, - {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, + {file = "typing_extensions-4.11.0-py3-none-any.whl", hash = "sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a"}, + {file = "typing_extensions-4.11.0.tar.gz", hash = "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0"}, ] diff --git a/pdm_build.py b/pdm_build.py index 7af65d003..ed0778192 100644 --- a/pdm_build.py +++ b/pdm_build.py @@ -3,22 +3,25 @@ from json import loads from pathlib import Path from shutil import copyfile, copytree -from typing import TYPE_CHECKING, TypedDict, cast +from typing import TypedDict, cast -# https://github.com/samwillis/nodejs-pypi/pull/23 -if TYPE_CHECKING: - # https://github.com/astral-sh/ruff/issues/9528 - from subprocess import run # noqa: S404 -else: - from nodejs.npm import run +from nodejs_wheel.executable import ( # pyright:ignore[reportMissingTypeStubs] + npm, # pyright:ignore[reportUnknownVariableType] +) class PackageJson(TypedDict): bin: dict[str, str] -_ = run(["ci"], check=True) -_ = run(["run", "build:cli:dev"], check=True) +def run_npm(*args: str): + exit_code = npm(args) + if exit_code != 0: + raise Exception(f"the following npm command exited with {exit_code=}: {args}") + + +run_npm("ci") +run_npm("run", "build:cli:dev") npm_package_dir = Path("packages/pyright") pypi_package_dir = Path("basedpyright") diff --git a/pyproject.toml b/pyproject.toml index 3e4e1883d..2163b203a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.pyprojectx] -main = ["pdm==2.13.2"] +main = ["pdm==2.15.1"] [tool.pdm] distribution = true @@ -8,8 +8,8 @@ distribution = true dev = [ "pylint>=3.0.0a7", "ruff>=0.2.2", - # required for running node/npm commands for local development if node is not installed globally: - "nodejs-bin[cmd]>=18.4.0a4", + # cli is needed for development if node is not installed globally + "nodejs-wheel>=20.13.0", ] [tool.pdm.version] @@ -32,8 +32,9 @@ authors = [ { name = "detachhead", email = "detachhead@users.noreply.github.com" }, ] dependencies = [ - # required by the basedpyright cli & langserver wrapper scripts, the cmd extra is not needed downstream tho - "nodejs-bin>=18.4.0a4", + # required by the basedpyright cli & langserver wrapper scripts. only binaries are required (no cli) + # since the user shouldn't have a node/npm binary unknowingly added to their PATH + "nodejs-wheel-binaries>=20.13.0", ] requires-python = ">=3.8" readme = "README.md" @@ -49,8 +50,9 @@ basedpyright-langserver = 'basedpyright.langserver:main' [build-system] requires = [ "pdm-backend", - # required when building because some transient dependencies call node/npm scripts relying on it being in the PATH - "nodejs-bin[cmd]>=18.4.0a4", + # required for building the pyright npm package to be bundled in the pypi package. + # cli is required due to dependencies with install scripts that assume node/npm is in the path + "nodejs-wheel>=20.13.0", ] build-backend = "pdm.backend" @@ -97,12 +99,9 @@ enable = [ "assignment-from-none", "dict-iter-missing-items", "invalid-bool-returned", - "invalid-bytes-returned", "invalid-getnewargs-ex-returned", "invalid-getnewargs-returned", - "invalid-index-returned", "invalid-length-hint-returned", - "invalid-length-returned", "invalid-slice-index", "invalid-slice-step", "invalid-slots", @@ -112,10 +111,8 @@ enable = [ "logging-unsupported-format", "method-hidden", "modified-iterating-dict", - "modified-iterating-set", "potential-index-error", "relative-beyond-top-level", - "singledispatchmethod-function", "abstract-method", "arguments-out-of-order", "attribute-defined-outside-init", @@ -127,17 +124,14 @@ enable = [ "missing-param-doc", "modified-iterating-list", "multiple-constructor-doc", - "nan-comparison", "non-parent-init-called", "overlapping-except", "preferred-module", "raising-format-tuple", - "redeclared-assigned-name", "redefined-outer-name", "redefined-slots-in-subclass", "redundant-returns-doc", "redundant-yields-doc", - "self-cls-assignment", "shallow-copy-environ", "useless-param-doc", "useless-parent-delegation",