From ff56a4ac328a9ecfe987099bfe00055f0ce2fafa Mon Sep 17 00:00:00 2001 From: Elias Freider <elias@modal.com> Date: Fri, 26 Jan 2024 09:20:57 +0100 Subject: [PATCH] Clean up some mypy errors by adding real return statements --- .gitignore | 6 +++++- test/type_stub_test.py | 18 +++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 90e373e..121a5e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ __pycache__ -venv +venv* +.venv *.egg-info +build +dist +*.iml diff --git a/test/type_stub_test.py b/test/type_stub_test.py index de26b8e..3a840c1 100644 --- a/test/type_stub_test.py +++ b/test/type_stub_test.py @@ -18,7 +18,7 @@ def arg_no_anno(arg1): def scalar_args(arg1: str, arg2: int) -> float: - ... + return 0 def generic_other_module_arg(arg: typing.List[some_mod.Foo]): @@ -167,7 +167,7 @@ def wrapper(extra_arg: int, *args, **kwargs): class Base: def base_method(self) -> str: - ... + return "" Base.__module__ = "basemod" @@ -176,7 +176,7 @@ def base_method(self) -> str: class Based(Base): def sub(self) -> float: - ... + return 0 def test_base_class_included_and_imported(): @@ -191,7 +191,7 @@ def test_typevar(): T.__module__ = "source_mod" def foo(arg: T) -> T: - ... + return arg src = _function_source(foo) assert "import source_mod" in src @@ -228,7 +228,7 @@ def test_forward_ref(): class SelfRefFoo: def foo(self) -> "SelfRefFoo": - ... + return self def test_self_ref(): @@ -241,7 +241,7 @@ def test_self_ref(): class _Foo: @staticmethod async def clone(foo: "_Foo") -> "_Foo": - ... + return foo synchronizer = synchronicity.Synchronizer() @@ -250,7 +250,7 @@ async def clone(foo: "_Foo") -> "_Foo": def test_synchronicity_type_translation(): async def _get_foo(foo: _Foo) -> _Foo: - ... + return foo get_foo = synchronizer.create_blocking(_get_foo, "get_foo", __name__) src = _function_source(get_foo) @@ -372,7 +372,7 @@ def test_translated_bound_type_vars(): def test_ellipsis(): def foo() -> typing.Callable[..., typing.Any]: - ... + return lambda x: 0 src = _function_source(foo) assert "-> typing.Callable[..., typing.Any]" in src @@ -380,7 +380,7 @@ def foo() -> typing.Callable[..., typing.Any]: def test_typing_literal(): def foo() -> typing.Literal["three", "str"]: - ... + return "str" src = _function_source(foo) assert "-> typing.Literal['three', 'str']" in src # "str" should not be eval:ed in a Literal!