|
11 | 11 |
|
12 | 12 | import logging |
13 | 13 | import re |
14 | | -from typing import TYPE_CHECKING, Any, Final, NamedTuple |
| 14 | +from typing import TYPE_CHECKING, Any, Final, NamedTuple, cast |
15 | 15 |
|
16 | 16 | import discord |
17 | 17 | from discord.ext import commands |
|
25 | 25 | from .. import Utility |
26 | 26 |
|
27 | 27 | # A "stub" for type hinting |
28 | | - class ProfileCustomizeView(discord.ui.View): |
| 28 | + class _ProfileCustomizeView(discord.ui.View): |
29 | 29 | _original_message: discord.Message | None |
30 | 30 |
|
31 | 31 | def set_original_message(self, message: discord.Message) -> None: ... |
@@ -106,7 +106,7 @@ def _check_is_bot(user_or_role: discord.Member | discord.User | discord.Role) -> |
106 | 106 |
|
107 | 107 | async def make_profile_customize_view( |
108 | 108 | cog: Utility, ctx: commands.Context[Bot], profile_detail: ProfileDetail, profile: ProfileModel |
109 | | -) -> type[ProfileCustomizeView]: |
| 109 | +) -> type[_ProfileCustomizeView]: |
110 | 110 | """Create a UI view for customizing profiles. |
111 | 111 |
|
112 | 112 | Args: |
@@ -308,6 +308,10 @@ async def customize_button( |
308 | 308 | """Open the modal for profile customization.""" |
309 | 309 | await interaction.response.send_modal(ProfileCustomizeModal()) |
310 | 310 |
|
| 311 | + if TYPE_CHECKING: |
| 312 | + # This is quite ugly, but until Protocol intersection is supported we have to do this |
| 313 | + ProfileCustomizeView = cast(type[_ProfileCustomizeView], ProfileCustomizeView) # noqa: N806 |
| 314 | + |
311 | 315 | return ProfileCustomizeView |
312 | 316 |
|
313 | 317 |
|
|
0 commit comments