redbaron icon indicating copy to clipboard operation
redbaron copied to clipboard

[BUG] GroupingError

Open xiaoyao1949 opened this issue 6 years ago • 3 comments

error here is my code:

async def request(
        self,
        method: Text = "post",
        subpath: Optional[Text] = None,
        content_type: Optional[Text] = "application/json",
        return_method: Text = "json",
        **kwargs: Any
    ):
        """Send a HTTP request to the endpoint.

        All additional arguments will get passed through
        to aiohttp's `session.request`."""

        # create the appropriate headers
        headers = {}
        if content_type:
            headers["Content-Type"] = content_type

        if "headers" in kwargs:
            headers.update(kwargs["headers"])
            del kwargs["headers"]

        url = concat_url(self.url, subpath)
        async with self.session() as session:
            async with session.request(
                method,
                url,
                headers=headers,
                params=self.combine_parameters(kwargs),
                **kwargs
            ) as resp:
                if resp.status >= 400:
                    raise ClientResponseError(
                        resp.status, resp.reason, await resp.content.read()
                    )
                return await getattr(resp, return_method)()

xiaoyao1949 avatar Sep 10 '19 03:09 xiaoyao1949

I have the same problem with all objects that I await and pass to a function in same expression, e.g.

max(await x())

or

l = []
l.append(await y())

If I put parentheses around awaited object, it will work, so:

max(await (x()))

or

l = []
l.append(await (y()))

doesn't raise this error.

Jackenmen avatar Dec 26 '19 04:12 Jackenmen

Looks like the grammar in baron is ready but a redbaron wrapper is missing: https://baron.readthedocs.io/en/latest/grammar.html#async-with

webknjaz avatar Jan 07 '20 22:01 webknjaz

Problem still exists to this date. Is there any update on this?

MoBoo avatar Oct 12 '23 18:10 MoBoo