mypy: function return types marked as optional
Only methods can have optional return types, but it has to be applied to function as well as method, otherwise mypy complains. I considered making a special return type for constructors/destructors, but it seemed to just make things too messy. Time will tell if this was the right decision.
This commit is contained in:
parent
36d23c37bd
commit
2eb13496fa
@ -1749,6 +1749,7 @@ class CxxParser:
|
||||
return method.has_body or method.has_trailing_return
|
||||
|
||||
else:
|
||||
assert return_type is not None
|
||||
fn = Function(
|
||||
return_type,
|
||||
pqname,
|
||||
@ -1778,8 +1779,12 @@ class CxxParser:
|
||||
if fn.template:
|
||||
raise CxxParseError("typedef function may not have a template")
|
||||
|
||||
return_type = fn.return_type
|
||||
if return_type is None:
|
||||
raise CxxParseError("typedef function must have return type")
|
||||
|
||||
fntype = FunctionType(
|
||||
fn.return_type,
|
||||
return_type,
|
||||
fn.parameters,
|
||||
fn.vararg,
|
||||
fn.has_trailing_return,
|
||||
|
@ -468,7 +468,9 @@ class Function:
|
||||
A function declaration, potentially with the function body
|
||||
"""
|
||||
|
||||
return_type: DecoratedType
|
||||
#: Only constructors and destructors don't have a return type
|
||||
return_type: typing.Optional[DecoratedType]
|
||||
|
||||
name: PQName
|
||||
parameters: typing.List[Parameter]
|
||||
|
||||
@ -510,9 +512,6 @@ class Method(Function):
|
||||
A method declaration, potentially with the method body
|
||||
"""
|
||||
|
||||
#: constructors and destructors don't have a return type
|
||||
return_type: typing.Optional[DecoratedType]
|
||||
|
||||
access: str = ""
|
||||
|
||||
const: bool = False
|
||||
|
Loading…
x
Reference in New Issue
Block a user