-
-
Notifications
You must be signed in to change notification settings - Fork 87
Refactor: modularize _make_file_info method #656
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
base: master
Are you sure you want to change the base?
Conversation
Split the _make_file_info method into platform-specific implementations (_make_win32_file_info, _make_unix_file_info, _make_generic_file_info) to improve clarity and maintainability. Adjusted test cases to ensure proper usage of SevenZipFile and comply with the new structure. This modular approach simplifies future enhancements and isolates platform-specific logic.
Replaced the installation of python3-pip with python3-venv in the GitHub Actions workflow. This ensures the virtual environment creation process is aligned with best practices and avoids unnecessary dependencies.
Introduced constants for Windows file attributes for better readability and consistency. Added a helper method `_get_win32_file_attribute` to streamline attribute extraction on Windows platforms, ensuring compatibility and reducing code redundancy.
|
|
||
| @staticmethod | ||
| def _make_file_info(target: pathlib.Path, arcname: Optional[str] = None, dereference=False) -> dict[str, Any]: | ||
| def _make_win32_file_info( |
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.
[mypy] reported by reviewdog 🐶
error: Function is missing a type annotation for one or more arguments [no-untyped-def]
| f["emptystream"] = False | ||
| f["attributes"] = FILE_ATTRIBUTE_ARCHIVE # noqa | ||
| f["uncompressed"] = fstat.st_size | ||
| f["creationtime"] = ArchiveTimestamp.from_datetime(fstat.st_ctime) |
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.
[mypy] reported by reviewdog 🐶
error: Call to untyped function "from_datetime" in typed context [no-untyped-call]
| f["attributes"] = FILE_ATTRIBUTE_ARCHIVE # noqa | ||
| f["uncompressed"] = fstat.st_size | ||
| f["creationtime"] = ArchiveTimestamp.from_datetime(fstat.st_ctime) | ||
| f["lastwritetime"] = ArchiveTimestamp.from_datetime(fstat.st_mtime) |
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.
[mypy] reported by reviewdog 🐶
error: Call to untyped function "from_datetime" in typed context [no-untyped-call]
| f["uncompressed"] = fstat.st_size | ||
| f["creationtime"] = ArchiveTimestamp.from_datetime(fstat.st_ctime) | ||
| f["lastwritetime"] = ArchiveTimestamp.from_datetime(fstat.st_mtime) | ||
| f["lastaccesstime"] = ArchiveTimestamp.from_datetime(fstat.st_atime) |
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.
[mypy] reported by reviewdog 🐶
error: Call to untyped function "from_datetime" in typed context [no-untyped-call]
| return fstat.st_file_attributes & FILE_ATTRIBUTE_WINDOWS_MASK | ||
| return 0 | ||
|
|
||
| def _make_unix_file_info(self, target: pathlib.Path, arcname: Optional[str] = None, dereference=False) -> dict[str, Any]: |
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.
[mypy] reported by reviewdog 🐶
error: Function is missing a type annotation for one or more arguments [no-untyped-def]
| f["lastaccesstime"] = ArchiveTimestamp.from_datetime(fstat.st_atime) | ||
| return f | ||
|
|
||
| def _make_generic_file_info( |
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.
[mypy] reported by reviewdog 🐶
error: Function is missing a type annotation for one or more arguments [no-untyped-def]
| f["emptystream"] = False | ||
| f["uncompressed"] = fstat.st_size | ||
| f["attributes"] = FILE_ATTRIBUTE_ARCHIVE | ||
| f["creationtime"] = ArchiveTimestamp.from_datetime(fstat.st_ctime) |
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.
[mypy] reported by reviewdog 🐶
error: Call to untyped function "from_datetime" in typed context [no-untyped-call]
| f["uncompressed"] = fstat.st_size | ||
| f["attributes"] = FILE_ATTRIBUTE_ARCHIVE | ||
| f["creationtime"] = ArchiveTimestamp.from_datetime(fstat.st_ctime) | ||
| f["lastwritetime"] = ArchiveTimestamp.from_datetime(fstat.st_mtime) |
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.
[mypy] reported by reviewdog 🐶
error: Call to untyped function "from_datetime" in typed context [no-untyped-call]
| f["attributes"] = FILE_ATTRIBUTE_ARCHIVE | ||
| f["creationtime"] = ArchiveTimestamp.from_datetime(fstat.st_ctime) | ||
| f["lastwritetime"] = ArchiveTimestamp.from_datetime(fstat.st_mtime) | ||
| f["lastaccesstime"] = ArchiveTimestamp.from_datetime(fstat.st_atime) |
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.
[mypy] reported by reviewdog 🐶
error: Call to untyped function "from_datetime" in typed context [no-untyped-call]
| f["lastaccesstime"] = ArchiveTimestamp.from_datetime(fstat.st_atime) | ||
| return f | ||
|
|
||
| def _make_file_info(self, target: pathlib.Path, arcname: Optional[str] = None, dereference=False) -> dict[str, Any]: |
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.
[mypy] reported by reviewdog 🐶
error: Function is missing a type annotation for one or more arguments [no-untyped-def]
Pull request type
select from below
Which ticket is resolved?
What does this PR change?
Other information