Skip to content

Commit 427f31c

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 5ee1d68 commit 427f31c

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

mypy/subtypes.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import mypy.applytype
88
import mypy.constraints
99
import mypy.typeops
10+
from mypy import errorcodes as codes
1011
from mypy.checker_state import checker_state
1112
from mypy.erasetype import erase_type
1213
from mypy.expandtype import (
@@ -76,7 +77,6 @@
7677
from mypy.types_utils import flatten_types
7778
from mypy.typestate import SubtypeKind, type_state
7879
from mypy.typevars import fill_typevars, fill_typevars_with_any
79-
from mypy import errorcodes as codes
8080

8181
# Flags for detected protocol members
8282
IS_SETTABLE: Final = 1
@@ -89,9 +89,7 @@
8989
# Each tuple is (subclass_fullname, superclass_fullname).
9090
# These are cases where a class is a subclass at runtime but treating it
9191
# as a subtype can cause runtime errors.
92-
UNSAFE_SUBTYPING_PAIRS: Final = [
93-
("datetime.datetime", "datetime.date"),
94-
]
92+
UNSAFE_SUBTYPING_PAIRS: Final = [("datetime.datetime", "datetime.date")]
9593

9694
TypeParameterChecker: _TypeAlias = Callable[[Type, Type, int, bool, "SubtypeContext"], bool]
9795

@@ -538,14 +536,14 @@ def visit_instance(self, left: Instance) -> bool:
538536
return True
539537
rname = right.type.fullname
540538
lname = left.type.fullname
541-
539+
542540
# Check if this is an unsafe subtype relationship that should be blocked
543541
if self.options and codes.UNSAFE_SUBTYPE in self.options.enabled_error_codes:
544542
# Block unsafe subtyping relationships when the error code is enabled
545543
for subclass, superclass in UNSAFE_SUBTYPING_PAIRS:
546544
if lname == subclass and rname == superclass:
547545
return False
548-
546+
549547
# Always try a nominal check if possible,
550548
# there might be errors that a user wants to silence *once*.
551549
# NamedTuples are a special case, because `NamedTuple` is not listed

0 commit comments

Comments
 (0)