Skip to content

Commit

Permalink
formatting changes to appease the linter on the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattscarpenter committed Sep 2, 2024
1 parent 04f4bf6 commit 8e1ba1d
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def __init__(self, options):
current_tag = self.repo.rev_parse(current_name)
print(f"Current tag id: {current_tag}", file=sys.stderr)
try:
self.current_tag = current_tag.tag
print(f"Current tag: {self.current_tag}", file=sys.stderr)
self.current_tag = current_tag.tag
print(f"Current tag: {self.current_tag}", file=sys.stderr)
except (AttributeError, BadName, GitCommandError):
print("Not an annotated tag!", file=sys.stderr)
exit(4)
print("Not an annotated tag!", file=sys.stderr)
exit(4)

def ready_for_release(self):
"""Return true if the current git checkout is suitable for release
Expand All @@ -96,7 +96,10 @@ def ready_for_release(self):
return False
tag_is_valid = self.RELEASE_TAG_PATTERN.match(self.current_tag) is not None
if not tag_is_valid:
print(f"""Tag "{self.current_tag}" is not a valid release tag. Expected "vX.Y.Z" where X, Y, and Z are non-negative integers, formatted without leading zeros.""", file=sys.stderr)
print(f"""Tag "{self.current_tag}" is not a valid release tag."""+
"""Expected "vX.Y.Z" where X, Y, and Z are non-negative integers, formatted without leading zeros.""",
file=sys.stderr
)
return tag_is_valid

def generate_changelog(self):
Expand Down Expand Up @@ -155,7 +158,9 @@ def format_rst_changelog(changelog, options):
links[sha] = f".. _{sha}: https://github.com/{options.organization}/{options.repository}/commit/{sha}"
for match in ISSUE_NUMBER.finditer(summary):
issue_number = match.group(1)
links[issue_number] = f".. _#{issue_number}: https://github.com/{options.organization}/{options.repository}/issues/{issue_number}"
links[issue_number] = (
f".. _#{issue_number}: https://github.com/{options.organization}/{options.repository}/issues/{issue_number}"
)
summary = ISSUE_NUMBER.sub(r"`#\1`_", summary)
output.append(f"* `{sha}`_: {summary}")
output.append("")
Expand All @@ -182,13 +187,14 @@ def create_artifacts(changelog, options):
formatted_changelog = format_rst_changelog(changelog, options)
with open(fd, "w", encoding="utf-8") as fobj:
fobj.write(formatted_changelog)
subprocess.check_call([
sys.executable, "setup.py",
"egg_info", "--tag-build=",
"sdist",
"bdist_wheel", "--universal"
subprocess.check_call(
[
sys.executable, "setup.py",
"egg_info", "--tag-build=",
"sdist",
"bdist_wheel", "--universal"
],
env=( os.environ.copy() | {"CHANGELOG_FILE": name} ) # see https://stackoverflow.com/a/78652759
env=(os.environ.copy() | {"CHANGELOG_FILE": name}) # see https://stackoverflow.com/a/78652759
)
os.unlink(name)
return [os.path.abspath(os.path.join("dist", fname)) for fname in os.listdir("dist")]
Expand Down Expand Up @@ -220,7 +226,12 @@ def main():
parser.add_argument("repository", help="The name of the repository on GitHub")
options = parser.parse_args()
if "GITHUB_TOKEN" not in os.environ:
print("Publish requires the GITHUB_TOKEN environment variable to be set. Before you run this command, try `export GITHUB_TOKEN=your-gh-token-blah-blah-blah-whatever` (on Unix-likes) or `set GITHUB_TOKEN=your-gh-token-blah-blah-blah-whatever` (on Windows)\n\nPublish also requires the TWINE_USERNAME and TWINE_PASSWORD environment variables to be set in the same way; but, unlike GITHUB_TOKEN, you will be prompted to provide them later if they aren't in the environment, so setting them beforehand is not mandatory.")
print("Publish requires the GITHUB_TOKEN environment variable to be set."+
"Before you run this command, try `export GITHUB_TOKEN=your-gh-token-blah-blah-blah-whatever` (on Unix-likes) or "+
"`set GITHUB_TOKEN=your-gh-token-blah-blah-blah-whatever` (on Windows)\n\nPublish also requires the TWINE_USERNAME and"+
"TWINE_PASSWORD environment variables to be set in the same way; but, unlike GITHUB_TOKEN, you will be prompted to provide"+
"them later if they aren't in the environment, so setting them beforehand is not mandatory."
)
sys.exit(3)
sys.exit(publish(options))

Expand Down

0 comments on commit 8e1ba1d

Please sign in to comment.