There is no way to ignore `valid-type` error for valid type alias `type` statements

Bug Report

Python 3.12 added support for the type statement as described in PEP 695. As discussed in #15238, Mypy does not yet support PEP 695. Unfortunately, it seems that Mypy also does not support ignoring error codes for lines using type.

To Reproduce

After reading the documentation at https://mypy.readthedocs.io/en/stable/error_codes.html#error-codes:

In mypy.ini:

[mypy]
disable_error_code = valid-type

In a Python source file:

type Number = int | float # type: ignore

type AnotherNumber = int | float # type: ignore[valid-type]

type YetAnotherNumber = int | float # mypy: disable-error-code="valid-type"

On the command line:

mypy --disable-error-code='unused-ignore' ...

Expected Behavior

All five of these examples should tell Mypy ignore the valid-type error code.

Actual Behavior

The error code is not ignored. In every case, the following error is still generated:

error: PEP 695 type aliases are not yet supported  [valid-type]

In a few of the cases, an error like

error: Unused "type: ignore" comment  [unused-ignore]

is generated.

Your Environment

  • Mypy version used: 1.7.1
  • Mypy command-line flags: see above
  • Mypy configuration options from mypy.ini (and other config files): see above
  • Python version used: 3.12