enthought / enthought/traits

Use | operator for Union traits

Open
#1,430 1 comment 0 reactions 0 assignees View on GitHub
priority: low type: discussion
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

Following [PEP 604](https://www.python.org/dev/peps/pep-0604/) which allows constructs like `int | float` as a replacement for `Union[int, float]` should we allow `Int | Float` as an (optional) replacement for `Union(Int, Float)`?

The good:
- meaning is fairly clear
- alignment with Python typing

The bad:
- if you want metadata then you'd have to do something like `(Int | Float)(foo='bar')` which is not very clear compared to `Union(Int, Float, foo='bar')`

The ugly:
- `Int | Float` or `Int() | Float()`? It may have to be the latter, but presumably Python is going to grow some hook for `|` for types with this change, the same way it did for getitem.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.