Skip to content

Commit

Permalink
assert google_protobuf.extract_python_version is a str
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Sep 18, 2024
1 parent ae26a36 commit 598d0a7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/sync_protobuf/google_protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import sys
import tempfile
from pathlib import Path
from typing import Any

from _utils import MYPY_PROTOBUF_VERSION, REPO_ROOT, download_file, extract_archive, run_protoc, update_metadata

Expand All @@ -31,9 +32,11 @@
def extract_python_version(file_path: Path) -> str:
"""Extract the Python version from https://github.com/protocolbuffers/protobuf/blob/main/version.json"""
with open(file_path) as file:
data: dict[str, dict[str, dict[str, str]]] = json.load(file)
data: dict[str, Any] = json.load(file)
# The root key will be the protobuf source code version
return next(iter(data.values()))["languages"]["python"]
version = next(iter(data.values()))["languages"]["python"]
assert isinstance(version, str)
return version


def extract_proto_file_paths(temp_dir: Path) -> list[str]:
Expand Down

0 comments on commit 598d0a7

Please sign in to comment.