Settle on Best Practice for Union / Optional Type Annotations
- Ngôn ngữ chính
- Python
- Star
- 288
- Fork
- 138
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
## 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
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.