Stabilization release of aiogram-forms
Today there is a release 1.1.0 for aiogram-forms, which can be absolutely called stabilization, because there are small features in it and for the most I aimed to extend tests, coverage and type hints.
The first changes were in the git at the beginning of February, but — as expected — a little kick was needed to find time and motivation to finish the version. This time, several mentions of the library in letters and even questions became such a kick.
Taking this opportunity, I want to remind you that there is documentation (https://aiogram-forms.13g10n.com/en), which, of course, a little behind the development, but in general it gives an idea of how to work with forms.
If we omit the stabilization moments and changes, then in the new version I can note the appeared ChoiceField and ChoiceValidator. They make it easier to add fields that have a limited list to choose from, and complete the transfer of functionality from version 0.3.0.
A good example is the language choice for user interaction. We pass to choices a construction containing label and value for each element:
@dispatcher.register('settings')
class SettingsForm(Form):
...
language = fields.ChoiceField('Language', choices=(
('English', 'en'),
('Russian', 'ru')
))
In this form, the user will see a response keyboard with English and Russian buttons, but the form data will be written en or ru respectively.
Well, no less important change as for me was the ability to call the get_data method of the manager with form ID as a param:
@router.message(Command(commands=['settings']))
async def show_settings(message: types.Message, forms: FormsManager):
settings: dict = await forms.get_data('settings')
...
I think this will finally allow you to separate the forms and avoid circular import errors when using in callbacks (more obviously this problem occurs in the menus, but this will remain on my conscience until the next release).