zrhoffman commented on a change in pull request #5506: URL: https://github.com/apache/trafficcontrol/pull/5506#discussion_r574052640
########## File path: .github/actions/pr-to-update-go/pr_to_update_go/__main__.py ########## @@ -0,0 +1,32 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +import sys + +from github.MainClass import Github + +from pr_to_update_go.GoPRMaker import GoPRMaker +from pr_to_update_go.constants import ENV_GITHUB_TOKEN + + +def main() -> None: + try: + github_token: str = os.environ[ENV_GITHUB_TOKEN] + except KeyError: + print(f'Environment variable {ENV_GITHUB_TOKEN} must be defined.') + sys.exit(1) + gh = Github(login_or_token=github_token) + GoPRMaker(gh).run() + + +main() Review comment: If the filename is `__main__.py`, then `__name__` is always equal to `'__main__'`. ########## File path: .github/actions/pr-to-update-go/pr_to_update_go/pr_template.md ########## @@ -0,0 +1,120 @@ +<!-- +************ STOP!! ************ +If this Pull Request is intended to fix a security vulnerability, DO NOT submit it! Instead, contact +the Apache Software Foundation Security Team at [email protected] and follow the +guidelines at https://www.apache.org/security/ regarding vulnerability disclosure. +--> +## What does this PR (Pull Request) do? +<!-- Explain the changes you made here. If this fixes an Issue, identify it by +replacing the text in the checkbox item with the Issue number e.g. + +- [x] This PR fixes #9001 OR is not related to any Issue + +^ This will automatically close Issue number 9001 when the Pull Request is +merged (The '#' is important). + +Be sure you check the box properly, see the "The following criteria are ALL +met by this PR" section for details. +--> Review comment: Removed comments in de4b55e9f3 ########## File path: .github/actions/pr-to-update-go/pr_to_update_go/GoPRMaker.py ########## @@ -0,0 +1,210 @@ +#!/usr/bin/env python3 +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import json +import os +import re +import requests +import sys + +from github.InputGitAuthor import InputGitAuthor +from github.Label import Label +from requests import Response + +from github.Branch import Branch +from github.GithubException import BadCredentialsException, GithubException, UnknownObjectException +from github.MainClass import Github +from github.Milestone import Milestone +from github.PaginatedList import PaginatedList +from github.PullRequest import PullRequest +from github.Repository import Repository + +from pr_to_update_go.constants import ENV_GITHUB_TOKEN, GO_VERSION_URL, ENV_GITHUB_REPOSITORY, \ + ENV_GITHUB_REPOSITORY_OWNER, GO_REPO_NAME, RELEASE_PAGE_URL, ENV_GO_VERSION_FILE, ENV_GIT_AUTHOR_NAME, \ + GIT_AUTHOR_EMAIL_TEMPLATE + + +class GoPRMaker: + gh: Github + latest_go_version: str + repo: Repository + + def __init__(self, gh: Github) -> None: + self.gh = gh + repo_name: str = self.get_repo_name() + self.repo = self.get_repo(repo_name) + + def run(self) -> None: Review comment: I like `-> None:` because then PyCharm gives you warnings when trying to a value returned by a function whose return type is `None` without needing to analyze control flow. For example, on line 6 of this snippet, ```python def a() -> None: if False: return 1 print('Returns nothing') b: int = a() ``` it warns > Expected type 'int', got 'None' instead. But that warning is gone if `-> None` is removed. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
