No real validation currently for head or tail.
The requirement for body being present currently relies on a ~hacky call to .pattern(), ultimately hitting this error.
Far better to just validate all three more consistently. An attrs validator won't work, because they could be instances of Parser, and that will be challenging to put into the main class body. Probably better to use instanceof(..., self.__class__) inside __attrs_post_init__.
head and tail could be None, str, Parser, or Iterable(? Collection? Sequence? Also, how to ensure str contents? Don't bother checking contents?); body is the same, save None is not allowed.
No real validation currently for head or tail.
The requirement for body being present currently relies on a ~hacky call to
.pattern(), ultimately hitting this error.Far better to just validate all three more consistently. An attrs
validatorwon't work, because they could be instances ofParser, and that will be challenging to put into the main class body. Probably better to useinstanceof(..., self.__class__)inside__attrs_post_init__.head and tail could be
None,str,Parser, orIterable(?Collection?Sequence? Also, how to ensurestrcontents? Don't bother checking contents?); body is the same, saveNoneis not allowed.