Stricter validation of type hints

I'm wondering if there's a way to validate type hints more strictly. For instance I had a bug in the following function, it returns None in one of the branches. This should be an error because of type hint, but PyCharm doesn't detect it

def ossystem(cmd, shell=True) -> str:
"""Like os.system, but returns output of command as string."""
p = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
(stdout, stderr) = p.communicate()
if stdout:
stdout.decode('ascii')
else:
return ''

Please sign in to leave a comment.