I am trying to enable in my linter the style-error (if this is the most suitable name) that should arise when a function has a type hint but no return statement. For instance:
def do_stuff() -> int:
a = 2
# this function expect at the very least something to be returned
# but no return statement is provided
I have looked at pylint, mypy and flake8 documentation but they seem to not support such error.
Also, is there a linter capable of arising a type-error, that is, the function is supposed to return an int
but is actually returning a str
. For instance:
def do_stuff() -> int:
a = 2
return 'abc'
# this function expect a int value to be returned
# but str value is returned instead
I am using VSCode. I know that this is possible in PyCharm