ahrefs / atd

Static types for JSON APIs
Other
309 stars 52 forks source link

atdpy treats option as nullable #332

Closed mjambon closed 1 year ago

mjambon commented 1 year ago

atdpy treats the option type as nullable but it should not.

The convention used by ATD is to use "None" or ["Some", 42] to represent int option values in JSON. Python code generated by atdpy instead expects null or 42 as if the type was int nullable rather than int option.

I don't think we need to support the option type at all for Python since Python doesn't have a standard option type. The Optional type known by mypy is in fact equivalent to ATD's nullable, not option.

Instead of emitting an error, we could create an option type for Python but it would probably be awkward. This can be done later if there's some demand for it (I doubt it will be the case).