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

Taskiq Mypy validation error #192

Open
RoyalGoose opened this issue Oct 2, 2023 · 1 comment
Open

Taskiq Mypy validation error #192

RoyalGoose opened this issue Oct 2, 2023 · 1 comment

Comments

@RoyalGoose
Copy link

RoyalGoose commented Oct 2, 2023

After initializing blank project with Taskiq Mypy gives an validation error

Format with Black........................................................Passed
isort....................................................................Passed
Check with Flake8........................................................Passed
Validate types with MyPy.................................................Failed
- hook id: mypy
- exit code: 1
project_name\tkq.py:9: error: Incompatible types in assignment (expression has
type "InMemoryBroker", variable has type "ZeroMQBroker")  [assignment]
        broker = InMemoryBroker()
                 ^~~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 44 source files)

Initial project_name/tkq.py

import taskiq_fastapi
from taskiq import InMemoryBroker, ZeroMQBroker

from project_name.settings import settings

broker = ZeroMQBroker()

if settings.environment.lower() == "pytest":
    broker = InMemoryBroker()

taskiq_fastapi.init(
    broker,
    "project_name.web.application:get_app",
)
@RoyalGoose RoyalGoose changed the title Taskiq Mypy error Taskiq Mypy validation error Oct 2, 2023
@s3rius
Copy link
Owner

s3rius commented Oct 2, 2023

Guess we need explicitly set type broker: AsyncBroker = ... at the beginning.

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

2 participants