Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing Issues (Private Import Usage in Public Namespace) #9607

Closed
3 tasks done
ImplyingICheck opened this issue Oct 12, 2023 · 2 comments
Closed
3 tasks done

Typing Issues (Private Import Usage in Public Namespace) #9607

ImplyingICheck opened this issue Oct 12, 2023 · 2 comments
Labels
as designed This feature is working as intended

Comments

@ImplyingICheck
Copy link

ImplyingICheck commented Oct 12, 2023

Summary

Types are not correctly re-exported from discord.ext.commands.bot.

Reproduction Steps

Attempt to import any types specified in the if TYPE_CHECKING: block.

Minimal Reproducible Code

import typing

import discord

BotT: typing.TypeAlias = discord.ext.commands.bot.BotT

Expected Results

Types used in the public namespace of a py.typed package should all be exported.

Attempting to provide type information for any subclass of a discord.ext.commands.bot class cannot correctly inherit type information.

Actual Results

Types not re-exported.

Intents

N/A

System Information

  • Python v3.11.6-final
  • discord.py v2.3.2-final
  • aiohttp v3.8.6
  • system info: Linux 5.15.90.1-microsoft-standard-WSL2 # 1 SMP Fri Jan 27 02:56:13 UTC 2023

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

There is a consensus in the typing community that imported private symbols should be explicitly exported. For example,

from discord.ext.commands._types import BotT as BotT

While the as ... seems redundant, the lack of an export keyword/construction in Python requires it to maintain consistent namespace standards.

@ImplyingICheck ImplyingICheck added the unconfirmed bug A bug report that needs triaging label Oct 12, 2023
@Rapptz Rapptz added as designed This feature is working as intended and removed unconfirmed bug A bug report that needs triaging labels Oct 12, 2023
@Rapptz
Copy link
Owner

Rapptz commented Oct 12, 2023

This is a private type and a private module, so this is by design. Duplicate of #7743

@Rapptz Rapptz closed this as not planned Won't fix, can't repro, duplicate, stale Oct 12, 2023
@ImplyingICheck
Copy link
Author

ImplyingICheck commented Oct 12, 2023

Having read #7743, I now see the intention. Would there be a possibility of renaming discord.ext.commands.bot to discord.ext.commands._bot to reflect the directory of sub-packages being private?

This would prevent confusion and bring consistency with PEP 561, "...all [py.typed packages'] sub-packages MUST support type checking...".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
as designed This feature is working as intended
Projects
None yet
Development

No branches or pull requests

2 participants