Skip to content

Commit

Permalink
Type annotate release.py (#7951)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex authored Jan 2, 2023
1 parent 46d2a94 commit 525c0b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
21 changes: 14 additions & 7 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
import os
import subprocess
import time
import typing
import zipfile

import click
import requests


def run(*args, **kwargs):
def run(*args: str) -> None:
print("[running] {0}".format(list(args)))
subprocess.check_call(list(args), **kwargs)
subprocess.check_call(list(args))


def wait_for_build_complete_github_actions(session, token, run_url):
def wait_for_build_complete_github_actions(
session: requests.Session, token: str, run_url: str
) -> None:
while True:
response = session.get(
run_url,
Expand All @@ -33,7 +36,9 @@ def wait_for_build_complete_github_actions(session, token, run_url):
time.sleep(3)


def download_artifacts_github_actions(session, token, run_url):
def download_artifacts_github_actions(
session: requests.Session, token: str, run_url: str
) -> typing.List[str]:
response = session.get(
run_url,
headers={
Expand Down Expand Up @@ -76,7 +81,9 @@ def download_artifacts_github_actions(session, token, run_url):
return paths


def fetch_github_actions_artifacts(token, version):
def fetch_github_actions_artifacts(
token: str, version: str
) -> typing.List[str]:
session = requests.Session()

response = session.get(
Expand All @@ -90,14 +97,14 @@ def fetch_github_actions_artifacts(token, version):
},
)
response.raise_for_status()
run_url = response.json()["workflow_runs"][0]["url"]
run_url: str = response.json()["workflow_runs"][0]["url"]
wait_for_build_complete_github_actions(session, token, run_url)
return download_artifacts_github_actions(session, token, run_url)


@click.command()
@click.argument("version")
def release(version):
def release(version: str) -> None:
"""
``version`` should be a string like '0.4' or '1.0'.
"""
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ extras =
deps =
mypy
types-pytz
types-requests
check-manifest
commands =
ruff .
black --check .
check-manifest
mypy src/cryptography/ vectors/cryptography_vectors/ tests/
mypy src/cryptography/ vectors/cryptography_vectors/ tests/ release.py

[testenv:rust]
basepython = python3
Expand Down

0 comments on commit 525c0b3

Please sign in to comment.