bloomberg / attrs-strict

Provides runtime validation of attributes specified in Python 'attr'-based data classes.
Apache License 2.0
52 stars 19 forks source link

Support added for Python3.10's Union Pipe operator #106

Closed ZhangZhida closed 1 year ago

ZhangZhida commented 1 year ago

Issue number of the reported bug or feature request: #80

Describe your changes This PR is based off the original PR https://github.com/bloomberg/attrs-strict/pull/102 because I have permission problem updating that PR.

In order to resolve the issue - Support of pipe symbol for Union operation. Python3.10 uses base type as types.UnionTypes. So therefore added a case for that (If the base type is types.UnionTypes then perform validation). Hence supporting Union as X | Y.

Testing performed Testing performed on Mac OS 13.3.1 and Python 3.10.7

Additional context Add any other context about your contribution here.