Skip to content

Commit 42ec16f

Browse files
committed
Manually wrap strings/comments
1 parent 37481a2 commit 42ec16f

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

mypy/checker.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3242,17 +3242,20 @@ def check_typeddict_inheritance(self, defn: ClassDef) -> None:
32423242
source = data.field_sources[field_name]
32433243
if source.base is None:
32443244
self.fail(
3245-
f'Definition of field "{field_name}" incompatible with base class "{base.name}"',
3245+
f'Definition of field "{field_name}" incompatible with base class '
3246+
f'"{base.name}"',
32463247
source.ctx,
32473248
)
32483249
else:
32493250
self.fail(
3250-
f'Incompatible definitions of field "{field_name}" in base classes "{base.name}" and "{source.base.name}"',
3251+
f'Incompatible definitions of field "{field_name}" in base classes '
3252+
f'"{base.name}" and "{source.base.name}"',
32513253
source.ctx,
32523254
)
32533255
if field_name in td.readonly_keys:
32543256
self.note(
3255-
f'This can be resolved by redeclaring the field "{field_name}" with a mutually compatible type',
3257+
f'This can be resolved by redeclaring the field "{field_name}" '
3258+
f"with a mutually compatible type",
32563259
source.ctx,
32573260
)
32583261

@@ -6458,14 +6461,14 @@ def conditional_types_for_iterable(
64586461
elif key in bound.items and isinstance(
64596462
get_proper_type(bound.items[key]), UninhabitedType
64606463
):
6461-
# If an item is explicitly declared uninhabited, we can exclude it from if_types;
6462-
# see testOperatorContainsNarrowsTypedDicts_closed
6464+
# If an item is explicitly declared uninhabited, we can exclude it from
6465+
# if_types; see testOperatorContainsNarrowsTypedDicts_closed
64636466
else_types.append(possible_iterable_type)
64646467
elif key not in bound.items and (bound.is_closed or bound.is_final):
6465-
# If an item is missing and the type is closed, we can exclude it from if_types;
6466-
# see testOperatorContainsNarrowsTypedDicts_closed
6467-
# We also support "final" as a legacy way of expressing "closed" in this specific case;
6468-
# see testOperatorContainsNarrowsTypedDicts_final
6468+
# If an item is missing and the type is closed, we can exclude it from
6469+
# if_types; see testOperatorContainsNarrowsTypedDicts_closed
6470+
# We also support "final" as a legacy way of expressing "closed" in this
6471+
# specific case; see testOperatorContainsNarrowsTypedDicts_final
64696472
else_types.append(possible_iterable_type)
64706473
else:
64716474
if_types.append(possible_iterable_type)

mypy/semanal_typeddict.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ def verify_requiredness_compatibility(
286286
)
287287
else:
288288
self.fail(
289-
f'Field "{field_name}" is required in base class "{source.base.name}" but can be deleted in base class "{primary_source_base.name}"',
289+
f'Field "{field_name}" is required in base class "{source.base.name}" but can '
290+
f'be deleted in base class "{primary_source_base.name}"',
290291
ctx,
291292
)
292293
elif not source.is_required and not source.is_readonly and is_required:
@@ -296,7 +297,8 @@ def verify_requiredness_compatibility(
296297
)
297298
else:
298299
self.fail(
299-
f'Field "{field_name}" is required in base class "{primary_source_base.name}" but can be deleted in base class "{source.base.name}"',
300+
f'Field "{field_name}" is required in base class "{primary_source_base.name}" '
301+
f'but can be deleted in base class "{source.base.name}"',
300302
ctx,
301303
)
302304

@@ -313,12 +315,14 @@ def verify_field_against_closed_bases(
313315

314316
if primary_source_base:
315317
self.fail(
316-
f'Cannot extend closed base class "{closed_base_type.name}" with field "{field_name}" from base class "{primary_source_base.name}"',
318+
f'Cannot extend closed base class "{closed_base_type.name}" with field '
319+
f'"{field_name}" from base class "{primary_source_base.name}"',
317320
ctx,
318321
)
319322
else:
320323
self.fail(
321-
f'Cannot extend closed base class "{closed_base_type.name}" with new field "{field_name}"',
324+
f'Cannot extend closed base class "{closed_base_type.name}" with new field '
325+
f'"{field_name}"',
322326
ctx,
323327
)
324328

@@ -344,7 +348,8 @@ def resolve_field_inheritance(
344348
if child_is_closed is False and closed_bases:
345349
for base_info, _ in closed_bases:
346350
self.fail(
347-
f'Open TypedDict class cannot subclass closed TypedDict class "{base_info.name}"',
351+
f"Open TypedDict class cannot subclass closed TypedDict class "
352+
f'"{base_info.name}"',
348353
ctx,
349354
)
350355

0 commit comments

Comments
 (0)