Settle on Best Practice for Union / Optional Type Annotations
- Lenguaje dominante
- Python
- Estrellas
- 288
- Forks
- 138
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
## Problem
[PEP 604](https://peps.python.org/pep-0604/) allows the pipe symbol (`|`) to annotate unions of types. In particular:
`X | Y` $\equiv$ `Union[X,Y]`
and
`X | None` $\equiv$ `Optional[X]`
However, type forwarding does not work with this new capability. I.e. `"Xtype" | Y` doesn't work (though `"Xtype | Y"` does actually work).
Currently our repo is inconsistent when it comes to union types.
## Solution
We should settle on a best practice for such annotations, change all usages to adhere to the best practice, and add it to our [style guide](https://github.com/algorand/pyteal/blob/master/CONTRIBUTING.md#code-guidelines).
I propose that we disallow `|` because of its incompatibility with forwarded types. But I'm open to discussion and don't have a strong opinion, except that we should have _some_ convention.
## Dependencies
None
## Urgency
Very low
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.