typeddjango/pytest-mypy-plugins

Setting `--python-version` overrides option in `--mypy-ini-file`

antonagestam opened this issue · 1 comments

I'm running into an issue where running mypy gives no errors, but pytest-mypy-plugins gets mypy errors due to it overriding --python-version. I'm setting python_version = 3.7 for compatibility reasons, which causes an attribute error for types.UnionType which I ignore.

But because pytest-mypy-plugins overrides the python_version set in config, in my case to 3.10 this causes mypy to think that types.UnionType is always there and yield and warning for the now unused ignore comment.

Naively I can't figure out why pytest-mypy-plugins needs to set --python-version at all. Perhaps it's worth considering not doing that?

As a less intrusive way forward, perhaps we could make it so that --python-version is only set when no ini config file is given?

@antonagestam

Naively I can't figure out why pytest-mypy-plugins needs to set --python-version at all. Perhaps it's worth considering not doing that?

I think the initial idea was to ensure that we have the same python version that we are running on.

But, I don't like this decision. Let's remove it.
Do you want to send a PR?

P.S. Happy New Year!