# Buggy code
def deserialize(self, data):
    """
    Given a dictionary of values, load up the field attributes for
    this object. As with serialize(), if there are any non-field
    attribute data members, this method will need to be overridden
    and extended.
    """

    if not isinstance(data, dict):
        raise AnsibleAssertionError(
            "data (%s) should be a dict but is a %s" % (data, type(data))
        )

    for name, attribute in iteritems(self._valid_attrs):
        if name in data:
            setattr(self, name, data[name])
        else:
            setattr(self, name, attribute.default)

    # restore the UUID field
    setattr(self, "_uuid", data.get("uuid"))
    self._finalized = data.get("finalized", False)
    self._squashed = data.get("squashed", False)


# Traceback (TypeError)
[echampetier@echampetier ansiblebug]$ ansible-playbook -i inventory-test playbook-test.yml -vvvv
ansible-playbook 2.7.1
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/echampetier/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.7/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 3.7.1 (default, Nov  5 2018, 14:07:04) [GCC 8.2.1 20181011 (Red Hat 8.2.1-4)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
/home/echampetier/ansiblebug/inventory-test did not meet host_list requirements, check plugin documentation if this is unexpected
/home/echampetier/ansiblebug/inventory-test did not meet script requirements, check plugin documentation if this is unexpected
Parsed /home/echampetier/ansiblebug/inventory-test inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3.7/site-packages/ansible/plugins/callback/default.py

PLAYBOOK: playbook-test.yml ***************************************************************************************************************************************************************************************
1 plays in playbook-test.yml
ERROR! Unexpected Exception, this is probably a bug: object of type 'type' has no len()
the full traceback was:

Traceback (most recent call last):
File "/usr/bin/ansible-playbook", line 118, in <module>
exit_code = cli.run()
File "/usr/lib/python3.7/site-packages/ansible/cli/playbook.py", line 122, in run
results = pbex.run()
File "/usr/lib/python3.7/site-packages/ansible/executor/playbook_executor.py", line 148, in run
batches = self._get_serialized_batches(play)
File "/usr/lib/python3.7/site-packages/ansible/executor/playbook_executor.py", line 243, in _get_serialized_batches
if len(serial_batch_list) == 0:
TypeError: object of type 'type' has no len()

# Fixed code
def deserialize(self, data):
    """
    Given a dictionary of values, load up the field attributes for
    this object. As with serialize(), if there are any non-field
    attribute data members, this method will need to be overridden
    and extended.
    """

    if not isinstance(data, dict):
        raise AnsibleAssertionError(
            "data (%s) should be a dict but is a %s" % (data, type(data))
        )

    for name, attribute in iteritems(self._valid_attrs):
        if name in data:
            setattr(self, name, data[name])
        else:
            if callable(attribute.default):
                setattr(self, name, attribute.default())
            else:
                setattr(self, name, attribute.default)

    # restore the UUID field
    setattr(self, "_uuid", data.get("uuid"))
    self._finalized = data.get("finalized", False)
    self._squashed = data.get("squashed", False)