-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(mimetypes): allow functions working with files to accept Paths
#15071
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,15 +25,15 @@ if sys.version_info >= (3, 13): | |
| def guess_type(url: StrPath, strict: bool = True) -> tuple[str | None, str | None]: ... | ||
| def guess_all_extensions(type: str, strict: bool = True) -> list[str]: ... | ||
| def guess_extension(type: str, strict: bool = True) -> str | None: ... | ||
| def init(files: Sequence[str] | None = None) -> None: ... | ||
| def read_mime_types(file: str) -> dict[str, str] | None: ... | ||
| def init(files: Sequence[StrPath] | None = None) -> None: ... | ||
| def read_mime_types(file: StrPath) -> dict[str, str] | None: ... | ||
| def add_type(type: str, ext: str, strict: bool = True) -> None: ... | ||
|
|
||
| if sys.version_info >= (3, 13): | ||
| def guess_file_type(path: StrPath, *, strict: bool = True) -> tuple[str | None, str | None]: ... | ||
|
|
||
| inited: bool | ||
| knownfiles: list[str] | ||
| knownfiles: list[StrPath] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
| suffix_map: dict[str, str] | ||
| encodings_map: dict[str, str] | ||
| types_map: dict[str, str] | ||
|
|
@@ -44,12 +44,12 @@ class MimeTypes: | |
| encodings_map: dict[str, str] | ||
| types_map: tuple[dict[str, str], dict[str, str]] | ||
| types_map_inv: tuple[dict[str, str], dict[str, str]] | ||
| def __init__(self, filenames: tuple[str, ...] = (), strict: bool = True) -> None: ... | ||
| def __init__(self, filenames: tuple[StrPath, ...] = (), strict: bool = True) -> None: ... | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems it just works. As a side note -- is there a particular reason why |
||
| def add_type(self, type: str, ext: str, strict: bool = True) -> None: ... | ||
| def guess_extension(self, type: str, strict: bool = True) -> str | None: ... | ||
| def guess_type(self, url: StrPath, strict: bool = True) -> tuple[str | None, str | None]: ... | ||
| def guess_all_extensions(self, type: str, strict: bool = True) -> list[str]: ... | ||
| def read(self, filename: str, strict: bool = True) -> None: ... | ||
| def read(self, filename: StrPath, strict: bool = True) -> None: ... | ||
| def readfp(self, fp: IO[str], strict: bool = True) -> None: ... | ||
| def read_windows_registry(self, strict: bool = True) -> None: ... | ||
| if sys.version_info >= (3, 13): | ||
|
|
||
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.
https://github.com/python/cpython/blob/061965c584810b97458f229a6ac5b3b79286e743/Lib/mimetypes.py#L425-L427
os.path.isfileacceptsPaths