Swiddis / word-debt-bot

A Discord bot for running a little reading game.
MIT License
2 stars 2 forks source link

Add optional name argument for info command #42

Closed azhitian closed 5 months ago

azhitian commented 5 months ago

Closes #36.

I'm not familiar with BearType, but it complained at me

E beartype.roar.BeartypeCallHintParamViolation: Method word_debt_bot.game.core.WordDebtGame.get_player_by_name() parameter display_name=<Parameter "empty=None"> violates type hint <class 'str'> under non-default configuration BeartypeConf(claw_is_pep526=True, is_color=None, is_debug=False, is_pep484_tower=False, strategy=<BeartypeStrategy.O1: 2>, warning_cls_on_decorator_exception=<class 'beartype.roar._roarwarn.BeartypeClawDecorWarning'>), as <class "discord.ext.commands.parameters.Parameter"> <Parameter "empty=None"> not instance of str.

so I modified

await game_commands_cog.info(game_commands_cog, ctx)

to

await game_commands_cog.info(game_commands_cog, ctx, None)

I'm assuming this is a limitation of using mocks, and in real usage Discord would pass a None and not a Parameter object. Testing the actual bot live on a Discord server it seems to work both with and without the name. Not sure if you think it's worth modifying how command tests are structured over this.

Swiddis commented 5 months ago

Yeah, I'd been messing a bit with it to see if I could get past the default objects being parameters instead of following the type hint. It would be less frustrating if discord.py supported adding help to commands with anything other than default parameter objects. Concluded it wasn't worth it to try and restructure everything, as you concluded it's something that the library handles behind the scenes and for doing mock-based testing we need to handle manually. Although I'll probably need to rewrite the help method anyways.

You can get around most of the issues by using integration tests instead of direct calls, at the cost of granularity.

codecov-commenter commented 5 months ago

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (1f078db) 90.72% compared to head (6533648) 87.86%.

Files Patch % Lines
src/word_debt_bot/game/core.py 14.28% 6 Missing :warning:
src/word_debt_bot/cogs/game_commands.py 66.66% 3 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #42 +/- ## ========================================== - Coverage 90.72% 87.86% -2.86% ========================================== Files 10 10 Lines 291 305 +14 ========================================== + Hits 264 268 +4 - Misses 27 37 +10 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

azhitian commented 5 months ago

Removed dead code