Skip to content

Releases: hikari-py/hikari

Sharding bugfixes, runtime bugfixes, optimisations

11 Sep 17:38
c9c6640
Compare
Choose a tag to compare

New features

  • New endpoints to support publishing crossposts in announcement channels.
  • BotAware.run and BotAware.start are now required to expose some kwargs
    provided in BotApp as part of the interface.
  • Windows signal handling stuff (see below).
  • New logging logger level can be used. Use "TRACE_HIKARI" to view
    the majority of what was in the "DEBUG" level logs before (namely
    request payloads, etc). This should now allow developers to add stuff to
    the "DEBUG" logs and not be assaulted with socket packet data as soon as
    they turn debug logs on. Debug logs are now much more readable.

Stuff to help new developers out

  • Using with <thing> instead of async with <thing> on objects made by
    hikari that require async with will now suggest how to fix this issue in the
    error message (foo.Bar is async-only, did you mean 'async with'?).

Renaming

  • Private channels are now known as DM channels again, to match the API
    naming.

Fixes and optimisations

  • Speedups for entity rebuilding in cache
  • TCP connector bugfixes for Windows. You should hopefully not get
    NoneType is not a socket errors or similar when aiohttp/asyncio
    encounters issues with the TCP/IP stack on Windows now. Hopefully.
  • Rewritten signal handling logic to work differently. Bots on Windows
    should now support closing gracefully when you use a keyboard interrupt
    (PyCharm will still just murder the process immediately, though).
  • Bot.close has been reimplemented (see below).
  • Fixed bug where closing bot during shard startup would take up to 5
    seconds to begin to be processed. Shards are interrupted immediately
    now.
  • RESTApp's _RESTProvider is now fully implemented again and shouldn't
    throw abstract class initialization errors when used internally, meaning the
    REST only client should work again.
  • Closing the bot now waits for shards to close properly. This was due to a
    regression in the logic from when we recently rewrote this mechanism which
    meant the shard was requested to close, but may not have shut down before
    the event loop got closed forcefully.
  • Platforms that hang on socket IO when a shard zombies or the network
    goes down should now not wait forever.
  • More contextual logging for why shards closed down specifically.
  • If one shard is manually closed directly on startup, the bot should now see
    this and treat it as a failed startup rather than ignoring it.
  • Ping-pong heartbeating is now disabled.

Removed features

  • Bot.terminate (was only added recently but is no longer needed due to
    the other aforementioned changes).
  • debug kwarg in components. Use the TRACE_HIKARI logging level
    instead.
  • version kwarg has been removed from BotApp, RESTApp, RESTClientImpl,
    and GatewayShardImpl.
  • UnavailableGuild no longer exists. Guilds that become unavailable are simply
    marked as being in this state. READY guilds are not cached until they become
    available for the first time.

More stability fixes

08 Sep 17:34
b4c5042
Compare
Choose a tag to compare
More stability fixes Pre-release
Pre-release

Bot shutdown fixes and other minor annoyances that I will get pinged relentlessly about if I don't push this now.

Bug fixes on top of 2.0.0.dev75

08 Sep 07:47
3863a83
Compare
Choose a tag to compare
Pre-release

Fixes several small bugs that caused issues running applications smoothly.

Event streaming, full shard and bot reimplementation, numerous fixes for bugs.

07 Sep 08:28
4846fef
Compare
Choose a tag to compare

API changes

There have been a large number of possibly breaking changes over the past week to make
this API more stable, more efficient, and tidier and clearer to understand. So please
bare with us! I have attempted to document every change below.

hikari.Bot / hikari.impl.bot.BotApp

  • The bot implementation has been rewritten from scratch.
  • logger_level kwarg in hikari.Bot has been renamed to logs (see Logging
    subsection below for details on this).
  • Gateway-specific configuration options are now passed to Bot.run or bot.start
    instead of the constructor. This will allow future releases of this library to
    potentially handle stuff like automatically rescaling if the bot reaches a sharding
    limit during execution. It also allows you to implement your own resharding strategies.
  • stateless constructor parameter has been changed to enable_cache.
  • is_stateless property has been removed. Users are encouraged to use an
    "ask for forgiveness" approach by checking the cache regardless of the cache
    implementation, and then observing the result (whether any match for their query is
    found or not) to determine what to do next (i.e. whether to make an API call or not).
  • New chunking_limit constructor argument.
  • New force_color and allow_color constructor arguments to compliment the
    existing CLICOLOR and CLICOLOR_FORCE environment variable support.
  • You can no longer force a specific gateway version or REST API version
    (without manipulating the URLs).
  • token is now able to be used as a positional argument in the constructor.
  • An overridable print_banner staticmethod has been provided that will allow library
    vendors to bundle or inject their own banners as they see fit for their libraries
    that build on top of hikari.
  • The session start limit is now considered before starting an application. If you have
    10 sessions left for the 24 hour window, but try to start 20 shards, the application
    will fail with a hikari.errors.GatewayError immediately. This will prevent your token
    being potentially reset by Discord without you realising if your application gets stuck
    in a restart loop. You can disable this check by passing ignore_session_start_limit=True
    to Bot.run or Bot.start.
  • New asyncio_debug parameter to Bot.run to toggle asyncio debugging mode on the
    event loop.
  • You can no longer change the event loop that the application is running on. You should
    declare the bot object on the thread you are wishing to run it from, and only do this
    once the event loop you wish to use is initialized. This prevents major bugs that were
    manifested in the previous implementation of this mechanism.
  • New coroutine_tracking_depth argument to bot.run to customise the coroutine
    tracking depth provisionally. This may be removed from CPython at any time without
    warning, so the mechanism will revert to doing "nothing" if your interpreter does not
    support setting this in the future.
  • New enable_signal_handlers argument to Bot.run that can be disabled if you wish to
    implement your own signal handling but still use bot.run.
  • The default executor for the asyncio event loop will now be gracefully shut down when
    Bot.run closes the event loop on exit. This will only be present in Python 3.9 and
    newer. In Python 3.8, this functionality is not available.
  • New close_loop argument to Bot.run that can be set to False optionally to stop
    the event loop being cleared up, any outstanding tasks being cancelled, asyncgens being
    shut down, and the event loop being closed. This will also toggle whether the default
    executor for the event loop is closed or not on Python 3.9 and newer.
  • Bot.close now requests shut down only. It can be made to wait until the application
    terminates, or left to run in the background (preventing exceptions being thrown
    everywhere if you invoke this as part of an event callback, such as a "close bot" command).
  • New close_executor argument to Bot.run that can be optionally set to True to
    enforce any custom executor passed to the Bot constructor gets closed when the event
    loop shuts down. This defaults to False as to not assume ownership.
  • Start up and shutdown orchestration logic has been completely overhauled. You can now
    safely terminate a multisharded bot midway through startup.
  • New Bot.terminate which can be used to manually destroy the entire application immediately.
    This is done concurrently, so should also be faster than before.

Gateway Shard implementation

  • The gateway shard implementation has been fully rewritten from scratch. The existing API
    is mostly the same but a large number of "pointless" properties that consumers will not
    usually ever need to know about have been removed.
  • Reconnect logic has been rewritten, shards should now be much more stable.
  • Logging has been rewritten.
  • There is now assurance that the gateway close code is sent on close, and only sent once.
  • The gateway close code is now 1xxx if shutting down permanently, which should allow the
    bot to appear offline "immediately" when closing down.

Logging

  • Banner and logging have been overhauled. colorlog is now used for the default logging
    configuration, which means log entries will now default to being coloured based on their
    severity, which should make reading logs when DEBUG is on much easier on the eyes.
  • colorlog includes colorama on Windows, which should fix some issues with colour
    support in some terminals, hopefully.
  • logger_level kwarg in hikari.Bot has been renamed to logs, and will now take an
    integer logging level, a string name, or a full logging.config.dictConfig compatible
    schema, as well as None to disable automatically initializing logging.
    You can now use a module like pyyaml or json to pull logging config from a config file
    and pass it directly to your application. Configuration-as-code for the masses!

