Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Easy type fixes for the release script
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Apr 8, 2022
1 parent 3d03b4e commit 24708f6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ ignore_missing_imports = True
[mypy-pympler.*]
ignore_missing_imports = True

[mypy-redbaron.*]
ignore_missing_imports = True

[mypy-rust_python_jaeger_reporter.*]
ignore_missing_imports = True

Expand Down
26 changes: 14 additions & 12 deletions scripts-dev/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import urllib.request
from os import path
from tempfile import TemporaryDirectory
from typing import List, Optional, Tuple
from typing import Any, List, Optional, Tuple

import attr
import click
Expand All @@ -37,7 +37,9 @@
from packaging import version


def run_until_successful(command, *args, **kwargs):
def run_until_successful(
command: str, *args: Any, **kwargs: Any
) -> subprocess.CompletedProcess:
while True:
completed_process = subprocess.run(command, *args, **kwargs)
exit_code = completed_process.returncode
Expand All @@ -51,7 +53,7 @@ def run_until_successful(command, *args, **kwargs):


@click.group()
def cli():
def cli() -> None:
"""An interactive script to walk through the parts of creating a release.
Requires the dev dependencies be installed, which can be done via:
Expand Down Expand Up @@ -81,7 +83,7 @@ def cli():


@cli.command()
def prepare():
def prepare() -> None:
"""Do the initial stages of creating a release, including creating release
branch, updating changelog and pushing to GitHub.
"""
Expand Down Expand Up @@ -267,7 +269,7 @@ def prepare():

@cli.command()
@click.option("--gh-token", envvar=["GH_TOKEN", "GITHUB_TOKEN"])
def tag(gh_token: Optional[str]):
def tag(gh_token: Optional[str]) -> None:
"""Tags the release and generates a draft GitHub release"""

# Make sure we're in a git repo.
Expand Down Expand Up @@ -349,7 +351,7 @@ def tag(gh_token: Optional[str]):

@cli.command()
@click.option("--gh-token", envvar=["GH_TOKEN", "GITHUB_TOKEN"], required=True)
def publish(gh_token: str):
def publish(gh_token: str) -> None:
"""Publish release."""

# Make sure we're in a git repo.
Expand Down Expand Up @@ -392,7 +394,7 @@ def publish(gh_token: str):


@cli.command()
def upload():
def upload() -> None:
"""Upload release to pypi."""

current_version, _, _ = parse_version_from_module()
Expand Down Expand Up @@ -420,7 +422,7 @@ def upload():


@cli.command()
def announce():
def announce() -> None:
"""Generate markdown to announce the release."""

current_version, _, _ = parse_version_from_module()
Expand Down Expand Up @@ -497,7 +499,7 @@ def find_ref(repo: git.Repo, ref_name: str) -> Optional[git.HEAD]:
return None


def update_branch(repo: git.Repo):
def update_branch(repo: git.Repo) -> None:
"""Ensure branch is up to date if it has a remote"""
if repo.active_branch.tracking_branch():
repo.git.merge(repo.active_branch.tracking_branch().name)
Expand Down Expand Up @@ -564,7 +566,7 @@ class VersionSection:
return "\n".join(version_changelog)


def generate_and_write_changelog(current_version: version.Version):
def generate_and_write_changelog(current_version: version.Version) -> None:
# We do this by getting a draft so that we can edit it before writing to the
# changelog.
result = run_until_successful(
Expand All @@ -584,8 +586,8 @@ def generate_and_write_changelog(current_version: version.Version):
f.write(existing_content)

# Remove all the news fragments
for f in glob.iglob("changelog.d/*.*"):
os.remove(f)
for filename in glob.iglob("changelog.d/*.*"):
os.remove(filename)


if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def exec_file(path_segments):
"mypy==0.931",
"mypy-zope==0.3.5",
"types-bleach>=4.1.0",
"types-commonmark>=0.9.2",
"types-jsonschema>=3.2.0",
"types-opentracing>=2.4.2",
"types-Pillow>=8.3.4",
Expand All @@ -130,7 +131,8 @@ def exec_file(path_segments):
# The following are used by the release script
"click==8.1.0",
"redbaron==0.9.2",
"GitPython==3.1.14",
# GitPython was == 3.1.14; bumped to 3.1.20, the first release with type hints.
"GitPython==3.1.20",
"commonmark==0.9.1",
"pygithub==1.55",
# The following are executed as commands by the release script.
Expand Down

0 comments on commit 24708f6

Please sign in to comment.