Skip to content

Commit

Permalink
Code review feedback and rebase fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjprescott committed Apr 11, 2022
1 parent a607642 commit edc7788
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def test_overloads(self):
assert node1.name == "double"
self._check_arg_nodes(node1.args, [
("self", None, None),
("input", "Optional[int]", "1"),
("input", "int", "1"),
("*", None, None),
("test", "Optional[bool]", "False"),
("test", "bool", "False"),
("**kwargs", None, None)
])
assert node1.return_type == "int"
Expand All @@ -122,9 +122,9 @@ def test_overloads(self):
assert node2.name == "double"
self._check_arg_nodes(node2.args, [
("self", None, None),
("input", "Optional[Sequence[int]]", "[1]"),
("input", "Sequence[int]", "[1]"),
("*", None, None),
("test", "Optional[bool]", "False"),
("test", "bool", "False"),
("**kwargs", None, None)
])
assert node2.return_type == "list[int]"
Expand All @@ -138,7 +138,7 @@ def test_overloads(self):
# don't appear in the actual APIView.
("input", "int | collections.abc.Sequence[int]", None),
("*", None, None),
("test", "Optional[bool]", "False"),
("test", "bool", "False"),
("**kwargs", None, None)
])
assert node3.return_type == "int | list[int]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ def test_complex_typehints(self):


def test_non_typehint_with_string_defaults(self):
func_node = FunctionNode("test", None, TypeHintingClient.some_method_non_optional, "test")
func_node = FunctionNode("test", None, obj=TypeHintingClient.some_method_non_optional)
arg1 = func_node.args["docstring_type"]
assert arg1.argtype == "str"
assert arg1.default == "string"
arg2 = func_node.args["typehint_type"]
assert arg2.argtype == "str"
assert arg2.default == "string"

func_node = FunctionNode("test", None, TypeHintingClient.some_method_with_optionals, "test")
func_node = FunctionNode("test", None, obj=TypeHintingClient.some_method_with_optionals)
arg1 = func_node.args["labeled_optional"]
assert arg1.argtype == "Optional[str]"
assert arg1.default == "string"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def double(self, input: int = 1, *, test: bool = False, **kwargs) -> int:
def double(self, input: Sequence[int] = [1], *, test: bool = False, **kwargs) -> list[int]:
...

async def double(self, input: int | Sequence[int], *, test: bool = False, **kwargs) -> int | list[int]:
def double(self, input: int | Sequence[int], *, test: bool = False, **kwargs) -> int | list[int]:
if isinstance(input, Sequence):
return [i * 2 for i in input]
return input * 2
Expand Down

0 comments on commit edc7788

Please sign in to comment.