Skip to content

Commit 089e952

Browse files
m-acieksterliakov
andauthored
Remove superfluous iteration
Co-authored-by: Stanislav Terliakov <50529348+sterliakov@users.noreply.github.com>
1 parent 427f31c commit 089e952

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

mypy/subtypes.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,12 @@ def visit_instance(self, left: Instance) -> bool:
538538
lname = left.type.fullname
539539

540540
# Check if this is an unsafe subtype relationship that should be blocked
541-
if self.options and codes.UNSAFE_SUBTYPE in self.options.enabled_error_codes:
542-
# Block unsafe subtyping relationships when the error code is enabled
543-
for subclass, superclass in UNSAFE_SUBTYPING_PAIRS:
544-
if lname == subclass and rname == superclass:
545-
return False
541+
if (
542+
self.options
543+
and codes.UNSAFE_SUBTYPE in self.options.enabled_error_codes
544+
and (lname, rname) in UNSAFE_SUBTYPING_PAIRS
545+
):
546+
return False
546547

547548
# Always try a nominal check if possible,
548549
# there might be errors that a user wants to silence *once*.

0 commit comments

Comments
 (0)