Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 1, 2024
1 parent b0aee9f commit a550fa8
Show file tree
Hide file tree
Showing 118 changed files with 3,915 additions and 1,274 deletions.
9 changes: 7 additions & 2 deletions doc/en/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("how-to/usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"], 1)]
man_pages = [
("how-to/usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"], 1)
]


# -- Options for Epub output ---------------------------------------------------
Expand Down Expand Up @@ -413,7 +415,10 @@
master_doc,
"pytest",
"pytest Documentation",
("Holger Krekel@*Benjamin Peterson@*Ronny Pfannschmidt@*" "Floris Bruynooghe@*others"),
(
"Holger Krekel@*Benjamin Peterson@*Ronny Pfannschmidt@*"
"Floris Bruynooghe@*others"
),
"pytest",
"simple powerful testing with Python",
"Programming",
Expand Down
4 changes: 3 additions & 1 deletion doc/en/example/assertion/failure_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ class A:
a = 1

b = 2
assert A.a == b, "A.a appears not to be b\nor does not appear to be b\none of those"
assert (
A.a == b
), "A.a appears not to be b\nor does not appear to be b\none of those"

def test_custom_repr(self):
class JSON:
Expand Down
4 changes: 3 additions & 1 deletion doc/en/example/customdirectory/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def collect(self):
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
ihook = self.ihook
for file in manifest["files"]:
yield from ihook.pytest_collect_file(file_path=self.path / file, parent=self)
yield from ihook.pytest_collect_file(
file_path=self.path / file, parent=self
)


@pytest.hookimpl
Expand Down
8 changes: 6 additions & 2 deletions extra/get_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ def report(issues):
import argparse

parser = argparse.ArgumentParser("process bitbucket issues")
parser.add_argument("--refresh", action="store_true", help="invalidate cache, refresh issues")
parser.add_argument("--cache", action="store", default="issues.json", help="cache file")
parser.add_argument(
"--refresh", action="store_true", help="invalidate cache, refresh issues"
)
parser.add_argument(
"--cache", action="store", default="issues.json", help="cache file"
)
args = parser.parse_args()
main(args)
4 changes: 3 additions & 1 deletion scripts/generate-gh-release-notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def extract_changelog_entries_for(version: str) -> str:


def convert_rst_to_md(text: str) -> str:
result = pypandoc.convert_text(text, "md", format="rst", extra_args=["--wrap=preserve"])
result = pypandoc.convert_text(
text, "md", format="rst", extra_args=["--wrap=preserve"]
)
assert isinstance(result, str), repr(result)
return result

Expand Down
12 changes: 9 additions & 3 deletions scripts/prepare-release-pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def login(token: str) -> Repository:
return github.repository(owner, repo)


def prepare_release_pr(base_branch: str, is_major: bool, token: str, prerelease: str) -> None:
def prepare_release_pr(
base_branch: str, is_major: bool, token: str, prerelease: str
) -> None:
print()
print(f"Processing release for branch {Fore.CYAN}{base_branch}")

Expand All @@ -72,7 +74,9 @@ def prepare_release_pr(base_branch: str, is_major: bool, token: str, prerelease:
is_feature_release = bool(features or breaking)

try:
version = find_next_version(base_branch, is_major, is_feature_release, prerelease)
version = find_next_version(
base_branch, is_major, is_feature_release, prerelease
)
except InvalidFeatureRelease as e:
print(f"{Fore.RED}{e}")
raise SystemExit(1)
Expand Down Expand Up @@ -142,7 +146,9 @@ def prepare_release_pr(base_branch: str, is_major: bool, token: str, prerelease:
print(f"Pull request {Fore.CYAN}{pr.url}{Fore.RESET} created.")


def find_next_version(base_branch: str, is_major: bool, is_feature_release: bool, prerelease: str) -> str:
def find_next_version(
base_branch: str, is_major: bool, is_feature_release: bool, prerelease: str
) -> str:
output = check_output(["git", "tag"], encoding="UTF-8")
valid_versions = []
for v in output.splitlines():
Expand Down
42 changes: 32 additions & 10 deletions scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,24 @@ def announce(version: str, template_name: str, doc_version: str) -> None:
stdout = check_output(["git", "describe", "--abbrev=0", "--tags"], encoding="UTF-8")
last_version = stdout.strip()

stdout = check_output(["git", "log", f"{last_version}..HEAD", "--format=%aN"], encoding="UTF-8")
stdout = check_output(
["git", "log", f"{last_version}..HEAD", "--format=%aN"], encoding="UTF-8"
)

contributors = {name for name in stdout.splitlines() if not name.endswith("[bot]") and name != "pytest bot"}
contributors = {
name
for name in stdout.splitlines()
if not name.endswith("[bot]") and name != "pytest bot"
}

template_text = Path(__file__).parent.joinpath(template_name).read_text(encoding="UTF-8")
template_text = (
Path(__file__).parent.joinpath(template_name).read_text(encoding="UTF-8")
)

contributors_text = "\n".join(f"* {name}" for name in sorted(contributors)) + "\n"
text = template_text.format(version=version, contributors=contributors_text, doc_version=doc_version)
text = template_text.format(
version=version, contributors=contributors_text, doc_version=doc_version
)

target = Path(__file__).parent.joinpath(f"../doc/en/announce/release-{version}.rst")
target.write_text(text, encoding="UTF-8")
Expand All @@ -40,9 +50,13 @@ def announce(version: str, template_name: str, doc_version: str) -> None:
if line != new_line:
lines.insert(index, new_line)
index_path.write_text("\n".join(lines) + "\n", encoding="UTF-8")
print(f"{Fore.CYAN}[generate.announce] {Fore.RESET}Updated {index_path.name}")
print(
f"{Fore.CYAN}[generate.announce] {Fore.RESET}Updated {index_path.name}"
)
else:
print(f"{Fore.CYAN}[generate.announce] {Fore.RESET}Skip {index_path.name} (already contains release)")
print(
f"{Fore.CYAN}[generate.announce] {Fore.RESET}Skip {index_path.name} (already contains release)"
)
break

check_call(["git", "add", str(target)])
Expand All @@ -59,7 +73,9 @@ def regen(version: str) -> None:

def fix_formatting() -> None:
"""Runs pre-commit in all files to ensure they are formatted correctly"""
print(f"{Fore.CYAN}[generate.fix linting] {Fore.RESET}Fixing formatting using pre-commit")
print(
f"{Fore.CYAN}[generate.fix linting] {Fore.RESET}Fixing formatting using pre-commit"
)
call(["pre-commit", "run", "--all-files"])


Expand All @@ -69,7 +85,9 @@ def check_links() -> None:
check_call(["tox", "-e", "docs-checklinks"])


def pre_release(version: str, template_name: str, doc_version: str, *, skip_check_links: bool) -> None:
def pre_release(
version: str, template_name: str, doc_version: str, *, skip_check_links: bool
) -> None:
"""Generates new docs, release announcements and creates a local tag."""
announce(version, template_name, doc_version)
regen(version)
Expand All @@ -96,8 +114,12 @@ def main() -> None:
init(autoreset=True)
parser = argparse.ArgumentParser()
parser.add_argument("version", help="Release version")
parser.add_argument("template_name", help="Name of template file to use for release announcement")
parser.add_argument("doc_version", help="For prereleases, the version to link to in the docs")
parser.add_argument(
"template_name", help="Name of template file to use for release announcement"
)
parser.add_argument(
"doc_version", help="For prereleases, the version to link to in the docs"
)
parser.add_argument("--skip-check-links", action="store_true", default=False)
options = parser.parse_args()
pre_release(
Expand Down
4 changes: 3 additions & 1 deletion scripts/towncrier-draft-to-file.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ def main() -> int:
Platform-agnostic wrapper script for towncrier.
Fixes the issue (#7251) where Windows users are unable to natively run tox -e docs to build pytest docs.
"""
with open("doc/en/_changelog_towncrier_draft.rst", "w", encoding="utf-8") as draft_file:
with open(
"doc/en/_changelog_towncrier_draft.rst", "w", encoding="utf-8"
) as draft_file:
return call(("towncrier", "--draft"), stdout=draft_file)


Expand Down
11 changes: 9 additions & 2 deletions scripts/update-plugin-list.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ def escape_rst(text: str) -> str:
Rudimentary attempt to escape special RST characters to appear as
plain text.
"""
text = text.replace("*", "\\*").replace("<", "\\<").replace(">", "\\>").replace("`", "\\`")
text = (
text.replace("*", "\\*")
.replace("<", "\\<")
.replace(">", "\\>")
.replace("`", "\\`")
)
text = re.sub(r"_\b", "", text)
return text

Expand Down Expand Up @@ -162,7 +167,9 @@ def version_sort_key(version_string: str) -> Any:
releases = response.json()["releases"]
for release in sorted(releases, key=version_sort_key, reverse=True):
if releases[release]:
release_date = datetime.date.fromisoformat(releases[release][-1]["upload_time_iso_8601"].split("T")[0])
release_date = datetime.date.fromisoformat(
releases[release][-1]["upload_time_iso_8601"].split("T")[0]
)
last_release = release_date.strftime("%b %d, %Y")
break
name = f':pypi:`{info["name"]}`'
Expand Down
Loading

0 comments on commit a550fa8

Please sign in to comment.