[pytest-dev] Optional static typing plugin?

Florian Bruhin me at the-compiler.org
Thu Apr 21 03:08:52 EDT 2016


Hey,

* Alessandro Amici <alexamici at gmail.com> [2016-04-21 06:58:50 +0000]:
> I'm starting using python 3 optional static typing and the mypy checker in
> one of my projects and it's working quite nicely, but I could not find a
> mypy, or any other static typing checker, plugin for pytest, so I'm now
> left to run two independent tools for every quality control check.
> 
> Is there a way to check optional static typing from within pytest, that I
> overlooked?
> 
> Is anybody working on a mypy plugin of anything comparable?

Nothing I'm aware of. But I think it should be quite easy to write
something based on e.g. pytest-flakes[1]. I did so with
pytest-mccabe[2] and it was really straightforward.

> In anybody else interested?

I stopped using pytest-{flakes,pep8,pep257,mccabe} myself and switched
back to flake8 again, as it's more powerful/configurable.

So personally I'd prefer a flake8-mypy or running it directly.

What I'd really like though is something validating types dynamically
at *runtime* while running the testsuite. It'd be a much more thorough
check of the types (assuming a good testsuite) and while slow, you
could only run it selectively.

There's [3]/[4] but that only runs on explicitly decorated functions.

Florian

[1] https://github.com/fschulze/pytest-flakes
[2] https://github.com/The-Compiler/pytest-mccabe
[3] https://pypi.python.org/pypi/typecheck-decorator
[4] https://github.com/agronholm/typeguard

-- 
    http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
       GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
     I'm running a crowdfunding to work on my FOSS-project full-time:
                  http://igg.me/at/qutebrowser
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20160421/c4fca987/attachment.sig>


More information about the pytest-dev mailing list