Deleting an Entry does not seem to remove attachments.
import pykeepass
kp = pykeepass.create_database("test")
e = kp.add_entry(kp.root_group, "title", "username", "password")
a = kp.add_binary(b"attachment data bytes string", False, False)
e.add_attachment(a, "attachment")
kp.dump_xml("before.xml")
print("before deleting entry", kp.binaries[a])
kp.delete_entry(e)
kp.dump_xml("after.xml")
print("after deleting entry", kp.binaries[a])
In secrets this can cause orphaned objects to be present in the database. https://gitlab.gnome.org/World/secrets/-/issues/574
P.S. PyKeePass.dump_xml does not seem to include binaries/attachments in it.