Skip to content

Commit

Permalink
Clean up some mypy errors by adding real return statements
Browse files Browse the repository at this point in the history
  • Loading branch information
freider committed Jan 26, 2024
1 parent 4c6b7b7 commit ff56a4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
__pycache__
venv
venv*
.venv
*.egg-info
build
dist
*.iml
18 changes: 9 additions & 9 deletions test/type_stub_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down Expand Up @@ -167,7 +167,7 @@ def wrapper(extra_arg: int, *args, **kwargs):

class Base:
def base_method(self) -> str:
...
return ""


Base.__module__ = "basemod"
Expand All @@ -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():
Expand All @@ -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
Expand Down Expand Up @@ -228,7 +228,7 @@ def test_forward_ref():

class SelfRefFoo:
def foo(self) -> "SelfRefFoo":
...
return self


def test_self_ref():
Expand All @@ -241,7 +241,7 @@ def test_self_ref():
class _Foo:
@staticmethod
async def clone(foo: "_Foo") -> "_Foo":
...
return foo


synchronizer = synchronicity.Synchronizer()
Expand All @@ -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)
Expand Down Expand Up @@ -372,15 +372,15 @@ 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


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!
Expand Down

0 comments on commit ff56a4a

Please sign in to comment.