import re from typing import List from million.model.message import Message def retain_counts(messages : List[Message])-> List[Message]: """ Retain only the messages that have a content and a sender_name """ return [ m for m in messages if m.content and m.sender_name and re.search('(\d{2,}|^\d$)', m.content) ]