Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧪 Add unit tests for DiscoveredFile absolute_path property #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🧪 Add unit tests for DiscoveredFile absolute_path property #215
Changes from all commits
2fcd29ccfef1a0032ced3efc41ddc69d38ab708308d6ee6d6992f3b5File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Check failure on line 25 in src/codeweaver/core/utils/generation.py
ruff (ANN002)
Check failure on line 34 in src/codeweaver/core/utils/generation.py
ruff (ANN002)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with Copilot's assessment - this is a critical issue in the UUID fallback logic.
Problem
The current fallback in
uuid7_as_timestamp()returnsdatetime.datetime.now()when UUID7 support is unavailable. This is semantically incorrect because:Impact on This PR
Looking at
generation.py:56-68, the fallback at line 64 is:This means if uuid7 support is missing on Python 3.14t/3.13t, any code calling
uuid7_as_timestamp(my_uuid)will get the current time instead of the time embedded inmy_uuid.Recommended Fix
Option 1 (Preferred): Raise a clear error
Option 2: Return None (if callers can handle it)
Then update the return type annotation from
int | datetime.datetime | Noneto explicitly document thatNonemeans "extraction unavailable".Verdict: This fallback should be removed or changed to raise an error. The current implementation is worse than failing fast because it corrupts data silently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Strengthen the FileNotFoundError branch test by asserting
get_project_pathis actually calledIn
test_absolute_path_when_project_path_is_none_filenotfound,get_project_pathis patched withside_effect = FileNotFoundError(), but the mock is never asserted. This means the test would still pass even ifabsolute_pathstops callingget_project_path. Please add an assertion like:(or
assert mock_get_project_path.called) so the test verifies the intended control flow for this branch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this assessment. The type-inconsistent approach is problematic for several reasons:
project_pathto an empty string when it's typed asDirectoryPathcreates a mismatch that could hide real bugsproject_pathas an empty string - it will be a valid Path or potentially NonePath | None, these tests won't catch regressionsSuggested Fix
Instead of:
Consider one of these approaches:
Option 1: Test with actual None (requires code changes)
Option 2: Mock get_project_path directly (preferred)
The key is to test the actual behavior without violating type constraints.
Uh oh!
There was an error while loading. Please reload this page.