-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Incompatible type with non-mandatory bool
arg and kwargs
#7572
Comments
We found this in our Airflow test suite -- for us the error only started appearing with 0.730 |
I think this is a duplicate of #5382, possible solution suggested in #5382 (comment) should fix this. |
@ilevkivskyi The original problem I ran in to from python/typeshed#3270 was on import unittest
from unittest import mock
class TestCloudBuildHookWithPassedProjectId(unittest.TestCase):
@mock.patch(
'airflow.gcp.hooks.base.GoogleCloudBaseHook.project_id',
new_callable=mock.PropertyMock,
**{"return_value.classify_text.return_value": {}}
)
def test_error_operation(self, _, mock_project_id):
pass (I'm not sure if it's relevant or not but this error doesn't show up on 0.720, only on 0.730.) |
I meant solution for us, not for users. But if you want a workaround, then I think something like this should pass (didn't test however): import unittest
from unittest import mock
from typing import Any
from typing_extensions import TypedDict
DummyMock = TypedDict('DummyMock', {"return_value.classify_text.return_value": Any})
dm: DummyMock = {"return_value.classify_text.return_value": {}}
class TestCloudBuildHookWithPassedProjectId(unittest.TestCase):
@mock.patch(
'airflow.gcp.hooks.base.GoogleCloudBaseHook.project_id',
new_callable=mock.PropertyMock,
**dm
)
def test_error_operation(self, _, mock_project_id):
pass If you need this for many keys you can probably add all of them to the same |
(Originally reported as python/typeshed#3270.)
Please consider:
With mypy 0.720 (Python 3.7.3) and 0.730 (Python 3.7.4) and mypy master this reports (no flags):
The text was updated successfully, but these errors were encountered: