Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'bool' object has no attribute 'lower' #386

Open
ZhymabekRoman opened this issue Nov 29, 2024 · 0 comments
Open

AttributeError: 'bool' object has no attribute 'lower' #386

ZhymabekRoman opened this issue Nov 29, 2024 · 0 comments

Comments

@ZhymabekRoman
Copy link

Hello @s3rius! Thank you for creating taskiq.

I encountered an exception (something like AttributeError: 'bool' object has no attribute 'lower') with taskiq when attempting to use my custom SimpleRetryMiddleware. The problem occurred with the following code:

@taskiq_broker.task(retry_on_error=True)
async def _process_not_reached_deal(deal_details: BitrixDealResultData) -> Optional[bool]:

Unfortunately, I don't have the full traceback of the exception to provide for troubleshooting.

I've implemented a fix, and the code is now working correctly:

_LABEL_PARSERS: Dict[LabelType, Callable[[str], Any]] = {
    LabelType.INT: int,
    LabelType.STR: str,
    LabelType.FLOAT: float,
    LabelType.BOOL: lambda x: str(x).lower() == "true",
    LabelType.BYTES: base64.b64decode,
    LabelType.ANY: lambda x: x,
}

However, I'm not entirely sure if the boolean value conversion logic (lambda x: str(x).lower() == "true") is the most appropriate approach. I'd appreciate your thoughts on this implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant