pytest-mypy-plugins icon indicating copy to clipboard operation
pytest-mypy-plugins copied to clipboard

Support for mypy .test files.

Open zero323 opened this issue 3 years ago • 3 comments

This is a feature request.

It might be nice to get support for handling mypy-style .test files:

[case foo]

reveal_type(1 + 1)  # N: Revealed type is "builtins.int"

[out]]

-- Comment

[case bar]

reveal_type(1 + 1)

[out]
main:2: note: Revealed type is "builtins.int"

zero323 avatar Oct 14 '21 10:10 zero323

Why not just use mypy's test then? It is a completely different format 🤔

sobolevn avatar Oct 14 '21 10:10 sobolevn

Why not just use mypy's test then?

Good question. I guess that depends on the use case. I used mypy tests in the past, and accumulated a lot of test files. However:

  • It is internal and undocumented feature.
  • It assumes rather specific project layout.

So it is hard sell for more strict projects.

Additionally, supporting these here, would allow smoother migration without keeping track of what should go into mypy.test.testcheck.TypeCheckSuite.files. Huge win for me :)

It is a completely different format 🤔

Up to certain point. Once you parse input file into cases containing:

  • options: Optional[str]
  • main: str
  • out:str

handling both main and out shouldn't require additional logic (inline comment format is the same, and out is just mypy output).

I am aware that it might be out-of-scope here, just the idea :)

zero323 avatar Oct 14 '21 10:10 zero323

Another idea: mypy's .test files converter into our yml format? 🤔 It might be easier!

sobolevn avatar Oct 14 '21 12:10 sobolevn