I noticed that using tk.abstract_paths_from_template with optional fields, paths that do not contain the optional fields are not returned. I guess this is because one glob pattern is used for all. Trying to understand the code for this.
Example:
Digging into this more. Template.parent for a path is os.path.dirname(template.definition)
However template.definition has no knowledge of optional fields - they are shown as normal fields. There is template._repr_def which contains the original definition, and it works with os.path.dirname! So I will fork some of the functions for the time being.
I will put together a PR on GitHub when I have a better understanding of the issue, comments especially from SG peeps welcome.
It happens right here, when we use template.parent: