Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
line-length = 120
output-format = "grouped"
target-version = "py37"
extend-exclude = ["src/pyright/_mureq.py"]
extend-exclude = []

[tool.ruff.lint]
select = [
Expand Down Expand Up @@ -46,7 +46,6 @@ include = [
"tests",
]
exclude = [
"src/pyright/_mureq.py",
"src/pyright/dist",
]
pythonVersion = "3.9"
Expand Down
14 changes: 7 additions & 7 deletions scripts/download_pyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import shutil
import tarfile
from pathlib import Path
from urllib.request import Request, urlopen

import pyright
from pyright import _mureq, __pyright_version__
from pyright import __pyright_version__

DIST_DIR = Path(pyright.__file__).parent / 'dist'

Expand Down Expand Up @@ -36,17 +37,16 @@ def download_tarball(*, version: str) -> None:
if DIST_DIR.exists():
shutil.rmtree(DIST_DIR)

rsp = _mureq.get(f'https://registry.npmjs.org/pyright/{version}')
rsp.raise_for_status()
with urlopen(Request(f'https://registry.npmjs.org/pyright/{version}')) as rsp:
info = json.loads(rsp.read())

info = rsp.json()
tar_url = info['dist']['tarball']
print(f'downloading tar from {tar_url}')

rsp = _mureq.get(tar_url)
rsp.raise_for_status()
with urlopen(Request(tar_url)) as rsp:
tar_bytes = rsp.read()

with tarfile.open(fileobj=io.BytesIO(rsp.body)) as tar:
with tarfile.open(fileobj=io.BytesIO(tar_bytes)) as tar:
members = tar.getmembers()

# npm tarballs will always output one `package/` directory which is
Expand Down
Loading