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

Remove tests/test_pattern_matching.py from mypy.exclude config #134

Closed
ThirVondukr opened this issue Jul 19, 2023 · 6 comments
Closed

Remove tests/test_pattern_matching.py from mypy.exclude config #134

ThirVondukr opened this issue Jul 19, 2023 · 6 comments

Comments

@ThirVondukr
Copy link
Contributor

Linked issue: python/mypy#10201
As of now that issue is closed and mypy supports pattern matching

@francium
Copy link
Member

Perhaps I'm not fully understanding, can you clarify what you mean here? Or a PR would be great as well.

Right now we do run tests/test_pattern_matching.py, but only for python versions 3.10 and above.

@ThirVondukr
Copy link
Contributor Author

Hm, sorry, I didn't consider pre 3.10 versions of python, would mypy flat out fail if you try to lint this file on 3.8 or 3.9? Because comment in pyproject.toml simply says that mypy doesn't support pattern matching, but it's no longer true

@francium
Copy link
Member

francium commented Jul 19, 2023

Yeah because of differences between versions in what they support the GitHub CI config runs things based on what version. pattern matching, type checking, flake8, mypy are all configured like this.

See https://github.com/rustedpy/result/blob/master/.github/workflows/ci.yml

@francium
Copy link
Member

Because comment in pyproject.toml simply says that mypy doesn't support pattern matching, but it's no longer true

# Exclude files with pattern matching syntax until Mypy supports it;
# see https://github.com/python/mypy/issues/10201
exclude = "tests/test_pattern_matching.py"

You're right. I'm not sure if there's a way to make it work between different versions though.
Perhaps that most logical thing to do here is wait until Python 3.8 and 3.9 become end-of-lie, then remove this exclude.

For now I think updating the comment to mention this would be best.

Anyway, I don't think this exclude is having any affect on users of this library, it only affects any developer working on this specific test file.

I'm going to push up a commit to update the comment on pyproject.toml and close this PR

@francium
Copy link
Member

francium commented Jul 19, 2023

Comment updated in cfda8ec.

Trying to run mypy with a Python version that doesn't support pattern matching results in the following error:

$ mypy tests/test_pattern_matching.py
tests/test_pattern_matching.py:11:12: error: invalid syntax; you likely need to run mypy using Python 3.11 or newer  [syntax]

@ThirVondukr
Copy link
Contributor Author

I think comment in pyproject.toml was a bit misleading then 😅 maybe it should be changed to something like

Exclude files with pattern matching for testing on python versions older than 3.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants