Couldn’t you pack attachment and attachment_name into a tuple of two elements (str, str), then do something like this?
type AttachmentData = tuple[str, str]
# Or another TypedDict for AttachmentData
class PrivateBinAPIJSON(TypedDict):
paste: str
attachment_data: tuple[AttachmentData, ...]
It would also stop usage of the class with say 3 attachments but 5 attachment-names. Maybe even a dictionary for name to attachment would work (unless names can be repeated).
I think for this case, and probably many others, a bit of redesigning can be helpful.
I don’t think it’s fair to assume that people have the ability to redesign external JSON APIs (which seems like what’s being used here) just for the sake of simplifying typing them in Python.