Git Product home page Git Product logo

Comments (2)

asarkar avatar asarkar commented on July 18, 2024 1

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.

spookylukey avatar spookylukey commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.