Skip to content

Commit

Permalink
style: fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Aug 21, 2024
1 parent a8df801 commit d0b3a86
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scripts/fetch-static-files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io
import json
import shutil
from collections.abc import Callable
from pathlib import Path
from tarfile import TarFile

Expand All @@ -16,7 +17,11 @@
client = httpx.Client(proxies="http://192.168.1.3:7890")


def download_npm_package(name: str, path_filter: tuple[str, ...], version_filter=None):
def download_npm_package(
name: str,
path_filter: tuple[str, ...],
version_filter: Callable[[str], bool] | None = None,
) -> None:
target = static_path.joinpath(name)
package_json = target.joinpath("package.json")

Expand Down Expand Up @@ -57,10 +62,13 @@ def download_npm_package(name: str, path_filter: tuple[str, ...], version_filter
continue
target_file = target.joinpath(latest_version, fn)
target_file.parent.mkdir(parents=True, exist_ok=True)
target_file.write_bytes(tar.extractfile(file).read())
f = tar.extractfile(file)
if not f:
raise Exception(f"extractfile return unexpected none for file {file}")
target_file.write_bytes(f.read())


def build_version_filter(major: int, stable=True):
def build_version_filter(major: int, stable: bool = True) -> Callable[[str], bool]:
def f(s: str) -> bool:
v = semver.VersionInfo.parse(s)
if v.prerelease:
Expand Down

0 comments on commit d0b3a86

Please sign in to comment.