8000 Add additional type ignores for mypy by cdce8p · Pull Request #14050 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Add additional type ignores for mypy#14050

Merged
srittau merged 1 commit intopython:mainfrom
cdce8p:mypy-ignores
May 13, 2025
Merged

Add additional type ignores for mypy#14050
srittau merged 1 commit intopython:mainfrom
cdce8p:mypy-ignores

Conversation

@cdce8p
Copy link
Contributor
@cdce8p cdce8p commented May 13, 2025

See python/mypy#19079

I can reproduce both errors by checking typeshed with the current mypy master commit.

stdlib/tempfile.pyi:387: error: Argument 1 of "writelines" is incompatible with supertype "_IOBase"; supertype defines the argument type as "Iterable[Buffer]"  [override]
stdlib/tempfile.pyi:387: note: This violates the Liskov substitution principle
stdlib/tempfile.pyi:387: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
stdlib/tkinter/ttk.pyi:565: error: Signature of "forget" incompatible with supertype "Pack"  [override]
stdlib/tkinter/ttk.pyi:565: note:      Superclass:
stdlib/tkinter/ttk.pyi:565: note:          def () -> None
stdlib/tkinter/ttk.pyi:565: note:      Subclass:
stdlib/tkinter/ttk.pyi:565: note:          def forget(self, tab_id: Any) -> None

tkinter - Notebook.forget

forget is inherited from Pack.forget but at runtime accepts an additional argument.

def pack_forget(self) -> None: ...
def pack_info(self) -> _PackInfo: ... # errors if widget hasn't been packed
pack = pack_configure
forget = pack_forget

https://www.tcl-lang.org/man/tcl8.6/TkCmd/ttk_notebook.htm#M23

SpooledTemporaryFile.writelines

Not sure it's possible to get the overload right here since the base class definitions seem to conflict itself. _IOBase wants only an Iterable[ReadableBuffer], whereas typing.IO also accepts Iterable[AnyStr].

def writelines(self, lines: Iterable[ReadableBuffer], /) -> None: ...

typeshed/stdlib/typing.pyi

Lines 857 to 862 in 23f1888

@abstractmethod
@overload
def writelines(self: IO[bytes], lines: Iterable[ReadableBuffer], /) -> None: ...
@abstractmethod
@overload
def writelines(self, lines: Iterable[AnyStr], /) -> None: ...

/CC @JelleZijlstra

@github-actions
Copy link
Contributor

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

@srittau srittau merged commit 82af3b2 into python:main May 13, 2025
64 checks passed
@cdce8p cdce8p deleted the mypy-ignores branch May 13, 2025 14:51
mmingyu pushed a commit to mmingyu/typeshed that referenced this pull request May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@srittau srittau srittau approved these changes

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0