Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dev = [
"clang-format~=14.0",

# Linting
"ruff>=0.2",
"ruff>=0.6",
"mypy",
"codespell",
"check-manifest",
Expand Down Expand Up @@ -104,7 +104,6 @@ syntax = "numpy"


[tool.ruff]
src = ["src"]
line-length = 120
output-format = "full"

Expand Down Expand Up @@ -185,10 +184,12 @@ show_missing = true


[tool.mypy]
strict = true
plugins = ["numpy.typing.mypy_plugin"]
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_return_any = true
warn_unused_configs = true
warn_unreachable = true
pretty = true
ignore_missing_imports = true # This could be made local for the tests

Expand Down
2 changes: 1 addition & 1 deletion src/charonload/_compat/hashlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def file_digest(fileobj: BinaryIO, digest: str | Callable[[], _Hash], /) -> _Has
elif callable(digest):
file_hasher = digest()
else:
msg = "Wrong type of digest: Should be either str or Callable."
msg = "Wrong type of digest: Should be either str or Callable." # type: ignore[unreachable]
raise TypeError(msg)

num_blocks = 1024
Expand Down
8 changes: 5 additions & 3 deletions src/charonload/_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
class JITCompileFinder(importlib.abc.MetaPathFinder):
"""An import finder for executing the just-in-time (JIT) compilation."""

def find_spec(self: Self, fullname, path, target=None) -> None: # noqa: ANN001, ARG002
def find_spec( # type: ignore[no-untyped-def]
self: Self, fullname, path, target=None # noqa: ANN001, ARG002
) -> None:
"""
Find the spec of the specified module.

Expand Down Expand Up @@ -96,7 +98,7 @@ def find_spec(self: Self, fullname, path, target=None) -> None: # noqa: ANN001,

def _load(module_name: str, config: ResolvedConfig) -> None:
if not isinstance(config, ResolvedConfig):
msg = f"Invalid type of configuration: expected 'Config', but got '{config.__class__.__name__}'"
msg = f"Invalid type of configuration: expected 'Config', but got '{config.__class__.__name__}'" # type: ignore[unreachable]
raise TypeError(msg)

(config.full_build_directory / "charonload").mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -500,7 +502,7 @@ def add(self: Self, d: pathlib.Path) -> None:
@staticmethod
def _clear(directories: dict[pathlib.Path, Any]) -> None:
for handler in directories.values():
handler.close() # type: ignore[attr-defined]
handler.close()


_windows_dll_directories: dict[pathlib.Path, Any] = {}
Expand Down
4 changes: 2 additions & 2 deletions src/charonload/_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class _Serializer:
decode: Callable[[str], Any]


class _PersistentDict(collections.abc.MutableMapping):
class _PersistentDict(collections.abc.MutableMapping[str, Any]):
def __init__(self: Self) -> None:
self._entries: dict[str, _TypedPersistentString] = {}
self._serializers: dict[type, _Serializer] = {}
Expand All @@ -76,7 +76,7 @@ def __delitem__(self: Self, key: str) -> None:
msg = "Deleting connections is not supported."
raise AttributeError(msg)

def __iter__(self: Self) -> collections.abc.Iterator:
def __iter__(self: Self) -> collections.abc.Iterator[str]:
return iter(self._entries)

def __len__(self: Self) -> int:
Expand Down
2 changes: 1 addition & 1 deletion src/charonload/cmake/torch/add_torch_library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Define some bindings ...
}

3. The usage requirements for PyTorch will be added to ``<name>`` and, if necessary,
3. The :doc:`usage requirements for PyTorch</src/pytorch_handling>` will be added to ``<name>`` and, if necessary,
recursively to all of its dependencies:

- C++ standard
Expand Down
2 changes: 1 addition & 1 deletion src/charonload/pybind11_stubgen/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def main() -> None:
# Patch list of command line argument globally as this list cannot directly be passed to pybind11-stubgen
sys.argv = [sys.argv[0], *original_args]

pybind11_stubgen.main()
pybind11_stubgen.main() # type: ignore[no-untyped-call]


if __name__ == "__main__": # pragma: no cover
Expand Down
6 changes: 3 additions & 3 deletions tests/test_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_installed_project() -> None:
assert config.full_stubs_directory not in config.full_project_directory.parents

t_input = torch.randint(0, 10, size=(3, 3, 3), dtype=torch.float, device="cpu")
t_output = charonload_installed_project.two_times(t_input)
t_output = charonload_installed_project.two_times(t_input) # type: ignore[attr-defined]

assert t_output.device == t_input.device
assert t_output.shape == t_input.shape
Expand Down Expand Up @@ -399,7 +399,7 @@ def _torch_incremental_build(
p.join()
assert p.exitcode == 0

return float(result.value) # type: ignore[attr-defined]
return float(result.value)


def test_torch_incremental_build_cpp(shared_datadir: pathlib.Path, tmp_path: pathlib.Path) -> None:
Expand Down Expand Up @@ -1009,7 +1009,7 @@ def test_concurrent_process_fork_import(shared_datadir: pathlib.Path, tmp_path:

num = 5
jobs = [
multiprocessing.get_context("fork").Process(target=_concurrent_process_fork_import, args=(i,)) # type: ignore[attr-defined]
multiprocessing.get_context("fork").Process(target=_concurrent_process_fork_import, args=(i,))
for i in range(num)
]

Expand Down