Skip to content

Commit 4043890

Browse files
Manushpm8claude
andcommitted
Judge every exact pin, rather than only the ones already right
Building the pattern from the five real names made a pin on a name nothing publishes invisible instead of wrong, which is the regression it exists to catch. It matches any exact pin, keeps the ones spelled with a first-party stem, and fails on a name outside the five as well as on a wrong version. All three spellings fail it: sdm-api==1.0.0, structured_data_models_api==1.0.0 and the right name at the wrong version. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 4e64658 commit 4043890

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

‎tests/test_release_contract.py‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,28 +1120,33 @@ def test_every_first_party_pin_names_the_version_being_released(self):
11201120
declared = self._declared_version()
11211121
distributions = {name for name in _distributions()}
11221122

1123-
# Built from the distributions themselves rather than written out:
1124-
# a name spelled only here would match a pin nothing publishes.
1123+
# Any exactly pinned requirement, then judged. Reading only the five
1124+
# real names would make a pin on a name nothing publishes -- a
1125+
# survivor of the rename, or a typo -- invisible rather than wrong,
1126+
# which is the regression this is here to catch. Everything first
1127+
# party is spelled with one of these two stems, and nothing else
1128+
# pinned here is.
1129+
ours = re.compile(r'^(?:structured[-_]data[-_]models|sdm)[-_]', re.I)
11251130
pattern = re.compile(
1126-
r'(?P<name>'
1127-
+ '|'.join(re.escape(one) for one in sorted(distributions))
1128-
+ r')(?:\[[^\]]*\])?==(?P<version>[0-9][^\'"\s,]*)'
1131+
r'(?P<name>[A-Za-z0-9][A-Za-z0-9._-]*)'
1132+
r'(?:\[[^\]]*\])?==(?P<version>[0-9][^\'"\s,]*)'
11291133
)
11301134
wrong = []
11311135
for source in sorted(PACKAGES.glob('*/pyproject.toml')) + sorted(
11321136
PACKAGES.glob('*/setup.py')
11331137
):
11341138
for match in pattern.finditer(source.read_text()):
1135-
if match.group('name') not in distributions:
1139+
name = match.group('name')
1140+
if not ours.match(name):
11361141
continue
1137-
if match.group('version') != declared:
1138-
wrong.append(
1139-
f'{source.relative_to(REPO)}: '
1140-
f'{match.group(0)} but the release is {declared}'
1141-
)
1142+
where = f'{source.relative_to(REPO)}: {match.group(0)}'
1143+
if name not in distributions:
1144+
wrong.append(f'{where} names no distribution we publish')
1145+
elif match.group('version') != declared:
1146+
wrong.append(f'{where} but the release is {declared}')
11421147
assert not wrong, (
1143-
'a first-party pin names a version other than the one being '
1144-
'released:\n' + '\n'.join(wrong)
1148+
'a first-party pin names a version, or a distribution, other '
1149+
'than the one being released:\n' + '\n'.join(wrong)
11451150
)
11461151

11471152
def test_every_distribution_declares_the_same_licence(self):

0 commit comments

Comments
 (0)