MyPy Error on 5.10.0
nagibyro opened this issue · 5 comments
Hello,
With the 5.10.0
release we run into a syntax error in aiogoogle/resource.py:38
when running mypy on our project.
[~/projects/foo]$ poetry update aiogoogle
Updating dependencies
Resolving dependencies... (1.7s)
Package operations: 0 installs, 1 update, 0 removals
• Updating aiogoogle (5.9.0 -> 5.10.0)
Writing lock file
[~/projects/foo]$ poetry run mypy --config-file ./pyproject.toml src/
/Users/username/Library/Caches/pypoetry/virtualenvs/foo-vYsNM9k8-py3.12/lib/python3.12/site-packages/aiogoogle/resource.py:38: error: invalid syntax [syntax]
Found 1 error in 1 file (errors prevented further checking)
Our mypy config is simple
# pyproject.toml
[tool.mypy]
plugins = ["mypy_django_plugin.main"]
ignore_missing_imports = true
We downgraded to 5.9.0
and the issue was fixed
[~/projects/foo]$ poetry update aiogoogle
Updating dependencies
Resolving dependencies... (1.7s)
Package operations: 0 installs, 1 update, 0 removals
• Updating aiogoogle (5.10.0 -> 5.9.0)
[~/projects/foo]$ poetry run mypy --config-file ./pyproject.toml src/
Success: no issues found in 137 source files
EDIT: additional context we are using mypy 1.10.1
Thanks for the detailed error report @nagibyro!
Do you mind sharing what aiogoogle/resource.py:38 looks like on your end? I tried downloading the published package from the Python package repo and it seems line 38 is a comment. Very strange it's causing a syntax error.
Also, this is the 5.10.0 PR: 1c78ecf, I doubt it's what caused it.
I have this issue as well, this is line 38 at my end:
[37] # TODO: etagRequired: {
[38] # type: "boolean", # noqa: F821 (weird error)
[39] # description: "Whether this method requires an ETag to be specified. The ETag is sent as an HTTP If-Match or If-None-Match header."
[40] # }
[41] # NOTE: etagRequired is only mentioned once in all of the discovery documents available from Google. (In discovery_service-v1. So, it isn't actually being used)
Mypy looks for # type: XXX
comments, as they can include type hints or type ignore commands. It mistakes this line for an invalid comment type hint.
Confirmed on my end aiogoogle resource.py
in our site-packages looks the same as @TomerYogev's
Simply changing the comment to not be # type: ...
fixes the mypy issue, opened a pr just rewording the comment.
Awesome! Thanks a lot @nagibyro & @TomerYogev !
Fix released in v5.11.0