-
-
Notifications
You must be signed in to change notification settings - Fork 275
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
Getting type error "_SpecialForm" not callable
for pyparsing 3.0.8
#385
Comments
"_SpecialForm" not callable
for pyparsing 3.0.8
"_SpecialForm" not callable
for pyparsing 3.0.8"_SpecialForm" not callable
for pyparsing 3.0.8
The type hints from pyparsing does not work for rdflib: pyparsing/pyparsing#385 Once the type hints for pyparsing is in a better state we can enable them again.
The type hints from pyparsing 3.0.8 does not work for rdflib: pyparsing/pyparsing#385 Once the type hints for pyparsing is in a better state we can enable them again.
The type hints from pyparsing 3.0.8 does not work for rdflib: pyparsing/pyparsing#385 Once the type hints for pyparsing is in a better state we can enable them again.
Using this as a workaround for now: https://github.com/RDFLib/rdflib/blob/603b7be94d81c87e6851d1b20c8faf198d5f5ff2/setup.cfg#L39-L43 [mypy-pyparsing.*]
# This is here because of an upstream issue with pyparsing:
# https://github.com/pyparsing/pyparsing/issues/385
# Once the issue is fixed this should be removed.
follow_imports = skip |
The type hints from pyparsing 3.0.8 does not work for rdflib: pyparsing/pyparsing#385 Once the type hints for pyparsing is in a better state we can enable them again.
Not clear to me what changed in 3.0.8 to cause this. Optional was in 3.0.7 as well. |
3.0.8 added Before this using pyparsing was basically the same as having: [mypy-pyparsing.*]
# This is here because of an upstream issue with pyparsing:
# https://github.com/pyparsing/pyparsing/issues/385
# Once the issue is fixed this should be removed.
follow_imports = skip And IMO it is an okay workaround. I'm actually not sure my theory is entirely right also (i.e. mypy confusing One option is to remove |
I made this change in the rdflib sparql parser.py code: from pyparsing import (
Literal,
Regex,
Opt as Optional, # <-- changed
OneOrMore,
ZeroOrMore,
Forward,
ParseException,
Suppress,
Combine,
restOfLine,
Group,
ParseResults,
delimitedList,
) And that cleared things up with mypy. But this will only work with pyparsing 3.x, not 2.4.7. |
Thanks @ptmcg - I will see if I can do some conditional import maybe. I don't actually get why mypy gets confused about Optional, this may actually be a mypy bug and not a pyparsing bug. |
This issue is that pyparsing/pyparsing/exceptions.py Line 5 in 4e627f2
and in pyparsing/pyparsing/__init__.py Line 138 in 4e627f2
Even though The fix is not to import |
Just for posterity sake I think it is critical to note this is a mypy issue and not an issue with pyparsing, and #386 is really just a workaround to the mypy issue. |
Thanks all for the investigation! Has this bug been reported to the Mypy maintainers yet? |
I somewhat recall seeing a similar bug against mypy before, but I can't say for sure if it was that similar, and I don't know about the issue. I would recommend asking on https://gitter.im/python/typing to see if someone knows, it would be good to link this to a specific issue, but otherwise someone should make one. |
When using pyparsing 3.0.8 I'm getting the following type errors on the master branch of rdflib.
Files in question are:
Errors can be seen in: https://github.com/RDFLib/rdflib/runs/5962843175?check_suite_focus=true
I think the problem somehow relates to
pyparsing.Optional
being confused withtyping.Optional
, but I'm not sure about this, I tried to alias it to something else and tried to use it with package name and it did not help. Not sure why this is happening, but I will try figure out. Just recording this while I work on it.The text was updated successfully, but these errors were encountered: