<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def append_payload(self, payload: Payload) -> Payload: """Adds a new body part to multipart writer."""

        # compression
        encoding = payload.headers.get(CONTENT_ENCODING, '').lower()  # type: Optional[str]  # noqa
        if encoding and encoding not in ('deflate', 'gzip', 'identity'):
            raise RuntimeError('unknown content encoding: {}'.format(encoding))
        if encoding == 'identity':
            encoding = None

        # te encoding
        te_encoding = payload.headers.get(
            CONTENT_TRANSFER_ENCODING, '').lower()  # type: Optional[str]  # noqa
        if te_encoding not in ('', 'base64', 'quoted-printable', 'binary'):
            raise RuntimeError('unknown content transfer encoding: {}'
                               ''.format(te_encoding))
        if te_encoding == 'binary':
            te_encoding = None

        # size
        size = payload.size
        if size is not None and not (encoding or te_encoding):
            payload.headers[CONTENT_LENGTH] = str(size)

        self._parts.append((payload, encoding, te_encoding))  # type: ignore
        return payload