Skip to content
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

fix: TarFile import #5666

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bcotton
Copy link
Contributor

@bcotton bcotton commented Mar 11, 2025

Description

Failing test for #5664. Proposed solution to failing test

To Do

  • Fix the problem
  • Documentation. (If you've added a new command-line flag, for example, find the appropriate page under docs/ to describe it.)
  • Changelog. (Add an entry to docs/changelog.rst to the bottom of one of the lists near the top of the document.)
  • Tests. (Very much encouraged but not strictly required.)

Copy link

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

bcotton added 2 commits March 11, 2025 17:21
Wrap the TarFile and TarInfo classes to adhere to the interface
@snejus snejus requested a review from Copilot March 20, 2025 21:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR aims to fix a failing test for handling tar files by introducing a custom TarWrapper and TarInfo in the importer as well as adding a new test case for tar file imports.

  • Introduce a custom TarInfo and TarWrapper in beets/importer.py to better handle tar files
  • Add a new test_import_tar in test/test_importer.py to validate tar file import functionality

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
beets/importer.py Replace existing tarfile.open handler with a custom wrapper class
test/test_importer.py Update test cases and class inheritance to include a tar file import
Comments suppressed due to low confidence (1)

test/test_importer.py:292

  • [nitpick] The variable name 'zip_path' can be misleading in a test intended for tar files; consider renaming it to 'tar_path'.
zip_path = self.create_archive()

self.gid = member.gid
self.uname = member.uname
self.gname = member.gname
self.date_time = time.gmtime(member.mtime)[:6]
Copy link
Preview

Copilot AI Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of 'time.gmtime' requires an import for the time module. Please add 'import time' at the beginning of the file.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be passing without it. 🤷

@@ -1225,7 +1225,33 @@ def handlers(cls):
cls._handlers.append((is_zipfile, ZipFile))
import tarfile

cls._handlers.append((tarfile.is_tarfile, tarfile.open))
class TarInfo(tarfile.TarInfo):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a python dev. Not sure this is correct, but is working on my install.

@bcotton bcotton changed the title chore: fix test case to show failing TarFile fix: TarFile import Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant