dbt-labs / hologram

A library for automatically generating Draft 7 JSON Schemas from Python dataclasses
MIT License
9 stars 13 forks source link

Python 3.9 support #34

Closed beckjake closed 3 years ago

beckjake commented 4 years ago

Python 3.9 changed the way typing.Optional is represented - in particular

This used to be how python represented a typing.Optional. An Optional is really just a Union that includes None in python 3.6-3.8:

>>> typing.Optional[int]
typing.Union[int, NoneType]

But in python 3.9, the typing.Optional is preserved when there is only None + one item:

>>> typing.Optional[int]
typing.Optional[int]

This breaks hologram (and therefore dbt) because it only checks for Union everywhere. It shouldn't be too hard to fix!