Comments (4)
We run slotscheck
on our CI and dont see any issues with that (https://github.com/hikari-py/hikari/actions/runs/3833692249/jobs/6525422008#step:9:1; latest run at the time of writing) and I dont see how it could cause an issue. We could add an option to disable it, as it is more in-line with the rest of the bot structure, I just forgot about it. But would you mind explaining your issue more in detail?
from hikari.
Random thought on this, could this be caused by the fact that you dont have a run guard in your file?
if __name__ == "__main__:
...
Couldnt this issue be solved by just adding that?
from hikari.
Yes I have a run guard, but not for the bot declaration. The warning is emitted when the bot object is created, not when the application is run.
There is no need in actually creating a bot object in a library, but it's different for an application: having the bot object as a global variable is a quicker approach than dependency injection for example.
Anyways, my use case was just there as an example, I don't want to make a point from it, it could be worked around.
This issue is mostly about "Hey other features can be activated / disabled (banner, update checks), why not this warning?" - and to trace similar requests from other users (if any).
from hikari.
Regarding using run guards:
Consider the basic example from the README:
import hikari
bot = hikari.GatewayBot(token="...")
@bot.listen()
async def ping(event: hikari.GuildMessageCreateEvent) -> None:
"""If a non-bot user mentions your bot, respond with 'Pong!'."""
# Do not respond to bots nor webhooks pinging us, only user accounts
if not event.is_human:
return
me = bot.get_me()
if me.id in event.message.user_mentions_ids:
await event.message.respond("Pong!")
bot.run()
Type guard would usually be implemented only to cover the bot.run call, else you have to put all the code under the if:
import hikari
bot = hikari.GatewayBot(token="...")
@bot.listen()
async def ping(event: hikari.GuildMessageCreateEvent) -> None:
"""If a non-bot user mentions your bot, respond with 'Pong!'."""
# Do not respond to bots nor webhooks pinging us, only user accounts
if not event.is_human:
return
me = bot.get_me()
if me.id in event.message.user_mentions_ids:
await event.message.respond("Pong!")
if __name__ == "__main__":
bot.run()
In this example, the warning will be emitted in any runtime evaluation (including a slotscheck run, for example).
Wouldn't it be more appropriate to put the warning in the run
call instead of the __init__
, at least?
from hikari.
Related Issues (20)
- Localization attribute missing for CommandChoice HOT 1
- typing context not exiting after a webhook is called HOT 2
- Asyncio SSLProto error HOT 3
- Add support for comparing roles HOT 1
- Editing the icon of a server fails HOT 1
- Components shutdown before completion of event listeners
- Option to only cache the bot member HOT 1
- Consider removing upper bound constraint on python version HOT 4
- Support editing community features in `edit_guild` endpoint
- Implement monetization
- Implement default select values
- Specialize InteractionCreateEvent HOT 4
- Consistent BitEnum Naming HOT 1
- Switch to msgspec HOT 4
- Support sending voice messages HOT 2
- Consider using mkdocs material HOT 3
- `Member.joined_at` is now nullable due to breaking API change
- Sync `guilds.GuildFeature` to Official API
- Support Polls
- Passing localization dicts with `hikari.Locale` keys fails HOT 1
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 hikari.