Skip to content

How to programatically run mypy in python? #2369

Closed
@TheDan64

Description

@TheDan64

Hi, I asked this question on the gitter chat originally, but I was redirected here.

A lot of the classes in my library have metaclasses that have custom __isinstance__ and/or __issubclass__ methods so that they work in a certain way and I want to make sure that they will work with mypy. Mypy compatibility is really important to my library and I don't want to just assume they'll work because they pass my own isinstance checks and whatnot.

So my question is, is there is a way to run mypy in my unit tests so that I can assert that they work as expected? For example, I'm imagining something like:

from mypy import validator

def test_my_class():
    def foo() -> MyClass:
        # do some stuff
        return myclassinstance

    assert validator.run(foo, params={})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions