docs: def make_final_message(version, error, codewords):
      """\
      Constructs the final message (codewords incl. error correction).
  
      ISO/IEC 18004:2015(E) -- 7.6 Constructing the final message codeword sequence (page 45)
  
      :param int version: (Micro) QR Code version constant.
      :param int error: Error level constant.
      :param codewords: An iterable sequence of codewords (ints)
      :return: Byte buffer representing the final message.
      """
      ec_infos = consts.ECC[version][error]
      last_cw_is_four = version in (consts.VERSION_M1, consts.VERSION_M3)
      data_blocks, error_blocks = make_blocks(ec_infos, codewords)
      if last_cw_is_four:
          # All codewords are 8 bit by default, M1 and M3 symbols use 4 bits
          # to represent the last last codeword
          # datablocks[0] is save since Micro QR Codes use just one datablock and
          # one error block
          data_blocks[0][-1] >>= 4
      buff = Buffer()
      append_int = partial(buff.append_bits, length=8)
      # Write codewords
      for i in range(max(info.num_data for info in ec_infos)):
          for block in data_blocks:
              if i >= len(block):
                  continue
              if last_cw_is_four and i + 1 == len(block):
                  buff.append_bits(block[i], 4)
              else:
                  append_int(block[i])
      # Write error codewords
      for i in range(max(info.num_total - info.num_data for info in ec_infos)):
          for block in error_blocks:
              if i >= len(block):
                  continue
              append_int(block[i])
      # ISO/IEC 18004:2015(E) -- 7.6 Constructing the final message codeword sequence
      # [...] In certain QR Code versions, however, where the number of modules
      # available for data and error correction codewords is not an exact multiple
      # of 8, there may be a need for 3, 4 or 7 Remainder Bits to be appended to
      # the final message bit stream in order to fill exactly the number of
      # modules in the encoding region
      remainder = 0  # Calculation: Number of Data modules - number of bits
      if version in (2, 3, 4, 5, 6):
          remainder = 7
      elif version in (14, 15, 16, 17, 18, 19, 20, 28, 29, 30, 31, 32, 33, 34):
          remainder = 3
      elif version in (21, 22, 23, 24, 25, 26, 27):
          remainder = 4
      buff.extend(b'\0' * remainder)
      return buff