Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type annotate release.py #7951

Merged
merged 1 commit into from Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 14 additions & 7 deletions release.py
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
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