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

Codebase doesn't have correct type hinting #168

Open
Laura7089 opened this issue Aug 23, 2021 · 0 comments
Open

Codebase doesn't have correct type hinting #168

Laura7089 opened this issue Aug 23, 2021 · 0 comments
Labels
documentation Improvements or additions to documentation smells Things that work but could be improved

Comments

@Laura7089
Copy link
Member

Laura7089 commented Aug 23, 2021

mypy checking of the types in the codebase turns up a lot of errors.

Commit c39d13b contains:

esportsbot/cogs/AdminCog.py:3: error: Skipping analyzing "discord.ext": found module but no type hints or library stubs
esportsbot/cogs/AdminCog.py:5: error: Item "None" of "Optional[str]" has no attribute "replace"
esportsbot/DiscordReactableMenus/reactable_lib.py:20: error: Need type annotation for "options" (hint: "options: Dict[<type>, <type>] = ...")
esportsbot/lib/stringTyping.py:61: error: Name "strIsChannelMention" already defined on line 51
esportsbot/models.py:8: error: Variable "esportsbot.models.base" is not valid as a type
esportsbot/models.py:8: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
esportsbot/models.py:8: error: Invalid base class "base"
esportsbot/models.py:15: error: Variable "esportsbot.models.base" is not valid as a type
esportsbot/models.py:15: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
esportsbot/models.py:15: error: Invalid base class "base"
esportsbot/models.py:23: error: Variable "esportsbot.models.base" is not valid as a type
esportsbot/models.py:23: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
esportsbot/models.py:23: error: Invalid base class "base"
esportsbot/models.py:33: error: Variable "esportsbot.models.base" is not valid as a type
esportsbot/models.py:33: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
esportsbot/models.py:33: error: Invalid base class "base"
esportsbot/models.py:43: error: Variable "esportsbot.models.base" is not valid as a type
esportsbot/models.py:43: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
esportsbot/models.py:43: error: Invalid base class "base"
esportsbot/models.py:51: error: Variable "esportsbot.models.base" is not valid as a type
esportsbot/models.py:51: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
esportsbot/models.py:51: error: Invalid base class "base"
esportsbot/models.py:57: error: Variable "esportsbot.models.base" is not valid as a type
esportsbot/models.py:57: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
esportsbot/models.py:57: error: Invalid base class "base"
esportsbot/models.py:63: error: Variable "esportsbot.models.base" is not valid as a type
esportsbot/models.py:63: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
esportsbot/models.py:63: error: Invalid base class "base"
esportsbot/models.py:70: error: Variable "esportsbot.models.base" is not valid as a type
esportsbot/models.py:70: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
esportsbot/models.py:70: error: Invalid base class "base"
esportsbot/models.py:79: error: Variable "esportsbot.models.base" is not valid as a type
esportsbot/models.py:79: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
esportsbot/models.py:79: error: Invalid base class "base"
esportsbot/models.py:90: error: Variable "esportsbot.models.base" is not valid as a type
esportsbot/models.py:90: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
esportsbot/models.py:90: error: Invalid base class "base"
esportsbot/models.py:98: error: Variable "esportsbot.models.base" is not valid as a type
esportsbot/models.py:98: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
esportsbot/models.py:98: error: Invalid base class "base"
esportsbot/db_gateway.py:6: error: Skipping analyzing "sqlalchemy_utils": found module but no type hints or library stubs
esportsbot/cogs/VoicemasterCog.py:1: error: Skipping analyzing "discord.ext": found module but no type hints or library stubs
esportsbot/cogs/LogChannelCog.py:1: error: Skipping analyzing "discord.ext": found module but no type hints or library stubs
esportsbot/cogs/DefaultRoleCog.py:1: error: Skipping analyzing "discord.ext": found module but no type hints or library stubs
esportsbot/cogs/TwitterCog.py:5: error: Skipping analyzing "tweepy": found module but no type hints or library stubs
esportsbot/cogs/TwitterCog.py:6: error: Skipping analyzing "discord.ext": found module but no type hints or library stubs
esportsbot/cogs/TwitterCog.py:102: error: Unsupported right operand type for in ("Optional[str]")
esportsbot/cogs/TwitterCog.py:102: error: Item "None" of "Optional[User]" has no attribute "id"
esportsbot/cogs/TwitterCog.py:104: error: Invalid index type "int" for "Dict[str, Dict[Any, Any]]"; expected type "str"
esportsbot/cogs/TwitterCog.py:117: error: Invalid index type "int" for "Dict[str, Dict[Any, Any]]"; expected type "str"
esportsbot/cogs/TwitterCog.py:131: error: Incompatible types in assignment (expression has type "int", variable has type "str")
esportsbot/cogs/TwitterCog.py:173: error: Argument 1 to "len" has incompatible type "Optional[Set[Any]]"; expected "Sized"
esportsbot/cogs/TwitterCog.py:173: error: Unsupported right operand type for in ("Optional[Set[Any]]")
esportsbot/cogs/TwitterCog.py:183: error: Unsupported right operand type for in ("Optional[Set[Any]]")
esportsbot/cogs/TwitterCog.py:226: error: Item "None" of "Optional[Any]" has no attribute "get"
esportsbot/cogs/TwitterCog.py:381: error: Item "VoiceChannel" of "Union[TextChannel, VoiceChannel]" has no attribute "create_webhook"
esportsbot/cogs/TwitterCog.py:491: error: Argument "id" to "partial" of "Webhook" has incompatible type "Optional[str]"; expected "int"
esportsbot/cogs/TwitterCog.py:491: error: Argument "token" to "partial" of "Webhook" has incompatible type "Optional[Any]"; expected "str"
esportsbot/cogs/TwitterCog.py:558: error: Missing return statement
esportsbot/cogs/TwitterCog.py:603: error: Not all arguments converted during string formatting
esportsbot/DiscordReactableMenus/EmojiHandler.py:3: error: Library stubs not installed for "emoji" (or incompatible with Python 3.9)
esportsbot/DiscordReactableMenus/EmojiHandler.py:3: note: Hint: "python3 -m pip install types-emoji"
esportsbot/DiscordReactableMenus/EmojiHandler.py:3: note: (or run "mypy --install-types" to install all missing stub packages)
esportsbot/DiscordReactableMenus/EmojiHandler.py:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
esportsbot/DiscordReactableMenus/EmojiHandler.py:9: error: Argument 1 to "from_dict" of "PartialEmoji" has incompatible type "Dict[str, object]"; expected "_PartialEmojiDict"
esportsbot/DiscordReactableMenus/EmojiHandler.py:37: error: Argument 1 to "from_dict" of "PartialEmoji" has incompatible type "Dict[Any, Any]"; expected "_PartialEmojiDict"
esportsbot/DiscordReactableMenus/EmojiHandler.py:52: error: Argument 1 to "from_dict" of "PartialEmoji" has incompatible type "Dict[Any, Any]"; expected "_PartialEmojiDict"
esportsbot/lib/client.py:2: error: Skipping analyzing "discord.ext": found module but no type hints or library stubs
esportsbot/lib/client.py:12: error: Library stubs not installed for "toml" (or incompatible with Python 3.9)
esportsbot/lib/client.py:12: note: Hint: "python3 -m pip install types-toml"
esportsbot/lib/client.py:15: error: Cannot resolve name "StringTable" (possible cyclic definition)
esportsbot/lib/client.py:62: error: Item "None" of "Optional[Guild]" has no attribute "id"
esportsbot/lib/client.py:72: error: Unsupported operand types for + ("str" and "None")
esportsbot/lib/client.py:72: note: Right operand is of type "Union[str, Any, None]"
esportsbot/lib/client.py:72: error: Item "DMChannel" of "Union[TextChannel, DMChannel, GroupChannel]" has no attribute "name"
esportsbot/lib/client.py:85: error: Incompatible types in assignment (expression has type "None", variable has type "EsportsBot")
esportsbot/DiscordReactableMenus/ReactableMenu.py:6: error: Library stubs not installed for "emoji" (or incompatible with Python 3.9)
esportsbot/DiscordReactableMenus/ReactableMenu.py:106: error: "int" has no attribute "embeds"
esportsbot/DiscordReactableMenus/ReactableMenu.py:109: error: "int" has no attribute "embeds"
esportsbot/DiscordReactableMenus/ReactableMenu.py:112: error: Incompatible types in assignment (expression has type "Dict[Union[Emoji, str], Any]", target has type "int")
esportsbot/DiscordReactableMenus/ReactableMenu.py:151: error: Incompatible return value type (got "List[Dict[Union[Emoji, PartialEmoji, str], Any]]", expected "List[Dict[str, str]]")
esportsbot/DiscordReactableMenus/ReactableMenu.py:228: error: Attribute "message" already defined on line 18
esportsbot/lib/emotes.py:9: error: Library stubs not installed for "emoji" (or incompatible with Python 3.9)
esportsbot/lib/emotes.py:78: error: Incompatible types in assignment (expression has type "None", variable has type "Emote")
esportsbot/lib/emotes.py:141: error: Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"
esportsbot/lib/emotes.py:141: note: This violates the Liskov substitution principle
esportsbot/lib/emotes.py:141: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
esportsbot/lib/emotes.py:141: note: It is recommended for "__eq__" to work with arbitrary objects, for example:
esportsbot/lib/emotes.py:141: note:     def __eq__(self, other: object) -> bool:
esportsbot/lib/emotes.py:141: note:         if not isinstance(other, Emote):
esportsbot/lib/emotes.py:141: note:             return NotImplemented
esportsbot/lib/emotes.py:141: note:         return <logic to compare two Emote instances>
esportsbot/lib/emotes.py:198: error: Argument "unicode" to "Emote" has incompatible type "Optional[str]"; expected "str"
esportsbot/lib/emotes.py:200: error: Argument "id" to "Emote" has incompatible type "Optional[int]"; expected "int"
esportsbot/lib/discordUtil.py:33: error: Incompatible return value type (got "Tuple[None, None, None]", expected "Tuple[Message, Union[User, Member], Emote]")
esportsbot/lib/discordUtil.py:41: error: Incompatible types in assignment (expression has type "ClientUser", variable has type "Optional[User]")
esportsbot/lib/discordUtil.py:48: error: Incompatible types in assignment (expression has type "ClientUser", variable has type "Optional[User]")
esportsbot/lib/discordUtil.py:51: error: Incompatible types in assignment (expression has type "Optional[Member]", variable has type "Optional[User]")
esportsbot/lib/discordUtil.py:53: error: Incompatible return value type (got "Tuple[None, None, None]", expected "Tuple[Message, Union[User, Member], Emote]")
esportsbot/lib/discordUtil.py:60: error: Incompatible types in assignment (expression has type "Member", variable has type "Optional[User]")
esportsbot/lib/discordUtil.py:61: error: Item "VoiceChannel" of "Union[TextChannel, VoiceChannel, StoreChannel, CategoryChannel, None]" has no attribute "fetch_message"
esportsbot/lib/discordUtil.py:61: error: Item "StoreChannel" of "Union[TextChannel, VoiceChannel, StoreChannel, CategoryChannel, None]" has no attribute "fetch_message"
esportsbot/lib/discordUtil.py:61: error: Item "CategoryChannel" of "Union[TextChannel, VoiceChannel, StoreChannel, CategoryChannel, None]" has no attribute "fetch_message"
esportsbot/lib/discordUtil.py:61: error: Item "None" of "Union[TextChannel, VoiceChannel, StoreChannel, CategoryChannel, None]" has no attribute "fetch_message"
esportsbot/lib/discordUtil.py:64: error: Incompatible return value type (got "Tuple[None, None, None]", expected "Tuple[Message, Union[User, Member], Emote]")
esportsbot/lib/discordUtil.py:70: error: Incompatible return value type (got "Tuple[None, None, None]", expected "Tuple[Message, Union[User, Member], Emote]")
esportsbot/lib/discordUtil.py:72: error: Incompatible return value type (got "Tuple[Message, Optional[User], Emote]", expected "Tuple[Message, Union[User, Member], Emote]")
esportsbot/lib/discordUtil.py:85: error: Bracketed expression "[...]" is not valid as a type
esportsbot/lib/discordUtil.py:85: note: Did you mean "List[...]"?
esportsbot/DiscordReactableMenus/ExampleMenus.py:79: error: Item "None" of "Optional[Member]" has no attribute "add_roles"
esportsbot/DiscordReactableMenus/ExampleMenus.py:244: error: Item "None" of "Optional[Member]" has no attribute "guild"
esportsbot/DiscordReactableMenus/ExampleMenus.py:249: error: Item "VoiceChannel" of "Union[TextChannel, VoiceChannel, StoreChannel, CategoryChannel, None, Any]" has no attribute "fetch_message"
esportsbot/DiscordReactableMenus/ExampleMenus.py:249: error: Item "StoreChannel" of "Union[TextChannel, VoiceChannel, StoreChannel, CategoryChannel, None, Any]" has no attribute "fetch_message"
esportsbot/DiscordReactableMenus/ExampleMenus.py:249: error: Item "CategoryChannel" of "Union[TextChannel, VoiceChannel, StoreChannel, CategoryChannel, None, Any]" has no attribute "fetch_message"
esportsbot/DiscordReactableMenus/ExampleMenus.py:249: error: Item "None" of "Union[TextChannel, VoiceChannel, StoreChannel, CategoryChannel, None, Any]" has no attribute "fetch_message"
esportsbot/bot.py:6: error: Skipping analyzing "discord.ext.commands": found module but no type hints or library stubs
esportsbot/bot.py:7: error: Skipping analyzing "discord.ext.commands.context": found module but no type hints or library stubs
esportsbot/cogs/VotingCog.py:4: error: Skipping analyzing "discord.ext": found module but no type hints or library stubs
esportsbot/cogs/VotingCog.py:118: error: Argument 1 to "add_many" of "ReactableMenu" has incompatible type "Dict[str, str]"; expected "Dict[Union[Emoji, PartialEmoji, str], Any]"
esportsbot/cogs/RoleReactCog.py:5: error: Skipping analyzing "discord.ext": found module but no type hints or library stubs
esportsbot/cogs/MusicCog.py:13: error: Skipping analyzing "googleapiclient.discovery": found module but no type hints or library stubs
esportsbot/cogs/MusicCog.py:13: error: Skipping analyzing "googleapiclient": found module but no type hints or library stubs
esportsbot/cogs/MusicCog.py:14: error: Skipping analyzing "youtube_dl": found module but no type hints or library stubs
esportsbot/cogs/MusicCog.py:16: error: Skipping analyzing "discord.ext": found module but no type hints or library stubs
esportsbot/cogs/MusicCog.py:17: error: Skipping analyzing "youtubesearchpython": found module but no type hints or library stubs
esportsbot/cogs/MusicCog.py:70: error: Unexpected keyword argument "footer" for "Embed"
esportsbot/cogs/MusicCog.py:1236: error: Incompatible default for argument "song_index" (default has type "int", argument has type "str")
esportsbot/cogs/MusicCog.py:1255: error: Unsupported operand types for + ("str" and "int")
esportsbot/cogs/MusicCog.py:1308: error: Unsupported operand types for + ("str" and "int")
esportsbot/cogs/MusicCog.py:1309: error: Unsupported operand types for + ("str" and "int")
esportsbot/cogs/PingableRolesCog.py:8: error: Skipping analyzing "discord.ext": found module but no type hints or library stubs
esportsbot/cogs/PingableRolesCog.py:212: error: Need type annotation for "loaded_data" (hint: "loaded_data: Dict[<type>, <type>] = ...")
esportsbot/cogs/PingableRolesCog.py:229: error: Bracketed expression "[...]" is not valid as a type
esportsbot/cogs/PingableRolesCog.py:229: note: Did you mean "List[...]"?
esportsbot/cogs/PingableRolesCog.py:247: error: Need type annotation for "loaded_data" (hint: "loaded_data: Dict[<type>, <type>] = ...")
esportsbot/cogs/PingableRolesCog.py:264: error: Bracketed expression "[...]" is not valid as a type
esportsbot/cogs/PingableRolesCog.py:264: note: Did you mean "List[...]"?
esportsbot/cogs/PingableRolesCog.py:282: error: Need type annotation for "roles"
esportsbot/cogs/PingableRolesCog.py:286: error: Item "None" of "Optional[Any]" has no attribute "get"
esportsbot/cogs/PingableRolesCog.py:287: error: Item "None" of "Optional[Any]" has no attribute "get"
esportsbot/cogs/PingableRolesCog.py:604: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc]"
esportsbot/cogs/PingableRolesCog.py:605: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc]"
esportsbot/cogs/PingableRolesCog.py:606: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc]"
esportsbot/cogs/PingableRolesCog.py:613: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc]"
esportsbot/cogs/PingableRolesCog.py:614: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc]"
esportsbot/cogs/PingableRolesCog.py:615: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc]"
esportsbot/cogs/PingableRolesCog.py:622: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc]"
esportsbot/cogs/PingableRolesCog.py:623: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc]"
esportsbot/cogs/PingableRolesCog.py:624: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc]"
esportsbot/cogs/EventCategoriesCog.py:6: error: Skipping analyzing "discord.ext": found module but no type hints or library stubs
esportsbot/cogs/EventCategoriesCog.py:308: error: Argument "shared_role" to "EventReactMenu" has incompatible type "Optional[Role]"; expected "Role"
esportsbot/cogs/EventCategoriesCog.py:335: error: Item "None" of "Optional[Role]" has no attribute "name"
Found 125 errors in 21 files (checked 29 source files)
@Laura7089 Laura7089 added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Aug 23, 2021
@Laura7089 Laura7089 added smells Things that work but could be improved and removed bug Something isn't working enhancement New feature or request labels Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation smells Things that work but could be improved
Projects
None yet
Development

No branches or pull requests

1 participant