typeddjango / pytest-mypy-plugins

pytest plugin for testing mypy types, stubs, and plugins
https://pypi.org/project/pytest-mypy-plugins/
MIT License
102 stars 24 forks source link

python_version is ignored, unable to test python 2 types #47

Open euresti opened 3 years ago

euresti commented 3 years ago

I've got a test case that looks like this:

- case: testAttrsNewStyleClassPy2
  mypy_config:
    python_version = 2.7
  main: |
    import attr
    @attr.s
    class Good(object):
        pass
    @attr.s
    class Bad:  # E: attrs only works with new-style classes
        pass

But it doesn't pass because the python_version = 2.7 line seems to be ignored. I believe it has to do with how mypy is run. mypy --python-version={current_interpreter}. But as there's no way to run mypy with python 2, then there's no way to test python2 types.

sobolevn commented 3 years ago

Here's the line you are interested in: https://github.com/typeddjango/pytest-mypy-plugins/blob/master/pytest_mypy_plugins/item.py#L130

PRs and fixes are welcome!