Skip to content

Conversation

smoya
Copy link
Contributor

@smoya smoya commented Oct 7, 2025

No description provided.

@smoya smoya requested a review from a team as a code owner October 7, 2025 10:49
@smoya smoya temporarily deployed to internal-contributors October 7, 2025 10:49 — with GitHub Actions Inactive
parsed = urlparse(file_path)
except Exception:
return None
split = parsed.path.split(".")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we use urlparse, this give us just the path without the query parameters.

@smoya smoya force-pushed the smoya/fix-file-extension-guessing branch from 6b0d3ba to cb1bdda Compare October 7, 2025 11:02
@smoya smoya temporarily deployed to internal-contributors October 7, 2025 11:02 — with GitHub Actions Inactive
parsed = urlparse(file_path)
except Exception:
return None
split = parsed.path.split(".")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we use urlparse, this give us just the path without the query parameters.


def guess_filetype(file_like: BytesIO, file_path: str | None = None) -> str | None:
guess = filetype.guess(file_like) # type: ignore
extension = filetype.guess_extension(file_like) # type: ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a simplification. Calling guess_extension calls guess internally and just returns the extension, which is all we need.

@smoya smoya force-pushed the smoya/fix-file-extension-guessing branch from cb1bdda to b8a8e63 Compare October 7, 2025 11:34
@smoya smoya temporarily deployed to internal-contributors October 7, 2025 11:34 — with GitHub Actions Inactive
parsed = urlparse(file_path)
except Exception:
return None
split = parsed.path.split(".")
Copy link
Member

Choose a reason for hiding this comment

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

Why not use splitext here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@smoya smoya deployed to internal-contributors October 7, 2025 15:16 — with GitHub Actions Active

def guess_filetype(file_like: BytesIO, file_path: str | None = None) -> str | None:
guess = filetype.guess(file_like) # type: ignore
guess = filetype.guess(file_like) # type: ignore[reportUnknownArgumentType,reportUnknownMemberType]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This error wasn't popping previously but now it does. Im just skipping. Other solution would be to do explicit casts.

except Exception:
return None

return ext[1:].lower() if ext else None
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the .lower() so we ensure always to go with lowercase extensions. Just for consistency.

@smoya smoya requested a review from JamesGuthrie October 7, 2025 15:19
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.

3 participants