Remember to set the link type as tc.
Specify it on your script just like this:
net = Mininet(topo=topo, link=TCLink)
Remember to import the TCLink as well on your python script
from mininet.link import TCLink
Instead, if you want to call mininet from the command prompt, set the --link parameter as follows
sudo mn --custom custom.py --topo customtopo --link tc