Home > Software design >  Python: TypeError: 'type' object is not subscriptable
Python: TypeError: 'type' object is not subscriptable

Time:01-13

Running into an issue with a project from here

Right off the bat when testing on Debian running python 3.7 it’s putting out errors, unfortunately I’m no coder and the devs don’t seem too responsive based on previous issues reported on their repos. I think it might be related to the float but what do I know.

def connect_tcp(host="127.0.0.1", port=8423, timeout: float = None) -> tuple[socket.socket, socket.socket]: TypeError: 'type' object is not subscriptable

Any pointers would be greatly appreciated

Not tried much as not sure what do to.

CodePudding user response:

The issue comes from tuple[socket.socket, socket.socket].

This notation using tuple directly was implemented in python 3.9, for python up to 3.8 it was done through typing.Tuple.

You can add from __future__ import annotation (see __future__) at the top of that file to turn on the postponed evaluation of annotations, which will allow you to run with any python from 3.7.

  • Related