Skip to content

mypy does not report column and error end for ignore-without-code #21856

Description

@still-wondering

Bug Report

When calling mypy with --show-column-numbers --show-error-end the error end and column are reported.

To Reproduce

# main.py
# mypy: enable-error-code="ignore-without-code"
a: int = "a" # type: ignore
mypy --show-column-numbers --show-error-end main.py

Expected Behavior

Expected the output to contain column and error end numbers:

main.py:3:14:3:27: error: "type: ignore" comment without error code (consider "type: ignore[assignment]" instead)  [ignore-without-code]
Found 1 error in 1 file (checked 1 source file)

The same way it is e.g. if the type ignore is removed in the example:

main.py:3:10:3:12: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
Found 1 error in 1 file (checked 1 source file)

Actual Behavior

No column or error end is included, only the line number:

main.py:3: error: "type: ignore" comment without error code (consider "type: ignore[assignment]" instead)  [ignore-without-code]
Found 1 error in 1 file (checked 1 source file)

Calling mypy with only one of the flags results in the same behavior.

Your Environment

  • Mypy version used: 2.3.0 (compiled)
  • Mypy command-line flags: --show-column-numbers --show-error-end
  • Mypy configuration options from mypy.ini (and other config files): no configuration
  • Python version used: 3.14.6 / 3.12.13

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions