Commit 72d584d5 authored by Nsukami Patrick's avatar Nsukami Patrick
Browse files

[mypy]: Improve type annotation for set_limit method

if we want to use it as 2nd arg to the property function:
- set_limit method should explicitly return None
- remove useless comments
- remove now useless type:ignore comments

This fix mypy error:
Argument 2 to "property"
 has incompatible type "Callable[[rql.stmts.Union, Any], Optional[rql.stmts.Union]]"
 expected "Optional[Callable[[Any, Any], None]]"
parent 0c6dc7504ba8
......@@ -319,20 +319,15 @@ class Union(Statement, Node):
warn("limit is now a Select node attribute", DeprecationWarning, stacklevel=2)
return self.children[-1].limit
# set_limit is supposed to return None to be used with property
# but returning None breaks the tests
def set_limit(self, limit: int) -> Optional["rql.stmts.Union"]:
def set_limit(self, limit: int) -> None:
if len(self.children) == 1:
return self
return None
return None
# Argument 2 to "property" has incompatible type "Callable[[rql.stmts.Union, Any],
# Optional[rql.stmts.Union]]";
# expected "Optional[Callable[[Any, Any], None]]"
limit = property(_get_limit, set_limit) # type: ignore[arg-type]
limit = property(_get_limit, set_limit)
def root(self):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment