Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

fix: allow coroutines for prefixed commands #581

Merged
merged 1 commit into from
Aug 2, 2022

Conversation

AstreaTSS
Copy link
Contributor

What type of pull request is this?

  • Non-breaking code change
  • Breaking code change
  • Documentation change/addition
  • Tests change

Description

While coroutine functions were always intended to work with prefixed commands if you used them in an annotation, it turns out the support to them was broken. This fixes that.

As a fun side effect, this also may fix a couple of other cases where functions weren't being properly parsed.

Changes

  • Use isroutine instead of isfunction to ensure the function is caught in all cases.
  • If the function has 2 parameters, return the function instead of unnecessarily wrapping it (which also blocks inspect.iscoroutinefunction from doing its job).
  • If the function has 1 parameter, use an asynchronous function wrapper instead of a lambda, using maybe_coroutine for the actual function itself.

Checklist

  • I've formatted my code with Black
  • I've ensured my code works on Python 3.10.x
  • I've tested my code

@LordOfPolls LordOfPolls merged commit 30e6955 into NAFTeam:dev Aug 2, 2022
@AstreaTSS AstreaTSS deleted the allow-coroutines-prefixed branch August 2, 2022 15:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants