-
Notifications
You must be signed in to change notification settings - Fork 9
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 assertions for explicit path comparison #147
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #147 +/- ##
=======================================
Coverage 83.92% 83.92%
=======================================
Files 34 34
Lines 3466 3466
=======================================
Hits 2909 2909
Misses 557 557
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Wrong button
tests/test_fieldtypes.py
Outdated
@@ -689,7 +690,9 @@ def test_path() -> None: | |||
), | |||
], | |||
) | |||
def test_path_multiple_parts(path_parts, expected_instance) -> None: | |||
def test_path_multiple_parts( | |||
path_parts: Tuple[str | pathlib.PurePath, ...], expected_instance: Type[pathlib.PurePath] |
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.
path_parts: Tuple[str | pathlib.PurePath, ...], expected_instance: Type[pathlib.PurePath] | |
path_parts: Tuple[str | pathlib.PurePath, ...], expected_instance: type[pathlib.PurePath] |
This is legal these days (unless it's another thing not allowed by 3.8, in which case ignore this comment).
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 thought this got introduced in python 3.9 but the python compatibility test passes with type
instead of Type
.
In any case, 3.8 is EOL now https://discuss.python.org/t/python-3-8-is-now-officially-eol/66983
tests/test_fieldtypes.py
Outdated
@@ -1153,7 +1160,7 @@ def test_command_failed() -> None: | |||
fieldtypes.path, | |||
], | |||
) | |||
def test_empty_path(path_cls) -> None: | |||
def test_empty_path(path_cls: Type[pathlib.PurePath]) -> None: |
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.
def test_empty_path(path_cls: Type[pathlib.PurePath]) -> None: | |
def test_empty_path(path_cls: type[pathlib.PurePath]) -> None: |
tests/test_fieldtypes.py
Outdated
@@ -688,7 +690,9 @@ def test_path(): | |||
), | |||
], | |||
) | |||
def test_path_multiple_parts(path_parts, expected_instance): | |||
def test_path_multiple_parts( | |||
path_parts: Tuple[str | pathlib.PurePath, ...], expected_instance: type[pathlib.PurePath] |
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.
path_parts: Tuple[str | pathlib.PurePath, ...], expected_instance: type[pathlib.PurePath] | |
path_parts: tuple[str | pathlib.PurePath, ...], expected_instance: type[pathlib.PurePath] |
This already worked with no changes because path::__eq__ is delegating to pathlib::__eq__. Nevertheless, let's prevent regressions.
d62a013
to
84f087f
Compare
Originally, this issue was about implementing explicit path comparisons such as
path == posix_path(/usr/local/ls")
.As it turns out, this behavior is already supported by flow.record
path
, because it delegates to the superclass methodpathlib::__eq__
.Added some assertions (actually I started with these and found out it already works as intended) to prevent regressions.
Bonus: improve typing of tests.
Closes #146