-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
unexpected "warn_ungrouped_named_tokens_in_collection" warnings in versions >2.4.0 #110
Comments
Thanks - I just pushed out 2.4.2, which has all these warnings disabled by default. |
Ah, great. This can be closed then. |
Worth noting, these returned in 3.0.0 (I assume intentionally?), and so are cropping up again where pip/packaging call into pyparser. |
@fungi - thanks for reporting this, though it does sadden me. I'm confused though - I was under the impression that packaging used a vendored 2.4.7 version of pyparsing, and so was immune to any changes in 3.0.0 until that version got vendored in (after some testing). Can you update this ticket to how these warnings are getting emitted? |
You're right, it's not as dire as previously unless something directly depending on pyparsing gets installed. I saw it start cropping up during wheel builds, because the pypa/build tool declares an install_requires on packaging>=19.0, and packaging in turn has an install_requires on pyparsing>=2.0.2, which now brings in pyparsing 3.0.0. |
And does this build tool regularly run with |
Sorry, I didn't mean to imply it was happening by default. This is when running explicitly with PYTHONWARNINGS=error in order to catch incorrect behaviors, use of deprecated functions and other latent bugs; but since the exception is a generic one and the warning string contains a colon (the field separator for the PYTHONWARNINGS envvar), the only way to effectively filter it is to ignore all UserWarning exceptions raised within packaging.requirements, which could easily mask other conditions there. I guess my question is, does that UserWarning actually indicate something packaging.requirements is doing incorrectly, which should be fixed? |
You should be able to ignore warnings from the pyparsing module using |
Thanks for the clarification, I'll see if the pypa/packaging maintainers have any interest in help correcting their use of pyparsing, or just want to wait on the PEP 508 parser replacement work instead. |
Can you post the actual warning and with line number/traceback so I can see where in the code this is getting flagged? |
Sure! Here's a minimal reproducer with full TB (essentially the same as pypa/packaging#170 but now only occurs when warnings are enabled):
|
I looked further at the pyparsing code and at your grammar, and this turns out to be a false alarm in pyparsing. I've tightened up the warning detection code, and this will be fixed in 3.0.5. |
Thanks so much! |
3.0.5 released with this fix |
Thanks again! |
I believe this fix may have broken this code in requirements.py:
To fix the warning, I renamed the internally defined results names This code should also be unnecessary, though since it uses a numeric index to get the version, should continue to work. Though again,
|
@ptmcg I'm not super familiar with pyparsing, but that code doesn't seem to work. With from packaging.markers import MARKER_EXPR, Marker
from pyparsing import ParseResults, originalTextFor
def into_marker(original: str, loc: int, results: ParseResults) -> Marker:
print("original:", original)
print("loc: ", loc)
print("results: ", repr(results))
return Marker(results[0])
MARKER_EXPR = originalTextFor(MARKER_EXPR)("marker")
MARKER_EXPR.setParseAction(into_marker)
MARKER_EXPR.parseString('python_version >= "3.6"') Produces the following output:
It doesn't seem to change depending on the usage of the This expression seems to work: MARKER_EXPR.setParseAction(
lambda s, l, t: Marker(s[t[0] : t[-1]])
) But I'm not sure why, and the documentation seems to imply that it shouldn't work, so I'm not sure what's going on here. |
In your code that doesn't work, this line:
should be:
|
Ah, thank you! That change works -- I'm not sure why the downstream was using |
It is very old code, and probably predates when |
Closes pypa#486 Context in pyparsing: pyparsing/pyparsing#110 (comment)
Fixed (for the last time!) in 3.0.6 |
Hi Paul, I wanted to alert you to this issue in case you didn't hear about it yet: (python-poetry/poetry#1244, pypa/packaging#170). The poetry people are working around it by fixing pyparsing to 4.2.0 😕
The text was updated successfully, but these errors were encountered: