From df781c2cc422e0f7c80f24736a0cd04159d375de Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Wed, 25 Sep 2024 00:14:29 -0500 Subject: [PATCH 1/8] Remove unmaintained and unused curlylint from linters --- .pre-commit-config.yaml | 10 ---------- pyproject.toml | 30 ------------------------------ 2 files changed, 40 deletions(-) delete mode 100644 pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e701b2b..d5aebb82 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -121,16 +121,6 @@ repos: name: Format JavaScript (Prettier) types: [javascript] -# Lint Jinja -- repo: https://github.com/thibaudcolas/curlylint - rev: v0.13.1 - hooks: - - id: curlylint - name: Lint Jinja templates - types: [html, jinja, twig] - files: 'templates/' - require_serial: true - # Check JSON - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index aff85537..00000000 --- a/pyproject.toml +++ /dev/null @@ -1,30 +0,0 @@ -[tool] - [tool.curlylint] - # include = '\.(html|jinja)$' - # exclude = ''' - - [tool.curlylint.rules] - # All role attributes must be valid. - # See https://www.curlylint.org/docs/rules/aria_role. - aria_role = true - # Forms cannot be rendered with as_table, as_ul, or as_p - # See https://www.curlylint.org/docs/rules/django_forms_rendering. - django_forms_rendering = true - # The `lang` attribute must be "en-US". - # See https://www.curlylint.org/docs/rules/html_has_lang. - html_has_lang = true - # The `alt` attribute must be present. - # See https://www.curlylint.org/docs/rules/image_alt. - image_alt = true - # Use 2 spaces for indent. - # See https://www.curlylint.org/docs/rules/indent. - # indent = 2 - # `user-scalable=no` must not be used, and `maximum-scale` should be 2 or above. - # See https://www.curlylint.org/docs/rules/meta_viewport. - meta_viewport = true - # The `autofocus` attribute must not be used. - # See https://www.curlylint.org/docs/rules/no_autofocus. - no_autofocus = true - # Avoid positive `tabindex` values, change the order of elements on the page instead. - # See https://www.curlylint.org/docs/rules/tabindex_no_positive. - tabindex_no_positive = true From 7b8e70b6a78771efa939c672802e6813d2d8b665 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Wed, 25 Sep 2024 00:25:19 -0500 Subject: [PATCH 2/8] Add Black as pre-commit hook and custom config file for it --- .black.toml | 3 +++ .flake8 | 2 +- .pre-commit-config.yaml | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .black.toml diff --git a/.black.toml b/.black.toml new file mode 100644 index 00000000..e535e4d9 --- /dev/null +++ b/.black.toml @@ -0,0 +1,3 @@ +[tool.black] +line-length = 79 +target-version = ["py38", "py39", "py39", "py310", "py311", "py312", "py313"] diff --git a/.flake8 b/.flake8 index 8a6ca460..79f17803 100644 --- a/.flake8 +++ b/.flake8 @@ -1,6 +1,6 @@ [flake8] count = True -ignore = E123, W504 +ignore = E123, E203, W504 max-doc-length = 79 max-complexity = 15 jobs = 1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d5aebb82..242fca86 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -144,6 +144,15 @@ repos: name: Lint Markdown args: [--fix] +# Format Python +- repo: https://github.com/psf/black-pre-commit-mirror + rev: '24.8.0' + hooks: + - id: black + name: Format Python with Black + args: ['--config', '.black.toml'] + exclude: '\bworkshops\b' + # Check Python - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 From 9e75d1834b30a486e6b8d0a011be43b587e8cd2d Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Wed, 25 Sep 2024 00:31:08 -0500 Subject: [PATCH 3/8] Blacken repository's Python scripts --- doc/conf.py | 32 +++++++------ noxfile.py | 75 ++++++++++++++++++++---------- scripts/generateredirects.py | 90 ++++++++++++++++++++++-------------- scripts/safecopy.py | 38 ++++++++++----- 4 files changed, 151 insertions(+), 84 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index aa6f7eb1..b158ba92 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -18,6 +18,7 @@ # pylint: disable-next = import-error from docutils import nodes + # pylint: disable-next = import-error from docutils.parsers.rst import Directive, directives @@ -69,7 +70,8 @@ # General information about the project. project = "Spyder" copyright = ( # pylint: disable = redefined-builtin - f" 2009-{UTC_DATE.year} Spyder Doc Contributors; MIT License") + f" 2009-{UTC_DATE.year} Spyder Doc Contributors; MIT License" +) author = "The Spyder Doc Contributors" # The version info for the project you're documenting, acts as replacement for @@ -142,7 +144,8 @@ "show_version_warning_banner": True, "switcher": { "json_url": ( - "https://docs.spyder-ide.org/current/_static/versions.json"), + "https://docs.spyder-ide.org/current/_static/versions.json" + ), "version_match": version, }, } @@ -309,7 +312,7 @@ r"https://(www\.)?(\w+\.)?(stackoverflow|stackexchange)\.com/?.*", # Temporary until removed (flaky/no longer used) r"https://(www\.)?openteams\.com/?.*", - ] +] # -- Additional Directives --------------------------------------------------- @@ -327,6 +330,7 @@ # :copyright: (c) 2012 by Danilo Bargen. # :license: BSD 3-clause + def align(argument): """Convert the "align" argument to one of the specified options.""" return directives.choice(argument, ("left", "center", "right")) @@ -366,16 +370,18 @@ def run(self): class Youtube(IFrameVideo): """A specific directive for injecting a Youtube video in a Sphinx doc.""" - html = "".join([ - '
', - '
', - '
', - ]) + html = "".join( + [ + '
', + '
', + '
', + ] + ) def setup(builder): # pylint: disable = unused-argument diff --git a/noxfile.py b/noxfile.py index cd3bc7f7..cacd5396 100644 --- a/noxfile.py +++ b/noxfile.py @@ -57,6 +57,7 @@ # ---- Helpers ---- # + @contextlib.contextmanager def set_log_level(logger=nox.logger.logger, level=logging.CRITICAL): """Context manager to set a logger log level and reset it after.""" @@ -73,16 +74,18 @@ def split_sequence(seq, *, sep="--"): if sep not in seq: seq.append(sep) idx = seq.index(sep) - return seq[:idx], seq[idx + 1:] + return seq[:idx], seq[idx + 1 :] def process_filenames(filenames, source_dir=SOURCE_DIR): """If filepaths are missing the source directory, add it automatically.""" source_dir = Path(source_dir) filenames = [ - str(source_dir / filename) - if source_dir not in Path(filename).resolve().parents - else filename + ( + str(source_dir / filename) + if source_dir not in Path(filename).resolve().parents + else filename + ) for filename in filenames ] return filenames @@ -125,7 +128,8 @@ def construct_sphinx_invocation( cli_options, filenames = split_sequence(list(posargs)) filenames = process_filenames(filenames, source_dir=source_dir) builders, cli_options = extract_option_values( - cli_options, ["--builder", "-b"], split_csv=False) + cli_options, ["--builder", "-b"], split_csv=False + ) builder = builders[-1] if builders else builder build_dir = BUILD_DIR / builder if build_dir is None else build_dir @@ -149,6 +153,7 @@ def construct_sphinx_invocation( # ---- Dispatch ---- # + # Workaround for Nox not (yet) supporting shared venvs # See: https://github.com/wntrblm/nox/issues/167 @nox.session(venv_backend="virtualenv", reuse_venv=True) @@ -156,14 +161,16 @@ def _execute(session): """Dispatch tasks to run in a common environment. Do not run directly.""" if not session.posargs or isinstance(session.posargs[0], str): raise ValueError( - "Must pass a list of functions to execute as first posarg") + "Must pass a list of functions to execute as first posarg" + ) if not session.posargs or session.posargs[0] is not _install: # pylint: disable=too-many-try-statements try: with set_log_level(): session.run( - *CANARY_COMMAND, include_outer_env=False, silent=True) + *CANARY_COMMAND, include_outer_env=False, silent=True + ) except nox.command.CommandFailed: print("Installing dependencies in isolated environment...") _install(session, use_posargs=False) @@ -175,6 +182,7 @@ def _execute(session): # ---- Install ---- # + def _install(session, *, use_posargs=True): """Execute the dependency installation.""" posargs = session.posargs[1:] if use_posargs else () @@ -189,6 +197,7 @@ def install(session): # ---- Utility ---- # + def _build_help(session): """Print Sphinx --help.""" session.run(*BUILD_INVOCATION, "--help") @@ -237,6 +246,7 @@ def clean(session): # --- Set up --- # + def _setup_remotes(session): """Set up the origin and upstream remote repositories.""" remote_cmd = ["git", "remote"] @@ -250,7 +260,8 @@ def _setup_remotes(session): # Get current origin details origin_url_cmd = (*remote_cmd, "get-url", "origin") origin_url = session.run( - *origin_url_cmd, external=True, silent=True, log=False).strip() + *origin_url_cmd, external=True, silent=True, log=False + ).strip() if "https://" not in origin_url: origin_url = origin_url.split(":")[-1] origin_user, origin_repo = origin_url.split("/")[-2:] @@ -268,11 +279,14 @@ def _setup_remotes(session): ) # Set up remotes - existing_remotes = session.run( - *remote_cmd, external=True, silent=True, log=False).strip().split("\n") + existing_remotes = ( + session.run(*remote_cmd, external=True, silent=True, log=False) + .strip() + .split("\n") + ) for remote, user_name, repo_name in ( - ("origin", origin_user, origin_repo), - ("upstream", ORG_NAME, REPO_NAME), + ("origin", origin_user, origin_repo), + ("upstream", ORG_NAME, REPO_NAME), ): action = "set-url" if remote in existing_remotes else "add" fetch_url = REPO_URL_HTTPS.format(user=user_name, repo=repo_name) @@ -281,7 +295,8 @@ def _setup_remotes(session): ssh_url = REPO_URL_SSH.format(user=user_name, repo=repo_name) push_url = ssh_url if ssh else fetch_url session.run( - *remote_cmd, "set-url", "--push", remote, push_url, external=True) + *remote_cmd, "set-url", "--push", remote, push_url, external=True + ) session.run("git", "fetch", "--all", external=True) @@ -303,6 +318,7 @@ def setup(session): # ---- Build ---- # + def _build(session): """Execute the docs build.""" _docs(session) @@ -327,10 +343,12 @@ def autobuild(session): # --- Docs --- # + def _docs(session): """Execute the docs build.""" sphinx_invocation = construct_sphinx_invocation( - posargs=session.posargs[1:]) + posargs=session.posargs[1:] + ) session.run(*sphinx_invocation) @@ -354,7 +372,7 @@ def _autodocs(session): "--port=0", f"--watch={SOURCE_DIR}", "--open-browser", - ] + ], ) session.run(*sphinx_invocation) @@ -368,7 +386,8 @@ def autodocs(session): def _build_languages(session): """Build the docs in multiple languages.""" languages, posargs = extract_option_values( - session.posargs[1:], ("--lang", "--language"), split_csv=True) + session.posargs[1:], ("--lang", "--language"), split_csv=True + ) languages = languages or ALL_LANGUAGES for language in languages: @@ -384,19 +403,20 @@ def _build_languages(session): @nox.session(name="build-languages") def build_languages(session): """Build the project in multiple languages (specify with '--lang').""" - session.notify( - "_execute", posargs=([_build_languages], *session.posargs)) + session.notify("_execute", posargs=([_build_languages], *session.posargs)) @nox.session(name="build-multilanguage") def build_multilanguage(session): """Build the project for deployment in all languages.""" session.notify( - "_execute", posargs=([_build, _build_languages], *session.posargs)) + "_execute", posargs=([_build, _build_languages], *session.posargs) + ) # ---- Deploy ---- # + def _serve(session=None): """Open the docs in a web browser.""" _serve_docs(session) @@ -430,7 +450,8 @@ def _prepare_multiversion(_session=None): latest_version_dir = HTML_BUILD_DIR / str(LATEST_VERSION) shutil.copytree( - HTML_BUILD_DIR, latest_version_dir, copy_function=shutil.move) + HTML_BUILD_DIR, latest_version_dir, copy_function=shutil.move + ) safecopy.copy_dir_if_not_existing( source_dir=str(LATEST_VERSION), target_dir="current", @@ -465,6 +486,7 @@ def build_deployment(session): # ---- Check ---- # + def _install_hooks(session): """Run pre-commit install to install the project's hooks.""" session.run( @@ -505,7 +527,8 @@ def _lint(session): """Run linting on the project via pre-commit.""" extra_options = ["--show-diff-on-failure"] if CI else [] session.run( - "pre-commit", "run", "--all", *extra_options, *session.posargs[1:]) + "pre-commit", "run", "--all", *extra_options, *session.posargs[1:] + ) @nox.session @@ -517,7 +540,8 @@ def lint(session): def _linkcheck(session): """Run Sphinx linkcheck on the docs.""" sphinx_invocation = construct_sphinx_invocation( - posargs=session.posargs[1:], builder="linkcheck") + posargs=session.posargs[1:], builder="linkcheck" + ) session.run(*sphinx_invocation) @@ -529,10 +553,12 @@ def linkcheck(session): # ---- Translation ---- # + def _build_pot(session): """Build the docs with Sphinx -b gettext to extract .pot files.""" sphinx_invocation = construct_sphinx_invocation( - posargs=session.posargs[1:], builder=GETTEXT_BUILDER) + posargs=session.posargs[1:], builder=GETTEXT_BUILDER + ) session.run(*sphinx_invocation) @@ -564,7 +590,8 @@ def copy_pot(_session): def update_pot(session): """Rebuild gettext .pot files and update the existing ones.""" session.notify( - "_execute", posargs=([_build_pot, _copy_pot], *session.posargs)) + "_execute", posargs=([_build_pot, _copy_pot], *session.posargs) + ) def _update_po(session): diff --git a/scripts/generateredirects.py b/scripts/generateredirects.py index 80857db7..2fae2223 100755 --- a/scripts/generateredirects.py +++ b/scripts/generateredirects.py @@ -20,12 +20,8 @@ def generate_redirect( - canonical_path, - canonical_dir, - redirect_dir="", - base_path="", - base_url="/" - ): + canonical_path, canonical_dir, redirect_dir="", base_path="", base_url="/" +): """Generate an individual HTML redirect from one location to another.""" base_path = Path(base_path).resolve() canonical_dir = base_path / canonical_dir @@ -33,32 +29,36 @@ def generate_redirect( if base_url[-1] != "/": base_url += "/" - redirect_output_path = ( - redirect_dir / canonical_path.relative_to(canonical_dir)) - redirect_url = Path(os.path.relpath( - canonical_path, start=redirect_output_path.parent)) + redirect_output_path = redirect_dir / canonical_path.relative_to( + canonical_dir + ) + redirect_url = Path( + os.path.relpath(canonical_path, start=redirect_output_path.parent) + ) canonical_url = canonical_path.relative_to(base_path) output_text = REDIRECT_TEXT.format( redirect_url=redirect_url.as_posix(), base_url=base_url, canonical_url=canonical_url.as_posix(), - ) + ) redirect_output_path.parent.mkdir(parents=True, exist_ok=True) - with open(redirect_output_path, mode="w", - encoding="utf-8", newline="\n") as redirect_file: + with open( + redirect_output_path, mode="w", encoding="utf-8", newline="\n" + ) as redirect_file: redirect_file.write(output_text) return redirect_output_path def generate_redirects( - canonical_dir, - base_path="", - match_glob="**/*.html", - verbose=False, - **redirect_kwargs): + canonical_dir, + base_path="", + match_glob="**/*.html", + verbose=False, + **redirect_kwargs, +): """Generate HTML redirect from one set of locations to another.""" base_path = Path(base_path).resolve() @@ -68,12 +68,15 @@ def generate_redirects( canonical_path=canonical_path, canonical_dir=canonical_dir, base_path=base_path, - **redirect_kwargs) + **redirect_kwargs, + ) redirect_paths.append(redirect_path) if verbose: - print("Generated redirect from " - f"{redirect_path.relative_to(base_path).as_posix()} " - f"--> {canonical_path.relative_to(base_path).as_posix()}") + print( + "Generated redirect from " + f"{redirect_path.relative_to(base_path).as_posix()} " + f"--> {canonical_path.relative_to(base_path).as_posix()}" + ) return redirect_paths @@ -82,31 +85,48 @@ def generate_arg_parser(): """Create and return the argument parser for the redirect script.""" arg_parser = argparse.ArgumentParser( description="Generate redirects given a directory of HTML files", - argument_default=argparse.SUPPRESS) + argument_default=argparse.SUPPRESS, + ) arg_parser.add_argument( - "canonical_dir", help=( + "canonical_dir", + help=( "The directory of pages to build redirects to, " - "relative to base_dir.")) + "relative to base_dir." + ), + ) arg_parser.add_argument( - "--redirect-dir", help=( + "--redirect-dir", + help=( "The dir that should be redirected from and " "the redirect files should be written to, " - "relative to base_path. By default, base_path.")) + "relative to base_path. By default, base_path." + ), + ) arg_parser.add_argument( - "--base-path", help=( + "--base-path", + help=( "The path that canonical_dir and redirect_dir " - "are relative to; defaults to the working dir.")) + "are relative to; defaults to the working dir." + ), + ) arg_parser.add_argument( - "--base-url", help=( - "Full URL for the site, for use with the canonical tag.")) + "--base-url", + help=("Full URL for the site, for use with the canonical tag."), + ) arg_parser.add_argument( - "--match-glob", help=( + "--match-glob", + help=( "The glob pattern to match files to redirect to " - "in canonical_dir. By default, '**/*.html'.")) + "in canonical_dir. By default, '**/*.html'." + ), + ) arg_parser.add_argument( - "-v", "--verbose", action="store_true", help=( - "If passed, prints each redirect generated.")) + "-v", + "--verbose", + action="store_true", + help=("If passed, prints each redirect generated."), + ) return arg_parser diff --git a/scripts/safecopy.py b/scripts/safecopy.py index 1dd4ab57..69ee8558 100755 --- a/scripts/safecopy.py +++ b/scripts/safecopy.py @@ -8,7 +8,8 @@ def copy_dir_if_not_existing( - source_dir, target_dir, base_path="", verbose=False): + source_dir, target_dir, base_path="", verbose=False +): """Copy a directory to another path if the target doesn't already exist.""" base_path = Path(base_path) source_dir = Path(source_dir) @@ -21,13 +22,17 @@ def copy_dir_if_not_existing( if not source_dir.exists(): if verbose: - print(f"Source directory {source_dir} doesn't exist; " - f"skipping copy to {target_dir}") + print( + f"Source directory {source_dir} doesn't exist; " + f"skipping copy to {target_dir}" + ) return False if target_dir.exists(): if verbose: - print(f"Target directory {target_dir} exists; " - f"skipping copy from {source_dir}") + print( + f"Target directory {target_dir} exists; " + f"skipping copy from {source_dir}" + ) return False print(f"Copying {source_dir} to {target_dir}") shutil.copytree(source_dir, target_dir) @@ -38,19 +43,28 @@ def generate_arg_parser(): """Create and return the argument parser for the safe copy script.""" arg_parser = argparse.ArgumentParser( description="Copies a directory, skipping if the target exists", - argument_default=argparse.SUPPRESS) + argument_default=argparse.SUPPRESS, + ) arg_parser.add_argument( - "source_dir", help="The directory from which to copy") + "source_dir", help="The directory from which to copy" + ) arg_parser.add_argument( - "target_dir", help="The directory to which to copy") + "target_dir", help="The directory to which to copy" + ) arg_parser.add_argument( - "--base-path", help=( + "--base-path", + help=( "The path that source_dir and target_dir are relative to " - "if not absolute; defaults to the working dir.")) + "if not absolute; defaults to the working dir." + ), + ) arg_parser.add_argument( - "-v", "--verbose", action="store_true", help=( - "If passed, prints details about the copy attempt.")) + "-v", + "--verbose", + action="store_true", + help=("If passed, prints details about the copy attempt."), + ) return arg_parser From 3ad7314441d636c242068af16d881c1062ba17c7 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Wed, 25 Sep 2024 00:52:07 -0500 Subject: [PATCH 4/8] Ignore linkcheck errors for flaky figshare.com URLs --- doc/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/conf.py b/doc/conf.py index b158ba92..bdc886d9 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -307,6 +307,7 @@ r"https://(www\.)?software\.opensuse\.org/?.*", r"https://(www\.)?packages\.ubuntu\.com/?.*", r"https://(www\.)?github\.com/.+/commit/.+", + r"https://(www\.)?figshare\.com/?.*", # Blocks GitHub Actions r"https://(www\.)?(\w+\.)?reddit\.com/?.*", r"https://(www\.)?(\w+\.)?(stackoverflow|stackexchange)\.com/?.*", From c9abaf2ea9534cc2984412d9b53633b025b9218f Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 26 Sep 2024 03:54:29 -0500 Subject: [PATCH 5/8] Pin eslint to fix dep conflict issue & update dates --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 242fca86..6ce3aa01 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -102,7 +102,7 @@ repos: # Lint and fix JavaScript - repo: https://github.com/eslint/eslint - rev: v9.11.0 + rev: v9.9.0 # Pin to fix dep conflict on install; see eslint/eslint# hooks: - id: eslint name: Lint and fix JavaScript (ESLint) @@ -111,7 +111,7 @@ repos: - 'eslint-plugin-import@2.30.0' - 'eslint-plugin-n@17.10.3' - 'eslint-plugin-promise@7.1.0' - - 'neostandard@0.11.5' + - 'neostandard@0.11.6' # Format JavaScript with Prettier - repo: https://github.com/rbubley/mirrors-prettier From c173cccf0c0567e708a5de881d3c9d8526ce39f4 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 26 Sep 2024 04:04:40 -0500 Subject: [PATCH 6/8] Update dependency update dates to 2024-09-25 --- .pre-commit-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6ce3aa01..172ad7ab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,10 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks -# Baseline hooks and config updated 2023-11-01 -# Web hooks and config updated 2023-11-01 -# Docs hooks and config updated 2024-01-29 -# Python hooks and config updated 2024-01-29 +# Baseline hooks and config updated 2024-09-25 +# Web hooks and config updated 2024-09-25 +# Docs hooks and config updated 2024-09-25 +# Python hooks and config updated 2024-09-25 minimum_pre_commit_version: '2.10.0' @@ -102,7 +102,7 @@ repos: # Lint and fix JavaScript - repo: https://github.com/eslint/eslint - rev: v9.9.0 # Pin to fix dep conflict on install; see eslint/eslint# + rev: v9.9.0 # Pin to fix dep conflict on install; see eslint/eslint#18956 hooks: - id: eslint name: Lint and fix JavaScript (ESLint) @@ -169,7 +169,7 @@ repos: exclude: '\bworkshops\b' - repo: https://github.com/pycqa/pylint - rev: v3.3.0 + rev: v3.3.1 hooks: - id: pylint name: Lint Python with Pylint From 5156274b0a145767428cf2df1699f82f7713d295 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Wed, 2 Oct 2024 20:20:35 -0500 Subject: [PATCH 7/8] Add .git-blame-ignore-revs for Black commit & add to Nox setup --- .git-blame-ignore-revs | 3 +++ noxfile.py | 31 ++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..441a153e --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,3 @@ +# Blacken scripts + +9e75d1834b30a486e6b8d0a011be43b587e8cd2d diff --git a/noxfile.py b/noxfile.py index cacd5396..8d95c881 100644 --- a/noxfile.py +++ b/noxfile.py @@ -26,6 +26,8 @@ REPO_URL_HTTPS = "https://github.com/{user}/{repo}.git" REPO_URL_SSH = "git@github.com:{user}/{repo}.git" +IGNORE_REVS_FILE = ".git-blame-ignore-revs" + CANARY_COMMAND = ("sphinx-build", "--version") BUILD_INVOCATION = ("python", "-m", "sphinx") SOURCE_DIR = Path("doc").resolve() @@ -307,12 +309,39 @@ def setup_remotes(session): session.notify("_execute", posargs=([_setup_remotes], *session.posargs)) +def _ignore_revs(session): + """Configure the Git ignore revs file to the repo default.""" + if not IGNORE_REVS_FILE: + return + session.run( + "git", + "config", + "blame.ignoreRevsFile", + IGNORE_REVS_FILE, + external=True, + ) + + +@nox.session(name="ignore-revs") +def ignore_revs(session): + """Configure Git to ignore noisy revisions.""" + _ignore_revs(session) + + @nox.session() def setup(session): """Set up the project; pass --https or --ssh to specify Git URL type.""" session.notify( "_execute", - posargs=([_setup_remotes, _install_hooks, _clean], *session.posargs), + posargs=( + [ + _ignore_revs, + _setup_remotes, + _install_hooks, + _clean, + ], + *session.posargs, + ), ) From 28f8e03fd905d541c7f1857c150d8f81bd34ee70 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Wed, 2 Oct 2024 20:33:03 -0500 Subject: [PATCH 8/8] Improve perf of setup-remotes Nox command by skipping env setup --- noxfile.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index 8d95c881..a4f37ab2 100644 --- a/noxfile.py +++ b/noxfile.py @@ -252,9 +252,12 @@ def clean(session): def _setup_remotes(session): """Set up the origin and upstream remote repositories.""" remote_cmd = ["git", "remote"] - posargs = list(session.posargs[1:]) + posargs = list(session.posargs) https = "--https" in posargs ssh = "--ssh" in posargs + + if posargs and not isinstance(posargs[0], str): + posargs = posargs[1:] username_args = extract_option_values(posargs, "--username")[0] if https == ssh: session.error("Exactly one of '--https' or '--ssh' must be passed") @@ -306,7 +309,7 @@ def _setup_remotes(session): @nox.session(name="setup-remotes") def setup_remotes(session): """Set up the Git remotes; pass --https or --ssh to specify URL type.""" - session.notify("_execute", posargs=([_setup_remotes], *session.posargs)) + _setup_remotes(session) def _ignore_revs(session):