Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix incompatible overrides of overloaded methods in concrete subclasses#14017

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hauntsaninja merged 7 commits intopython:masterfromhauntsaninja:generic-self
Nov 10, 2022

Conversation

@hauntsaninja
Copy link
Collaborator

Fixes#14002

foriteminoriginal_type.items
ifnotitem.arg_typesoris_subtype(active_self_type,item.arg_types[0])
]
iffiltered_items:
Copy link
Member

Choose a reason for hiding this comment

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

If there are no filtered_items, shouldn't we always treat the override as compatible? e.g. in yourF test below, I think the override is actually compatible: the base class says nothing about what the method should return if self is anA[bytes].

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

Yeah, I wasn't sure about this, but it seemed like a weird situation so I chose to fail. Feels sketchy to introduce aCallable[..., Any] ... I'll add a comment and if it ever comes up we can reconsider

@github-actions

This comment has been minimized.

@hauntsaninja
Copy link
CollaboratorAuthor

I think the mypy_primer hits are from a different bug, will fix in another PR

hauntsaninja added a commit to hauntsaninja/mypy that referenced this pull requestNov 5, 2022
hauntsaninja added a commit that referenced this pull requestNov 6, 2022
@github-actions

This comment has been minimized.

@hauntsaninja
Copy link
CollaboratorAuthor

Hmm, there are still some issues involving type variables:

from typing import overload, TypeVar, UnionZAT = TypeVar("ZAT", bound="ZA")class ZA:    @overload    def f(self: ZAT, x: int) -> ZAT: ...    @overload    def f(self, x: str) -> None: ...    @overload    def f(self: ZAT) -> bytes: ...    def f(*a, **kw): ...class ZB(ZA):    @overload    def f(self, x: int) -> ZB: ...    @overload    def f(self, x: str) -> None: ...    def f(*a, **kw): ...

^this correctly gives an error on master, but this PR removes the error.

Given that this fixes a real issue I might add an xfail test and merge anyway, but let me see if I can figure out a change to make this work as well

@hauntsaninja
Copy link
CollaboratorAuthor

Okay I added the xfail test. The correct solution probably involves thebind_self code. I think some of the pandas errors might come back once it's fixed too

@github-actions
Copy link
Contributor

Diff frommypy_primer, showing the effect of this PR on open source code:

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)+ pandas-stubs/core/series.pyi:1752: error: Unused "type: ignore" commentpandas (https://github.com/pandas-dev/pandas)+ pandas/core/series.py:3380: error: Unused "type: ignore" comment+ pandas/core/series.py:5132: error: Unused "type: ignore" comment+ pandas/core/frame.py:5531: error: Unused "type: ignore" comment

@hauntsaninja
Copy link
CollaboratorAuthor

Let me know if you think the new false negative is not acceptable

Copy link
Member

@JelleZijlstraJelleZijlstra left a comment

Choose a reason for hiding this comment

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

The xfail case seems fairly contrived and false negatives are better than false positives, so I think this is an improvement. Thanks!

@hauntsaninjahauntsaninja merged commita48dd5a intopython:masterNov 10, 2022
@hauntsaninjahauntsaninja deleted the generic-self branchNovember 10, 2022 23:37
hauntsaninja added a commit to hauntsaninja/mypy that referenced this pull requestMar 11, 2023
JelleZijlstra pushed a commit that referenced this pull requestMar 11, 2023
hauntsaninja added a commit to hauntsaninja/mypy that referenced this pull requestApr 13, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JelleZijlstraJelleZijlstraJelleZijlstra approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Incorrect incompatible override report with self type + overload

2 participants

@hauntsaninja@JelleZijlstra

[8]ページ先頭

©2009-2025 Movatter.jp