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

Guild.owner_id type mismatch between docs and code. #1270

Open
3 tasks done
dlchamp opened this issue Jan 13, 2025 · 4 comments
Open
3 tasks done

Guild.owner_id type mismatch between docs and code. #1270

dlchamp opened this issue Jan 13, 2025 · 4 comments
Labels
unconfirmed bug Something might not be working

Comments

@dlchamp
Copy link
Contributor

dlchamp commented Jan 13, 2025

Summary

Guild.owner_id documented as int, but is Optional[int] in code

Reproduction Steps

Declare return type as int and try to return owner_id. Strict type checking enabled in vscode.

Minimal Reproducible Code

def get_guild_owner_id(guild: disnake.Guild) -> int:
    return guild.owner_id

Expected Results

I expect owner_id to always be an int, otherwise, update the documentation to show it can also be None

Actual Results

Got an error because int | None doesn't match a return type of int

Type "int | None" is not assignable to return type "int"
  Type "int | None" is not assignable to type "int"
    "None" is not assignable to "int"Pylance[reportReturnType](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportReturnType)

Intents

All, while testing

System Information

- Python v3.12.4-final
- disnake v2.10.1-final
    - disnake importlib.metadata: v2.10.1
- aiohttp v3.11.11
- system info: Windows 11 10.0.22631 AMD64

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

No response

@dlchamp dlchamp added the unconfirmed bug Something might not be working label Jan 13, 2025
@nerd-bear
Copy link
Contributor

Could you please provide the link to the docs where this type is specified?

@dlchamp
Copy link
Contributor Author

dlchamp commented Jan 15, 2025

Could you please provide the link to the docs where this type is specified?

https://docs.disnake.dev/en/stable/api/guilds.html#disnake.Guild.owner_id

@nerd-bear
Copy link
Contributor

I checked the code and the docs and can confirm this bug. I will open a pull request within 24 hours to fix this. Could you also link the relative path to the file where this function is defined (And its line number if possible)

@dlchamp
Copy link
Contributor Author

dlchamp commented Jan 15, 2025

Guild.owner_id is defined here:

self.owner_id: Optional[int] = utils._get_as_snowflake(guild, "owner_id")

This calls utils._get_as_snowflake() which can be found here:

def _get_as_snowflake(data: Any, key: str) -> Optional[int]:

Documentation is here in the class docstring:

owner_id: :class:`int`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed bug Something might not be working
Projects
None yet
Development

No branches or pull requests

2 participants