Skip to content

Commit

Permalink
Fix autoupdate tools for new tox
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Dec 11, 2022
1 parent abff9f2 commit 022df2d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions hypothesis-python/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ toxworkdir={env:TOX_WORK_DIR:.tox}
[testenv]
deps =
-r../requirements/test.txt
whitelist_externals=
allowlist_externals =
bash
passenv=
HOME
Expand Down Expand Up @@ -141,7 +141,7 @@ commands=
[testenv:coverage]
deps =
-r../requirements/coverage.txt
whitelist_externals=
allowlist_externals =
rm
setenv=
PYTHONDEVMODE=1
Expand Down
11 changes: 2 additions & 9 deletions tooling/src/hypothesistooling/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,9 @@ def upgrade_requirements():
compile_requirements(upgrade=True)
subprocess.call(["./build.sh", "format"], cwd=tools.ROOT) # exits 1 if changed
if has_diff(hp.PYTHON_SRC) and not os.path.isfile(hp.RELEASE_FILE):
if has_diff(f"{hp.PYTHON_SRC}/hypothesis/vendor/tlds-alpha-by-domain.txt"):
msg = (
"our vendored `list of top-level domains "
"<https://www.iana.org/domains/root/db>`__,\nwhich is used by the "
"provisional :func:`~hypothesis.provisional.domains` strategy."
)
else:
msg = "our autoformatting tools, improving our code style without any API changes."
msg = hp.get_autoupdate_message(domainlist_changed=has_diff(hp.DOMAINS_LIST))
with open(hp.RELEASE_FILE, mode="w") as f:
f.write(f"RELEASE_TYPE: patch\n\nThis patch updates {msg}\n")
f.write(f"RELEASE_TYPE: patch\n\n" + msg)
update_python_versions()
subprocess.call(["git", "add", "."], cwd=tools.ROOT)

Expand Down
16 changes: 16 additions & 0 deletions tooling/src/hypothesistooling/projects/hypothesispython.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

PYTHON_SRC = os.path.join(HYPOTHESIS_PYTHON, "src")
PYTHON_TESTS = os.path.join(HYPOTHESIS_PYTHON, "tests")
DOMAINS_LIST = os.path.join(
PYTHON_SRC, "hypothesis", "vendor", "tlds-alpha-by-domain.txt"
)

RELEASE_FILE = os.path.join(HYPOTHESIS_PYTHON, "RELEASE.rst")

Expand Down Expand Up @@ -234,3 +237,16 @@ def latest_version():

def tag_name():
return PYTHON_TAG_PREFIX + __version__


def get_autoupdate_message(domainlist_changed: bool) -> str:
if domainlist_changed:
return (
"This patch updates our vendored `list of top-level domains "
"<https://www.iana.org/domains/root/db>`__,\nwhich is used by the "
"provisional :func:`~hypothesis.provisional.domains` strategy.\n"
)
return (
"This patch updates our autoformatting tools, "
"improving our code style without any API changes."
)
2 changes: 2 additions & 0 deletions whole-repo-tests/test_release_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def test_release_file_exists_and_is_valid(project):
def test_release_file_has_no_merge_conflicts():
_, message = rm.parse_release_file(hp.RELEASE_FILE)
assert "<<<" not in message, "Merge conflict in RELEASE.rst"
if message in {hp.get_autoupdate_message(x).strip() for x in (True, False)}:
return
_, *recent_changes, _ = hp.CHANGELOG_ANCHOR.split(hp.changelog(), maxsplit=12)
for entry in recent_changes:
_, version, old_msg = (x.strip() for x in hp.CHANGELOG_BORDER.split(entry))
Expand Down

0 comments on commit 022df2d

Please sign in to comment.