Skip to content

Magic .as_(...) operation works incorrectly with negative results #1281

Description

@JrooTJunior

Checklist

  • I am sure the error is coming from aiogram code
  • I have searched in the issue tracker for similar bug reports, including closed ones

Operating system

Any

Python version

Any

aiogram version

3.0

Expected behavior

F.text.cast(int).as_("value") should works when text is "0"

Current behavior

0 interpreted as negative result

Steps to reproduce

  1. Send 0 as a text message

Code example

from aiogram import Router, F
from aiogram.types import Message

demo_router = Router(name=__name__)


@demo_router.message(F.text.cast(int).as_("value"))
async def zero_handler(message: Message, value: int):
    await message.answer(f"Value: {value}")

Logs

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.xIssue or PR for stable 3.x versionbugSomething is wrong with the framework

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions