From e7a4745d6b170f3635089d7e5c5d6a87072cfb4d Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Tue, 28 Feb 2023 23:45:26 +0100 Subject: [PATCH 1/2] fix extension substitution to work with files --- lazy_loader/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lazy_loader/__init__.py b/lazy_loader/__init__.py index 687c0a6..59530f7 100644 --- a/lazy_loader/__init__.py +++ b/lazy_loader/__init__.py @@ -237,7 +237,7 @@ def attach_stub(package_name: str, filename: str): If a stub file is not found for `filename`, or if the stubfile is formmated incorrectly (e.g. if it contains an relative import from outside of the module) """ - stubfile = filename if filename.endswith("i") else f"{filename}i" + stubfile = filename if filename.endswith("i") else f"{os.path.splitext(filename)[0]}.pyi" if not os.path.exists(stubfile): raise ValueError(f"Cannot load imports from non-existent stub {stubfile!r}") From 91b14094d9e903fad58f3de5f1262a35333156bc Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Thu, 2 Mar 2023 00:28:18 -0800 Subject: [PATCH 2/2] Update pre-commit versions --- .pre-commit-config.yaml | 12 ++++++------ lazy_loader/__init__.py | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8e4eab9..f49ab66 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,23 +16,23 @@ repos: - id: check-toml - id: check-added-large-files - repo: https://github.com/psf/black - rev: 22.8.0 + rev: 22.10.0 hooks: - id: black - - repo: https://gitlab.com/pycqa/flake8 - rev: 5.0.4 + - repo: https://github.com/pycqa/flake8 + rev: 6.0.0 hooks: - id: flake8 pass_filenames: true - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/asottile/pyupgrade - rev: v2.38.0 + rev: v3.3.1 hooks: - id: pyupgrade - args: [--py37-plus] + args: [--py38-plus] - repo: https://github.com/pre-commit/mirrors-prettier rev: v2.7.1 hooks: diff --git a/lazy_loader/__init__.py b/lazy_loader/__init__.py index 59530f7..ed6f7dd 100644 --- a/lazy_loader/__init__.py +++ b/lazy_loader/__init__.py @@ -237,7 +237,9 @@ def attach_stub(package_name: str, filename: str): If a stub file is not found for `filename`, or if the stubfile is formmated incorrectly (e.g. if it contains an relative import from outside of the module) """ - stubfile = filename if filename.endswith("i") else f"{os.path.splitext(filename)[0]}.pyi" + stubfile = ( + filename if filename.endswith("i") else f"{os.path.splitext(filename)[0]}.pyi" + ) if not os.path.exists(stubfile): raise ValueError(f"Cannot load imports from non-existent stub {stubfile!r}")