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

On Start: TypeError: 'type' object is not subscriptable #3

Closed
Sack148 opened this issue Dec 2, 2021 · 2 comments
Closed

On Start: TypeError: 'type' object is not subscriptable #3

Sack148 opened this issue Dec 2, 2021 · 2 comments

Comments

@Sack148
Copy link

Sack148 commented Dec 2, 2021

Hi,
thank you for this work! It looks exactly like what i need.
Unfortunately I running into an issue trying to run it. It happens after the bot connected to the database.

~/VoteBot % python3 votebot.py                                                                                             
PG Ran ./db/build.sql                                                                                                                     
Traceback (most recent call last):                                                                                                        
  File "votebot.py", line 10, in <module>                                                                                                 
    from voting import voteDB                                                                                                             
  File "/home/discord/VoteBot/voting/voteDB.py", line 21, in <module>                                                                     
    def addVote(creator: discord.User, question: str, options: list[str], limit: int, guild: discord.Guild, channel: discord.TextChannel, 
stage: int = 0, type: int = 1, num_win: int = 1, title_pre: str = "Poll") -> tuple[int, str]:                                             
TypeError: 'type' object is not subscriptable                                                                                             

I am running Python 3.8.10. Is there any specific versino required? Or maybe special setting or something that i need to consider?

Thank you!

@ericthelemur
Copy link
Owner

In Python 3.8, to specify a list element type you needed to (import and) use typing.List, but in 3.9 this functionality was merged into the basic list.

There are 3 solutions:

  1. upgrade to Python 3.9
  2. replace any instance of list, dict, tuple, etc. in type signatures with List, Dict, Tuple (needs to be imported from typing)
  3. Remove the brackets and contents from these types, or the types entirely. They are only useful for development.

@Sack148
Copy link
Author

Sack148 commented Dec 2, 2021

Awesome, thank you!
I've upgraded to 3.9 and the bot starts now. Maybe you could add that to the readme? Maybe together with the information that + is the default prefix and not ! as one could think based on your screenshot.

Thank you very much!

@Sack148 Sack148 closed this as completed Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants