Skip to content

Conversation

@alexei
Copy link
Contributor

@alexei alexei commented Nov 22, 2025

No description provided.

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: ...
Copy link
Contributor Author

Choose a reason for hiding this comment

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


inited: bool
knownfiles: list[str]
knownfiles: list[StrPath]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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: ...
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 init accepts a Sequence of names, but MimeTypes.__init__ only a tuple? I mean other than it being initialised that way. It's working with either tuple or list.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks!

@srittau srittau merged commit 8dcca56 into python:main Nov 24, 2025
63 checks passed
@alexei
Copy link
Contributor Author

alexei commented Nov 24, 2025

Thanks @srittau I'd also appreciate it if you had any insight on #15071 (comment)

As a side note -- is there a particular reason why init accepts a Sequence of names, but MimeTypes.init only a tuple? I mean other than it being initialised that way. It's working with either tuple or list.

@srittau
Copy link
Collaborator

srittau commented Nov 24, 2025

Looking at the source (for 3.12), it should accept an Iterable.

Some annotations in typeshed are ancient, predating modern typing features and standards, or were not updated even if Python itself was updated ages ago. This particular annotation seems to exist since mimetypes.pyi was added in 2016. So, if you see something in typeshed that doesn't look right that is often because it isn't.

@alexei
Copy link
Contributor Author

alexei commented Nov 24, 2025

@srittau much appreciated!

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.

2 participants