Comments (2)
Thanks for your response. As for a minimal reproducible example, I don’t believe I could get any more minimal than what was shown, and the error was certainly reproducible with the given code and input. If that wasn’t enough, then as a maintainer you could have closed the ticket without looking but as a user, I couldn’t have helped it any other way.
from parsy.
It looks like you have a bug in your parser, in particularly, the line for node
- the lambda takes a single argument, but many()
produces multiple values, and combine
passes them using *args
- see https://parsy.readthedocs.io/en/latest/ref/methods_and_combinators.html#parsy.Parser.combine . This means that the node
definition will work if the previous parser produces an iterable that has exactly one value but fail for multiple or zero value.
Here is a simplified example:
In [1]: from parsy import *
In [2]: node = string(';') >> string('X').many().combine(lambda x: {'properties': x})
In [3]: node.parse(';X')
Out[3]: {'properties': 'X'}
In [4]: node.parse(';XX')
TypeError: <lambda>() takes 1 positional argument but 2 were given
In [5]: node.parse(';')
TypeError: <lambda>() missing 1 required positional argument: 'x'
You need to use a lambda that takes multiple arguments as *args
, or more probably just use map
- https://parsy.readthedocs.io/en/latest/ref/methods_and_combinators.html#parsy.Parser.map
BTW, normally I would have just closed this issue without looking at the code, because it's not a great report. A good bug report should be a Minimal Reproducible Example - see also Craft Minimal Bug Reports - (I should add these to the README for submitting reports). If you don't do this, you are in effect asking the maintainers of the project to debug your code for you (as I have done) and often if you do it yourself, you will discover where the bug is.
from parsy.
Related Issues (20)
- >>= for bind HOT 14
- Missing documentation for eof parser? HOT 1
- Improve debugging: peek show next data in errors HOT 5
- Recompute line number for ParseError passed up from .bind
- Improve debugging ergonomics HOT 3
- Inline (explicit) and implicit tracing
- Missing seq import statement in tutorial HOT 1
- Help with parsing that "hangs" HOT 3
- Bug with backtracking and generate? HOT 4
- Parsy 1.3.0 fails to support 'group' keyword of `regex` function HOT 1
- async/await support in generate() HOT 6
- Release HOT 2
- Interested in a version of parsy with type annotations? HOT 3
- Allow providing a default to optional() HOT 2
- maintaining state while parsing HOT 3
- [bug] Parser.desc() causes loss of error information, simple fix HOT 2
- alt doesn't use fallback parsers when initial parser has .many()/.sep_by() HOT 1
- Processing list of tokens HOT 1
- Seeking Guidance on Implementing Parser Autocomplete HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parsy.