Serialize reference types that denote Python-based definitions correclty. Closes 1140.

16 jobs for !907 with 1140-python-defined-sections-cannot-be-used-as-quantity-types-in-yaml-schemas in 42 minutes and 17 seconds (queued for 3 seconds)
latest merge request