python / python/mypy

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

Open
#19,940 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-developer topic-tests
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Bug Report

After using --update-data in https://github.com/python/mypy/pull/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 https://github.com/python/mypy/issues/17465, but only a little, I think.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the --update-data entry point and the testErrorCodeIgnoreMultiple1 fixture shown in the report. Reproduce the update and trace the multiline expected-info alignment; done means realigned comments remain correct without adding blank lines at the end of the test case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.