code: def build_messages_modules(messages):
      
      data = collections.defaultdict(list)
      for line in messages:
          module_name = line.get('module')
          module_path = line.get('path')
          module_info = ModuleInfo(
              module_name,
              module_path,
          )
          data[module_info].append(line)
  
      for module, module_messages in data.items():
          yield (
              module,
              sorted(module_messages, key=lambda x: x.get('line')))
docs: Build and yield sorted list of messages per module.
  
      :param list messages: List of dict of messages
      :return: Tuple of 2 values: first is the module info, second is the list
               of messages sorted by line number