From cca2527068f58fd3a4bffb3664a05d9b982e850d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:52:28 +0000 Subject: [PATCH 1/7] chore: update pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/python-jsonschema/check-jsonschema: 0.31.3 → 0.32.1](https://github.com/python-jsonschema/check-jsonschema/compare/0.31.3...0.32.1) - [github.com/astral-sh/ruff-pre-commit: v0.9.10 → v0.11.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.10...v0.11.4) --- .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 ff45aea..7ba061e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.31.3 + rev: 0.32.1 hooks: - id: check-github-workflows @@ -67,7 +67,7 @@ repos: - id: rst-inline-touching-normal - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.10 + rev: v0.11.4 hooks: - id: ruff types_or: [python, jupyter] From e053f3afe732ce7027238b784ae648ecb1a614d0 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 29 Apr 2025 13:54:32 +0200 Subject: [PATCH 2/7] modernize some pathlib for linter --- jupyter_core/command.py | 7 ++++--- jupyter_core/migrate.py | 21 ++++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/jupyter_core/command.py b/jupyter_core/command.py index abc2930..0e10171 100644 --- a/jupyter_core/command.py +++ b/jupyter_core/command.py @@ -92,14 +92,15 @@ def list_subcommands() -> list[str]: # construct a set of `('foo', 'bar') from `jupyter-foo-bar` for d in _path_with_self(): try: - names = os.listdir(d) + bin_paths = Path(d).iterdir() except OSError: continue - for name in names: + for path in bin_paths: + name = path.name if name.startswith("jupyter-"): if sys.platform.startswith("win"): # remove file-extension on Windows - name = os.path.splitext(name)[0] # noqa: PTH122, PLW2901 + name = path.stem subcommand_tuples.add(tuple(name.split("-")[1:])) # build a set of subcommand strings, excluding subcommands whose parents are defined subcommands = set() diff --git a/jupyter_core/migrate.py b/jupyter_core/migrate.py index e70678a..4b74781 100644 --- a/jupyter_core/migrate.py +++ b/jupyter_core/migrate.py @@ -86,17 +86,19 @@ def get_ipython_dir() -> str: def migrate_dir(src: str, dst: str) -> bool: """Migrate a directory from src to dst""" log = get_logger() - if not os.listdir(src): + src_path = Path(src) + dst_path = Path(dst) + if not any(src_path.iterdir()): log.debug("No files in %s", src) return False - if Path(dst).exists(): - if os.listdir(dst): + if dst_path.exists(): + if any(dst_path.iterdir()): # already exists, non-empty log.debug("%s already exists", dst) return False - Path(dst).rmdir() + dst_path.rmdir() log.info("Copying %s -> %s", src, dst) - ensure_dir_exists(Path(dst).parent) + ensure_dir_exists(dst_path.parent) shutil.copytree(src, dst, symlinks=True) return True @@ -107,19 +109,20 @@ def migrate_file(src: str | Path, dst: str | Path, substitutions: Any = None) -> substitutions is an optional dict of {regex: replacement} for performing replacements on the file. """ log = get_logger() - if Path(dst).exists(): + dst_path = Path(dst) + if dst_path.exists(): # already exists log.debug("%s already exists", dst) return False log.info("Copying %s -> %s", src, dst) - ensure_dir_exists(Path(dst).parent) + ensure_dir_exists(dst_path.parent) shutil.copy(src, dst) if substitutions: - with Path.open(Path(dst), encoding="utf-8") as f: + with dst_path.open() as f: text = f.read() for pat, replacement in substitutions.items(): text = pat.sub(replacement, text) - with Path.open(Path(dst), "w", encoding="utf-8") as f: + with dst_path.open("w") as f: f.write(text) return True From 1814b937670027acd1975de9d5cb78c4da0f305f Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 29 Apr 2025 13:58:38 +0200 Subject: [PATCH 3/7] cast to list to catch OSError --- jupyter_core/command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyter_core/command.py b/jupyter_core/command.py index 0e10171..9c9317d 100644 --- a/jupyter_core/command.py +++ b/jupyter_core/command.py @@ -92,7 +92,7 @@ def list_subcommands() -> list[str]: # construct a set of `('foo', 'bar') from `jupyter-foo-bar` for d in _path_with_self(): try: - bin_paths = Path(d).iterdir() + bin_paths = list(Path(d).iterdir()) except OSError: continue for path in bin_paths: From cdfe6da447581f27e2c1436e7361ac20ee4ba3d5 Mon Sep 17 00:00:00 2001 From: Min RK Date: Wed, 30 Apr 2025 14:41:03 +0200 Subject: [PATCH 4/7] fix problem with shared PIPX_HOME on 3.8 --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index efd3c0b..16fbe56 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,6 +40,10 @@ jobs: python-version: "3.10" steps: - uses: actions/checkout@v4 + - name: fix pipx on Python 3.8 + if: ${{ matrix.python-version == '3.8' }} + run: | + echo PIPX_HOME=$HOME/.pipx_home >> $GITHUB_ENV - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - name: Test run: | From 33eef4772a4a8a6c8ee5c1a17ed22579fefaf8bc Mon Sep 17 00:00:00 2001 From: Min RK Date: Wed, 30 Apr 2025 14:52:47 +0200 Subject: [PATCH 5/7] simplify setup with basic setup-python maintainer tools is irrevocably broken with 3.8 --- .github/workflows/test.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16fbe56..b7cb17b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,11 +40,20 @@ jobs: python-version: "3.10" steps: - uses: actions/checkout@v4 - - name: fix pipx on Python 3.8 - if: ${{ matrix.python-version == '3.8' }} + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: pip + + - name: install hatch run: | - echo PIPX_HOME=$HOME/.pipx_home >> $GITHUB_ENV - - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + pip install --upgrade pip pipx + if [[ "${{ matrix.python-version }}" == "3.8" ]]; then + PIPX_HOME=$HOME/.pipx_home + mkdir $PIPX_HOME + fi + pipx install hatch + - name: Test run: | hatch run cov:test From 896bb9bde094801a89080cebfde4d2f3f809797b Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 26 May 2025 12:55:45 +0200 Subject: [PATCH 6/7] update pre-commit hooks --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7ba061e..7b22a1a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.32.1 + rev: 0.33.0 hooks: - id: check-github-workflows @@ -67,7 +67,7 @@ repos: - id: rst-inline-touching-normal - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.4 + rev: v0.11.11 hooks: - id: ruff types_or: [python, jupyter] @@ -76,7 +76,7 @@ repos: types_or: [python, jupyter] - repo: https://github.com/scientific-python/cookie - rev: "2025.01.22" + rev: "2025.05.02" hooks: - id: sp-repo-review additional_dependencies: ["repo-review[cli]"] From b3eb69b92bc0eb2df86a29ee95af95d584610041 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 26 May 2025 12:56:08 +0200 Subject: [PATCH 7/7] add sphinx configuration to rtd required by lint --- .readthedocs.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 27b3512..e765926 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -10,3 +10,5 @@ build: os: ubuntu-22.04 tools: python: "3.12" +sphinx: + configuration: docs/conf.py