Allow empty and zero parts in CallbackData (#646)

* enh: allow empty parts in CallbackData

* enh: allow zero parts in CallbackData

* new: tests for CallbackData
This commit is contained in:
Ramzan Bekbulatov 2021-08-01 00:05:21 +03:00 committed by GitHub
parent f6f2972a11
commit 580fa2e499
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 4 deletions

View file

@ -33,8 +33,6 @@ class CallbackData:
raise ValueError("Prefix can't be empty")
if sep in prefix:
raise ValueError(f"Separator {sep!r} can't be used in prefix")
if not parts:
raise TypeError('Parts were not passed!')
self.prefix = prefix
self.sep = sep
@ -64,8 +62,6 @@ class CallbackData:
if value is not None and not isinstance(value, str):
value = str(value)
if not value:
raise ValueError(f"Value for part {part!r} can't be empty!'")
if self.sep in value:
raise ValueError(f"Symbol {self.sep!r} is defined as the separator and can't be used in parts' values")