Rate limiting

  • Internal exponential backoffs should not explode now when they get too large. This was
    fixed by amending a second hidden bug that had not been spotted that allowed exponential
    backoffs to surpass their limits.
  • Exponential backoffs must ALWAYS have a maximum value now.

Guild member chunking and event streaming

  • The guild member chunking interface is now part of the public API.
  • Shard request_guild_members now limits the nonce to a valid constrained value. This
    should prevent invalid inputs from causing the gateway connection to die.
  • A "feature" on Discord where the use of intents prevents guild member details being
    sent on GUILD_CREATE unless you have the GUILD_PRESENCES intent enabled has been
    remediated. Using intents now chunks all guilds to ensure member data is present
    consistently, as long as the privileged intents for GUILD_MEMBERS or GUILD_PRESENCES
    is enabled.
  • The user_ids parameter on the request_guild_members coroutine function in
    GatewayShard is now named users instead.
  • Implemented an EventStream class to use for generating an async iterator across matching
    inbound events. This can be used as an alternative to BotApp.wait_for which handles
    registering and deregistering internal listeners for you automatically.
  • Event streaming is used for guild member chunking, and is now lock-based.
  • Guild member chunking has been redesigned to follow a more user-oriented design.
  • Guild member chunks now behave as if they were a typing.Sequence of members, and
    thus support the standard operations that are exposed by typing.Sequence.

User flags

  • User flags have been renamed appropriately. Check the documentation to view the changes.

Guild model consistency

  • REST Guilds now require the approximate presences and members counts fields.
    API calls will always request that those values be passed.
  • Removed max_presences and max_members fields from hikari.GatewayBot,
    as they were unused and would never be populated with anything but default
    values.
  • Fixed an issue where Discord are not always sending display_splash in GUILD_CREATE
    despite documenting that they should.

Speedups

  • Fixed that ciso8601 dependency requires Microsoft Visual C++ Redistributable 14.0 to
    be installed to allow the library to install. If you do not use the hikari[speedups]
    package target, then a pure-Python version is used instead. (Windows only)
  • Added aiodns and cchardet support, documented how to use uvloop and Python
    optimisation flags in README.

Art

  • The hikari.utilities.art API has been removed and replaced with hikari.utilities.ux
    which provides a different and simpler interface.

Version Sniffer

  • Library version checks have been integrated into hikari.utilities.ux, the
    hikari.utilities.version_sniffer module has been removed entirely.

Changes to internals and development environment, documentation

  • Snowflake#calculate_shard_id has been implemented.
  • Updated flake8-pytest-style from v1.2.3 to 1.3.0.
  • Requirements are now frozen rather than bounded by a minor version.
  • New test suites.
  • Shard tests have been disabled while they await a rewrite.
  • hikari.api.rest.REST is now almost fully documented.
  • Documentation fixes and Pdoc QA.
  • Twemoji pipeline should now be much faster (4-8 seconds to complete).
  • GuildEvent is now documented.
  • aio.first_completed and aio.all_of helpers.

Stability fixes.

30 Aug 20:57
20e24f9
Compare
Choose a tag to compare
Stability fixes. Pre-release
Pre-release

Fixes to stability, correct closing of shards (due to a hidden aiohttp "feature"), and more stuff making handling faulty connections a little more usable...

2.0.0.dev73 - bugfixes, stability, and tidying up

