Skip to content

Commit 65b66fe

Browse files
committed
Fix or ignore all style errors
1 parent 7321e3c commit 65b66fe

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/scikit_build_core/resources/_editable_redirect.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from __future__ import annotations
22

33
import importlib.abc
4-
import importlib.util
54
import importlib.machinery
6-
import importlib.readers # Might be Python version specific?
5+
6+
# TODO: importlib.readers is Python version specific
7+
import importlib.readers # type: ignore[import-not-found]
8+
import importlib.util
79
import os
810
import subprocess
911
import sys
@@ -13,6 +15,7 @@
1315
TYPE_CHECKING = False
1416
if TYPE_CHECKING:
1517
from importlib.machinery import ModuleSpec
18+
from pathlib import Path
1619

1720

1821
DIR = os.path.abspath(os.path.dirname(__file__))
@@ -78,11 +81,12 @@ def release(self) -> None:
7881
fcntl.flock(self.lock_file_fd, fcntl.LOCK_UN)
7982
os.close(self.lock_file_fd)
8083

84+
8185
# Note: This solution relies on importlib's call stack in Python 3.11. Python 3.9 looks
8286
# different, so might require a different solution, but I haven't gone deeper into that
8387
# yet since I don't have a solution for the 3.11 case yet anyway.
84-
class ScikitBuildRedirectingReader(importlib.readers.FileReader):
85-
def files(self):
88+
class ScikitBuildRedirectingReader(importlib.readers.FileReader): # type: ignore[misc]
89+
def files(self) -> Path:
8690
# ATTENTION: This is where the problem is. The expectation is that this returns
8791
# a Traversable object. We could hack together an object that satisfies that
8892
# API, but methods like `joinpath` don't have sensible implementations if
@@ -91,11 +95,11 @@ def files(self):
9195
# representation that knows both possible roots and checks for existence when
9296
# necessary, but that seriously violates the principle of least surprise for the
9397
# user so I'd be quite skeptical.
94-
return self.path
98+
return self.path # type: ignore[no-any-return]
9599

96100

97101
class ScikitBuildRedirectingLoader(importlib.machinery.SourceFileLoader):
98-
def get_resource_reader(self, module):
102+
def get_resource_reader(self, module: str) -> ScikitBuildRedirectingReader: # type: ignore[override]
99103
return ScikitBuildRedirectingReader(self)
100104

101105

@@ -175,7 +179,9 @@ def find_spec(
175179
submodule_search_locations=submodule_search_locations
176180
if redir.endswith(("__init__.py", "__init__.pyc"))
177181
else None,
178-
loader=ScikitBuildRedirectingLoader(fullname, os.path.join(self.dir, redir)),
182+
loader=ScikitBuildRedirectingLoader(
183+
fullname, os.path.join(self.dir, redir)
184+
),
179185
)
180186
if fullname in self.known_source_files:
181187
redir = self.known_source_files[fullname]

0 commit comments

Comments
 (0)