Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
euresti opened this issue Dec 21, 2020 · 1 comment
Open

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

euresti opened this issue Dec 21, 2020 · 1 comment

Comments

@euresti
Copy link

euresti commented Dec 21, 2020

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
Copy link
Member

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!

abelcheung added a commit to abelcheung/types-lxml that referenced this issue Oct 25, 2023
Multiple problems with mypy / pytest-mypy-plugin interaction:
- Starting from mypy 1.4, output is dependant on python version by default, test suite fails for python < 3.10 unless conditional file tests are used
- 'python_version' mypy setting not honored (typeddjango/pytest-mypy-plugins#47)
- Even if above bug is fixed, it's impossible to upgrade because jinja2 doesn't support all chevron template, test suite needs substantial changes
OTOH, annotation itself is compatible with mypy 1.5 (not 1.6 tho)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants