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 #102

Closed apurvakhatri closed 1 year ago

apurvakhatri commented 1 year ago

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

Describe your changes 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

ZhangZhida commented 1 year ago

Hi @apurvakhatri , I have permission issue pushing the code to your PR here, so I created a new PR https://github.com/bloomberg/attrs-strict/pull/106 and retaining your commit history.

The new PR https://github.com/bloomberg/attrs-strict/pull/106 fix the python version issue and add unit tests.