Skip to content
Open
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
3 changes: 3 additions & 0 deletions src/codeweaver/core/di/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@
else:
self._singletons[interface] = instance

async def resolve(

Check failure on line 527 in src/codeweaver/core/di/container.py

View workflow job for this annotation

GitHub Actions / Lint / Lint and Format

ruff (C901)

src/codeweaver/core/di/container.py:527:15: C901 `resolve` is too complex (11 > 10)
self,
interface: type[T] | TypeAliasType[T],
_resolution_stack: list[str] | None = None,
Expand All @@ -545,6 +545,9 @@
Raises:
CircularDependencyError: If a circular dependency is detected.
"""
if interface is type(None):
return None # type: ignore[return-value]

Comment on lines +548 to +550
Comment on lines +548 to +550
from codeweaver.core.exceptions import CircularDependencyError

if _resolution_stack is None:
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/core/test_discovery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from pathlib import Path
from unittest.mock import patch

from codeweaver.core.discovery import DiscoveredFile

Comment on lines +1 to +5

def test_is_path_binary_exception_handling():
# Arrange
test_path = Path("some_nonexistent_or_protected_file.bin")

# Act & Assert
with patch("pathlib.Path.open", side_effect=PermissionError("Permission denied")):
result = DiscoveredFile.is_path_binary(test_path)
assert result is False

with patch("pathlib.Path.open", side_effect=OSError("OS Error")):
result = DiscoveredFile.is_path_binary(test_path)
assert result is False
Comment on lines +7 to +18
Loading