Skip to content

--update-data introduces new blank lines when aligning multi-line expected info comments #19940

Open

Description

@wyattscarpenter

Bug Report

After using --update-data in #19904, I'm seeing a lot of diffs like this:

 [case testErrorCodeIgnoreMultiple1]
 a = 'x'.foobar(b)  # type: ignore[name-defined, attr-defined]
 a = 'x'.foobar(b)  # type: ignore[name-defined, xyz]  # E: "str" has no attribute "foobar"  [attr-defined] \
-    # N: Error code "attr-defined" not covered by "type: ignore" comment
+                                                      # N: Error code "attr-defined" not covered by "type: ignore" comment ignoring [name-defined, xyz]
 a = 'x'.foobar(b)  # type: ignore[xyz, w, attr-defined]  # E: Name "b" is not defined  [name-defined] \
-    # N: Error code "name-defined" not covered by "type: ignore" comment
+                                                         # N: Error code "name-defined" not covered by "type: ignore" comment ignoring [xyz, w, attr-defined]
+
+

it seems to apply extra whitespace at the end of the test case if it realigns a line continuation

Semi-related to #17465, but only a little, I think.

Activity

  1. wyattscarpenter commented on Sep 27, 2025

    @wyattscarpenter
    ContributorAuthor

    The error is probably in here:

    # Update assertion comments within the sections

    In a reverse of the normal course of events, I have the test case figured out already... it turns out the normal test was using backslashes wrong, so fixing that creates a test for this which is already failing. wyattscarpenter@9018224 (I will also add a test case for alignment specifically, later.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-developerIssues relevant to mypy developerstopic-tests

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions