The method list.sort() is sorting the list in place, and as all mutating methods it returns None. Use the built-in function sorted() to return a new sorted list.
result = sorted((trans for trans in my_list if trans.type in types),
key=lambda x: x.code)
Instead of lambda x: x.code, you could also use the slightly faster operator.attrgetter("code").