@@ -59,7 +59,15 @@ def check_sdist(dist: Path, version: str) -> None:
59
59
with tarfile .open (sdist ) as f :
60
60
version_py = f .extractfile (f"{ sdist .name [:- len ('.tar.gz' )]} /mypy/version.py" )
61
61
assert version_py is not None
62
- assert f"'{ version } '" in version_py .read ().decode ("utf-8" )
62
+ version_py_contents = version_py .read ().decode ("utf-8" )
63
+
64
+ # strip a git hash from our version, if necessary, since that's not present in version.py
65
+ match = re .match (r"(.*\+dev).*$" , version )
66
+ hashless_version = match .group (1 ) if match else version
67
+
68
+ assert (
69
+ f"'{ hashless_version } '" in version_py_contents
70
+ ), "Version does not match version.py in sdist"
63
71
64
72
65
73
def spot_check_dist (dist : Path , version : str ) -> None :
@@ -92,7 +100,11 @@ def upload_dist(dist: Path, dry_run: bool = True) -> None:
92
100
93
101
94
102
def upload_to_pypi (version : str , dry_run : bool = True ) -> None :
95
- assert re .match (r"0\.[0-9]{3}$" , version )
103
+ assert re .match (r"v?0\.[0-9]{3}(\+\S+)?$" , version )
104
+ if "dev" in version :
105
+ assert dry_run , "Must use --dry-run with dev versions of mypy"
106
+ if version .startswith ("v" ):
107
+ version = version [1 :]
96
108
97
109
target_dir = tempfile .mkdtemp ()
98
110
dist = Path (target_dir ) / "dist"
0 commit comments