Skip to content

Commit aa539c1

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

File tree

3 files changed

+8
-27
lines changed

3 files changed

+8
-27
lines changed

mypy/message_registry.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ def with_additional_msg(self, info: str) -> ErrorMessage:
240240
CANNOT_MAKE_DELETABLE_FINAL: Final = ErrorMessage("Deletable attribute cannot be final")
241241

242242
# Disjoint bases
243-
INCOMPATIBLE_DISJOINT_BASES: Final = ErrorMessage(
244-
'Class "{}" has incompatible disjoint bases'
245-
)
243+
INCOMPATIBLE_DISJOINT_BASES: Final = ErrorMessage('Class "{}" has incompatible disjoint bases')
246244

247245
# Enum
248246
ENUM_MEMBERS_ATTR_WILL_BE_OVERRIDDEN: Final = ErrorMessage(

mypy/stubtest.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ class SubClass(runtime): # type: ignore[misc]
466466
stub_desc=repr(stub),
467467
)
468468

469+
469470
SIZEOF_PYOBJECT = struct.calcsize("P")
470471

471472

@@ -474,33 +475,19 @@ def _shape_differs(t1: type[object], t2: type[object]) -> bool:
474475
475476
Mirrors the shape_differs() function in typeobject.c in CPython."""
476477
if sys.version_info >= (3, 12):
477-
return (
478-
t1.__basicsize__ != t2.__basicsize__ or t1.__itemsize__ != t2.__itemsize__
479-
)
478+
return t1.__basicsize__ != t2.__basicsize__ or t1.__itemsize__ != t2.__itemsize__
480479
else:
481480
# CPython had more complicated logic before 3.12:
482481
# https://github.com/python/cpython/blob/f3c6f882cddc8dc30320d2e73edf019e201394fc/Objects/typeobject.c#L2224
483482
# We attempt to mirror it here well enough to support the most common cases.
484483
if t1.__itemsize__ or t2.__itemsize__:
485-
return (
486-
t1.__basicsize__ != t2.__basicsize__
487-
or t1.__itemsize__ != t2.__itemsize__
488-
)
484+
return t1.__basicsize__ != t2.__basicsize__ or t1.__itemsize__ != t2.__itemsize__
489485
t_size = t1.__basicsize__
490-
if (
491-
not t2.__weakrefoffset__
492-
and t1.__weakrefoffset__ + SIZEOF_PYOBJECT == t_size
493-
):
486+
if not t2.__weakrefoffset__ and t1.__weakrefoffset__ + SIZEOF_PYOBJECT == t_size:
494487
t_size -= SIZEOF_PYOBJECT
495-
if (
496-
not t2.__dictoffset__
497-
and t1.__dictoffset__ + SIZEOF_PYOBJECT == t_size
498-
):
488+
if not t2.__dictoffset__ and t1.__dictoffset__ + SIZEOF_PYOBJECT == t_size:
499489
t_size -= SIZEOF_PYOBJECT
500-
if (
501-
not t2.__weakrefoffset__
502-
and t2.__weakrefoffset__ == t_size
503-
):
490+
if not t2.__weakrefoffset__ and t2.__weakrefoffset__ == t_size:
504491
t_size -= SIZEOF_PYOBJECT
505492
return t_size != t2.__basicsize__
506493

@@ -516,7 +503,6 @@ def _is_disjoint_base(typ: type[object]) -> bool:
516503
return _shape_differs(typ, base)
517504

518505

519-
520506
def _verify_disjoint_base(
521507
stub: nodes.TypeInfo, runtime: type[object], object_path: list[str]
522508
) -> Iterator[Error]:

mypy/types.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,7 @@
123123
DEPRECATED_TYPE_NAMES: Final = ("warnings.deprecated", "typing_extensions.deprecated")
124124

125125
# Supported @disjoint_base decorator names
126-
DISJOINT_BASE_DECORATOR_NAMES: Final = (
127-
"typing.disjoint_base",
128-
"typing_extensions.disjoint_base",
129-
)
126+
DISJOINT_BASE_DECORATOR_NAMES: Final = ("typing.disjoint_base", "typing_extensions.disjoint_base")
130127

131128
# We use this constant in various places when checking `tuple` subtyping:
132129
TUPLE_LIKE_INSTANCE_NAMES: Final = (

0 commit comments

Comments
 (0)