question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GatewayBot.stream produces typing errors

See original GitHub issue

Steps to reproduce

  1. Create a GatewayBot
  2. Open a stream (I have only tested with InteractionCreateEvent’s
  3. With or without filter, they both give typing errors.
  4. Deprecated async or sync both produce these errors.
with bot.stream(hikari.InteractionCreateEvent, 120).filter(
        lambda e: (
            isinstance(e.interaction, hikari.ComponentInteraction)
            and e.interaction.user == author
            and e.interaction.message == message
        )
    ) as stream:
        for event in stream:
            ...

Expected result

Everything works as expected, without typing errors. This is the exact syntax used in the hikari examples.

Actual result

Everything works as expected except for when using filter this error is displayed:

Object of type "LazyIterator[InteractionCreateEvent]" cannot be used with "with" because it does not implement __enter__

and when not using filter:

"EventStream[InteractionCreateEvent]" is not iterable "__next__" method not defined on type "LazyIterator[InteractionCreateEvent]"

System info

hikari (2.0.0.dev104) [79548984]
located at /home/projects/hikari-lightbulb/.venv/lib/python3.10/site-packages/hikari
CPython 3.10.0 GCC 11.1.0
Linux love 5.10.79-1-lts #1 SMP Fri, 12 Nov 2021 19:04:00 +0000 x86_64

Further info

We discussed this briefly, but I wanted to get it onto the issue tracker as it’s quite annoying.

Checklist

  • I have made sure to remove ANY sensitive information (bot token, passwords, credentials, personal details, etc.).
  • I have searched the issue tracker and have made sure it’s not a duplicate. If it is a follow up of another issue, I have specified it.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Jonxslayscommented, Dec 6, 2021

You are correct about that, it should be async for event in stream. That does not resolve the issue though.

0reactions
davfsacommented, Dec 10, 2021

Closed by #917

Read more comments on GitHub >

github_iconTop Results From Across the Web

2 - Stack Overflow
I'm working with a Discord bot using the node.js module discord.js. Recently an error appears on start up (when the bot attempts to...
Read more >
hikari-py/hikari: A Discord API wrapper for Python ... - GitHub
An opinionated, static typed Discord microframework for Python3 and asyncio that supports Discord's v10 REST and Gateway APIs. Built on good intentions and ......
Read more >
Voice.AI Gateway Bot API Reference - AudioCodes
The Voice.AI Gateway creates a new conversation by using a pre-configured URL. 2. The reply contains URLs for posting messages to the ...
Read more >
Search - appsloveworld.com
Coding example for the question FetchError: request to https://discordapp.com/api/v7/gateway/bot failed, reason: read ECONNRESET-discord.js.
Read more >
Gateway Intents - discord.js Guide
Intents are named groups of pre-defined WebSocket events, which the discord.js client will receive. If you omit DirectMessageTyping , for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found