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

Patch methods should return AsyncMock if the target is an async method #254

Closed
GDYendell opened this issue Aug 23, 2021 · 3 comments
Closed

Comments

@GDYendell
Copy link

This would match the behaviour of the equivalent methods in mock

Currently, I can pass new_callable=AsyncMock to make it work, but then mypy type checking fails because the type hints state that the methods return MagicMock. The return type is a union in the mock stubs.

@nicoddemus
Copy link
Member

Hi @GDYendell, thanks for bringing this to attention.

@nicoddemus
Copy link
Member

Hi @GDYendell,

There's a PR for this in #364, but I wonder if you could post an example of a mypy failure? See my comments in #364 (comment).

@GDYendell
Copy link
Author

GDYendell commented Jun 9, 2023

Hi @nicoddemus

This was a while ago now so I am doing some digging trying to remember. There is a chain of issues that leads to testing-cabal/mock#500 where I included a mypy error.

The repo this was happening is https://github.com/dls-controls/odinprocservcontrol. I have created a mypy branch from an old commit to recreate the problem here. It works on master with the updated types-mock. If it is useful to recreate the problem locally, checkout the mypy branch and do a pipenv install --dev --ignore-pipfile and pipenv run mypy tests.

I have briefly looked through #364, but don't immediately understand the detail of the change - is this useful information? Let me know if there is anything else I can do to help.

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

No branches or pull requests

2 participants