MCPcopy Index your code
hub / github.com/python/mypy / main

Function main

misc/generate_changelog.py:157–206  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

155
156
157def main() -> None:
158 parser = argparse.ArgumentParser(
159 description="Generate draft .md changelog for a mypy public release and print it to stdout."
160 )
161 parser.add_argument("version", help="target mypy version (form X.Y)")
162 parser.add_argument(
163 "--local", action="store_true", help="use local release branch, not origin"
164 )
165 args = parser.parse_args()
166 version: str = args.version
167 local: bool = args.local
168
169 version = version.removeprefix("v")
170
171 if not re.match(r"[0-9]+\.[0-9]+$", version):
172 sys.exit(f"error: Release must be of form X.Y (not {version!r})")
173 major, minor = (int(component) for component in version.split("."))
174
175 if not local:
176 print("Running 'git fetch' to fetch all release branches...")
177 subprocess.run(["git", "fetch"], check=True)
178
179 if minor > 0:
180 prev_major = major
181 prev_minor = minor - 1
182 else:
183 # For a x.0 release, the previous release is the most recent (x-1).y release.
184 all_releases = sorted(find_all_release_branches())
185 if (major, minor) not in all_releases:
186 sys.exit(f"error: Can't find release branch for {major}.{minor} at origin")
187 for i in reversed(range(len(all_releases))):
188 if all_releases[i][0] == major - 1:
189 prev_major, prev_minor = all_releases[i]
190 break
191 else:
192 sys.exit("error: Could not determine previous release")
193 print(f"Generating changelog for {major}.{minor}")
194 print(f"Previous release was {prev_major}.{prev_minor}")
195
196 if local:
197 new_branch = f"release-{major}.{minor}"
198 else:
199 new_branch = f"origin/release-{major}.{minor}"
200 old_branch = f"origin/release-{prev_major}.{prev_minor}"
201
202 changes = find_changes_between_releases(old_branch, new_branch)
203
204 print()
205 for c in changes:
206 print(format_changelog_entry(c))
207
208
209if __name__ == "__main__":

Callers 1

Calls 14

intClass · 0.85
printFunction · 0.85
sortedFunction · 0.85
reversedFunction · 0.85
rangeClass · 0.85
lenFunction · 0.85
format_changelog_entryFunction · 0.85
add_argumentMethod · 0.80
removeprefixMethod · 0.80
exitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…