Skip to content

Commit e1e48fa

Browse files
authored
Fix extension substitution to work with *.pyc files (#39)
1 parent cb22eba commit e1e48fa

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ repos:
1616
- id: check-toml
1717
- id: check-added-large-files
1818
- repo: https://github.com/psf/black
19-
rev: 22.8.0
19+
rev: 22.10.0
2020
hooks:
2121
- id: black
22-
- repo: https://gitlab.com/pycqa/flake8
23-
rev: 5.0.4
22+
- repo: https://github.com/pycqa/flake8
23+
rev: 6.0.0
2424
hooks:
2525
- id: flake8
2626
pass_filenames: true
2727
- repo: https://github.com/pycqa/isort
28-
rev: 5.10.1
28+
rev: 5.12.0
2929
hooks:
3030
- id: isort
3131
- repo: https://github.com/asottile/pyupgrade
32-
rev: v2.38.0
32+
rev: v3.3.1
3333
hooks:
3434
- id: pyupgrade
35-
args: [--py37-plus]
35+
args: [--py38-plus]
3636
- repo: https://github.com/pre-commit/mirrors-prettier
3737
rev: v2.7.1
3838
hooks:

lazy_loader/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ def attach_stub(package_name: str, filename: str):
237237
If a stub file is not found for `filename`, or if the stubfile is formmated
238238
incorrectly (e.g. if it contains an relative import from outside of the module)
239239
"""
240-
stubfile = filename if filename.endswith("i") else f"{filename}i"
240+
stubfile = (
241+
filename if filename.endswith("i") else f"{os.path.splitext(filename)[0]}.pyi"
242+
)
241243

242244
if not os.path.exists(stubfile):
243245
raise ValueError(f"Cannot load imports from non-existent stub {stubfile!r}")

0 commit comments

Comments
 (0)