27 Aug 15:26
52a847a
Compare
Choose a tag to compare
  • Reimplemented BotApp.run to handle signal handling better and to close the event loop properly.
    Tasks that are still running get shut down and asyncgens get shut down. (@nekokatt) ¹
  • Removed non-debug asyncio event loop latency checker for performance, and integrated configuration
    with the checker for blocking calls in asyncio on the base event loop. (@nekokatt)
  • Channel events now have cache and REST API helper functions that can be invoked instead of
    bot.rest.<call>. (@nekokatt)
  • Guild events now have cache and REST API helper functions that can be invoked instead of
    bot.rest.<call>. (@nekokatt)
  • Member events now have cache and REST API helper functions that can be invoked instead of
    bot.rest.<call>. (@nekokatt)
  • Updated default User-Agent. (@nekokatt)
  • Made default banner take up less space and not mess up when badly implemented monospace
    fonts are in use. (@nekokatt)
  • Bugfixes for race conditions in starting multisharded bots.
    • Bug fix for starting a bot and shutting it down before it was ready, which previously caused a
      deadlock. (@nekokatt)
    • Bug fix for weird Windows handling of closing a ProactorEventLoop when aiohttp fails to close
      an SSL/TCP connection properly, which previously led to spam of RuntimeErrors on shutting down
      bots in some extreme cases. (@nekokatt)
  • Coroutine tracking depth is now changed as part of BotApp.run only, meaning if you use bot.start,
    you are left to do your own handling of your environment, which is more likely to be desirable
    behaviour. (@nekokatt)
  • Forced websocket closure on shutdown as a resource optimisation. (@nekokatt)
  • Added a handler for aiohttp.WSServerUpgradeError that @Tmpod observed being caused by Discord
    or Cloudflare returning us a 520 non-standard HTTP response code when attempting to upgrade
    an HTTP/1.1 connection to a TCP/IP websocket. The application will now attempt to recover from this
    error using standard exponential backoff that you would see for other repeated failures. (@nekokatt)
  • Disabling the use of intents now will produce a DEPRECATION WARNING. Users should expect
    and prepare for this being removed in the coming weeks entirely
    ready for the October breaking
    intents change deadline quickly approaching. (@nekokatt) ²
  • BotApp now defaults to being state__ful__ rather than state__less__. If you wish to run a stateless
    bot, you should now initialize your BotApp with bot = hikari.Bot(..., stateless=True) to retain
    stateless behaviour. (@nekokatt) ³

¹²³ - these are potentially breaking changes. Please regression-test any of your code before redeploying.

Fixing race conditions in event subsystem.

24 Aug 02:22
ad7f46f
Compare
Choose a tag to compare

From this release, async predicates in bot.wait_for will be fully unsupported.

This is a small breaking change being added that is mediating a bug we have been fighting with for most of yesterday/today.

This has been done to remove issues with handling race conditions that would otherwise have likely had a much greater performance impact on the library.

Lots of little bugfixes

21 Aug 20:36
66849dd
Compare
Choose a tag to compare
Pre-release
2.0.0.dev71

Update setup.py

2.0.0.dev70: Merge pull request #54 from nekokatt/bugfix/credentials-again

20 Aug 17:11
3f4ce5d
Compare
Choose a tag to compare

Changes in bold are considered to be breaking for this release.

  • Increased page size for fetching members from 100 to 1000, speeding up that endpoint and reducing ratelimit occurrances (@FasterSpeeding)
  • Cache optimisations (@FasterSpeeding)
  • Deployment fixes (@nekokatt)
  • Awaiting lazy iterator for awaiting coroutines as the result of .map on a lazy iterator object. This can speed up bulk API calls tenfold (@nekokatt)
  • Documentation consistency fixes (@davfsa)
  • Changed VERIFIED_BOT_DEVELOPER user flag to EARLY_VERIFIED_DEVELOPER (@nekokatt)
  • models are now in base package (@nekokatt)
  • CLICOLOR and CLICOLOR_FORCE support (@nekokatt)
  • Bumped dev dependencies (Dependabot)
  • Adjusted error logging of event exceptions if event handlers are registered (@nekokatt)
  • BotApp.is_stateless (@nekokatt)

2.0.0.dev69

18 Aug 14:05
Compare
Choose a tag to compare
2.0.0.dev69 Pre-release
Pre-release
  • Removed __all__ from __init__.py files, fixing mypy stub issue (will remove documentation on packages, but attributes will remain accessible). (@nekokatt)
  • Tests for users (@davfsa)
  • Test fixes (@davfsa)
  • Status update regression bugfix (@nekokatt)
  • BotApp.run no longer raises GatewayClientClosedException when the gateway is closed manually programmatically. (@nekokatt)
  • LazyIterator#chunk (@FasterSpeeding)
  • Updated documentation and indices to point to GitHub instead of GitLab (@davfsa)
  • Issue templates + code of conduct (@davfsa)