Added model validation to remove UNSET before field validation (#1233)

* Add model validation to remove UNSET before field validation

Updated aiogram/types/base.py to include a model validator which removes any 'UNSET' before field validation. This change was necessary to correctly handle `parse_mode` where 'UNSET' is used as a sentinel value. Without the removal of 'UNSET', it would create issues when passed to model initialization from `Bot.method_name`. 'UNSET' was also added to typing. Tiny documentation fix was made.

* Added changelog
This commit is contained in:
Alex Root Junior 2023-07-30 00:01:23 +03:00 committed by GitHub
parent 42570fb747
commit 98780dfb49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

4
CHANGES/1233.bugfix.rst Normal file
View file

@ -0,0 +1,4 @@
Added model validation to remove UNSET before field validation.
This change was necessary to correctly handle parse_mode where 'UNSET' is used as a sentinel value.
Without the removal of 'UNSET', it would create issues when passed to model initialization from Bot.method_name.
'UNSET' was also added to typing.