Recently I was type annotating something. It turns out I was list[MyClass]
as my type annotation because I wanted a Sequence
that I could call .append()
on. But at first I wasn’t sure if Sequence
would work. By setting it as Sequence
first, then trying to call .append()
my type checker (pycharm’s inspections) told me that Sequence
doesn’t support .append()
.
This is my usual workflow for figuring out if a certain type supports some method or attribute. But sometimes this is annoying and I wish there were a more direct way to get the answer. Is there a way to figure out ahead of time what methods a certain type supports? Or at least specifically for the Sequence
type?
My apologies if some of my terminology is incorrect. Technical corrections would be appreciated.