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

Avoid spurious non-overlapping eq error with metaclass with__eq__#19220

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
JukkaL merged 1 commit intomasterfromelvis-eq
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletionsmypy/typeops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1190,6 +1190,10 @@ def custom_special_method(typ: Type, name: str, check_all: bool = False) -> bool
if isinstance(typ, FunctionLike) and typ.is_type_obj():
# Look up __method__ on the metaclass for class objects.
return custom_special_method(typ.fallback, name, check_all)
if isinstance(typ, TypeType) and isinstance(typ.item, Instance):
if typ.item.type.metaclass_type:
# Look up __method__ on the metaclass for class objects.
return custom_special_method(typ.item.type.metaclass_type, name, check_all)
if isinstance(typ, AnyType):
# Avoid false positives in uncertain cases.
return True
Expand Down
8 changes: 8 additions & 0 deletionstest-data/unit/check-expressions.test
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2172,6 +2172,14 @@ class Custom(metaclass=CustomMeta): ...
Normal == int() # E: Non-overlapping equality check (left operand type: "type[Normal]", right operand type: "int")
Normal == Normal
Custom == int()

n: type[Normal] = Normal
c: type[Custom] = Custom

n == int() # E: Non-overlapping equality check (left operand type: "type[Normal]", right operand type: "int")
n == n
c == int()

[builtins fixtures/bool.pyi]

[case testCustomContainsCheckStrictEquality]
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp