Skip to content
This repository has been archived by the owner on May 1, 2022. It is now read-only.

feat: annotation > converter specifiers #7

Merged
merged 10 commits into from
Apr 7, 2022
Merged

Conversation

AstreaTSS
Copy link
Contributor

@AstreaTSS AstreaTSS commented Apr 5, 2022

An idea discussed on the dis-snek server was the idea to allow normal annotations to be use in Molter commands by tying a converter to them. This is what is done for dis-snek objects, actually, but allowing user-defined "injections" would be nice as well.

Take, for example:

@molter.msg_command()
@molter.register_converter(CustomClass, CustomClassConverter)
async def test(ctx: Context, class_var: CustomClass):
    ...

Molter would be able to take care of the conversion just with that decorator.

This PR is not done and in fact is just a draft. Reviews and contributions are encouraged.

@AstreaTSS AstreaTSS added the enhancement New feature or request label Apr 5, 2022
@AstreaTSS AstreaTSS requested a review from silasary April 5, 2022 14:59
@AstreaTSS AstreaTSS marked this pull request as ready for review April 6, 2022 13:11
@AstreaTSS
Copy link
Contributor Author

Ready for review! The logic behind it is somewhat hacky, so I'm interested in doing reviews, comments, etc..

@AstreaTSS AstreaTSS mentioned this pull request Apr 6, 2022
# when this is merged with dis-snek, parameters will be analyzed either
# when the client reads its own commands or when a scale is loaded,
# instead of on creation. that will remove the need for this
command.parse_parameters(has_self=_is_nested(command.callback))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll review myself SMH.

This section is the only section I have concerns with. I would like to do a less naive approach where we go through each parameter and only redo the ones that are needed here.

@AstreaTSS AstreaTSS merged commit c9af4e3 into dev Apr 7, 2022
@AstreaTSS AstreaTSS deleted the converter-injection branch April 7, 2022 12:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant