gleitz / howdoi

instant coding answers via the command line
http://blog.gleitzman.com/post/43330157197/howdoi-instant-coding-answers-via-the-command-line
MIT License
10.56k stars 867 forks source link

Crashes in Python 3.8 (and prior) due to usage of list[str] type annotation by terminaltables3 #498

Open zkprisma opened 3 weeks ago

zkprisma commented 3 weeks ago

What happened:

TypeError in terminaltables3\width_and_alignment.py", line 49

What you expected to happen:

to work and give output

Output with --explain

Please provide the output of running the same command with the --explain flag like so

$ howdoi YOUR_COMMAND --explain
C:\Users\zeev.PRISMA\pz\microservices\pz_integrations\zebra\test_utils>howdoi install howdoi --explain
Traceback (most recent call last):
  File "C:\Users\zeev.PRISMA\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\zeev.PRISMA\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\zeev.PRISMA\virtualenvs\pzdev\Scripts\howdoi.exe\__main__.py", line 4, in <module>
  File "c:\users\zeev.prisma\virtualenvs\pzdev\lib\site-packages\howdoi\howdoi.py", line 33, in <module>
    from keep import utils as keep_utils
  File "c:\users\zeev.prisma\virtualenvs\pzdev\lib\site-packages\keep\utils.py", line 12, in <module>
    from terminaltables3 import AsciiTable
..
  File "c:\users\zeev.prisma\virtualenvs\pzdev\lib\site-packages\terminaltables3\width_and_alignment.py", line 49, in <module>
    ) -> list[str]:
TypeError: 'type' object is not subscriptable
gleitz commented 3 weeks ago

Hmm, I wonder if this is an issue with keep upstream? https://pypi.org/project/keep/

We're currently on 2.9 but it looks like there is now 2.11. Would you try updating the keep version and seeing if you still get the error?

zkprisma commented 3 weeks ago

pip install keep==2.9 does resolve the issue

Maybe you want to apply the "We're currently on 2.9" statement in setup.py? i.e. replace 'keep' with 'keep==2.9' ?

gleitz commented 3 weeks ago

Hmm, interesting. Did you install howdoi with pip, or are you installing it from source? I was pretty sure that pip was using the correct versions since we specify it in the requirements here.

I see there is also a way to have the setup.py read from the requirements file, which might be a better option.