Skip to content

Invalid type: ignore style when checking with mypy #128

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

Closed
jamescw19 opened this issue Feb 15, 2024 · 3 comments
Closed

Invalid type: ignore style when checking with mypy #128

jamescw19 opened this issue Feb 15, 2024 · 3 comments

Comments

@jamescw19
Copy link
Contributor

The jsonschema module has 3 type: ignore comments that are not in PEP484 format. This results in the following error when running mypy where referencing has been imported:

$ mypy my_package
/usr/local/lib/python3.8/dist-packages/referencing/jsonschema.py:432: error: Invalid "type: ignore" comment
/usr/local/lib/python3.8/dist-packages/referencing/jsonschema.py:474: error: Invalid "type: ignore" comment
/usr/local/lib/python3.8/dist-packages/referencing/jsonschema.py:505: error: Invalid "type: ignore" comment
Found 3 errors in 1 file (errors prevented further checking)

The error produced is the same as reported here. However, newer versions of mypy do not fix the issue, as the style is not correct.

These can't be ignored with the mypy ignore_errors = True flag, because these are fatal errors that do not allow mypy to run over the rest of the codebase.

From what I can tell, the error messages just need an extra # after the error code to allow mypy to pass

@Julian
Copy link
Member

Julian commented Feb 15, 2024

Hi there -- pyright (which is what's used here in the repo) has no issue with these, which is why CI passes -- I'm happy to merge a PR to change the syntax, though ideally one that also then adds a minimal mypy setup which would have failed for this, otherwise it's hard to promise it won't happen again.

@jamescw19
Copy link
Contributor Author

It looks like this specific error only occurs in mypy<0.990, so in my setup updating mypy should be fine. I don't think it's worth a mypy check against v0.982 just for this case. But there are of course other blocking mypy errors, so it might be good to make this change, and add the minimal mypy setup just to be safe? What do you think @Julian?

@jamescw19
Copy link
Contributor Author

I opened the PR anyway 🙂

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