mypy: add None return types to functions that don't return a value

This commit is contained in:
Dustin Spicuzza
2022-01-02 21:30:41 -05:00
parent cd6d4f23f3
commit 9756025e2d
22 changed files with 190 additions and 189 deletions

View File

@@ -9,7 +9,7 @@ from .options import ParserOptions
from .simple import parse_file
def dumpmain():
def dumpmain() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("header")

View File

@@ -46,7 +46,7 @@ def nondefault_repr(data):
return _inner_repr(data)
def gentest(infile: str, name: str, outfile: str, verbose: bool):
def gentest(infile: str, name: str, outfile: str, verbose: bool) -> None:
# Goal is to allow making a unit test as easy as running this dumper
# on a file and copy/pasting this into a test
@@ -64,7 +64,7 @@ def gentest(infile: str, name: str, outfile: str, verbose: bool):
stmt = inspect.cleandoc(
f'''
def test_{name}():
def test_{name}() -> None:
content = """
{content}
"""

View File

@@ -544,7 +544,7 @@ class CxxParser:
return TemplateDecl(params)
def _parse_template(self, tok: LexToken, doxygen: typing.Optional[str]):
def _parse_template(self, tok: LexToken, doxygen: typing.Optional[str]) -> None:
template = self._parse_template_decl()
@@ -2128,7 +2128,7 @@ class CxxParser:
template: typing.Optional[TemplateDecl],
is_typedef: bool,
is_friend: bool,
):
) -> None:
tok = self._next_token_must_be("operator")
if is_typedef:

View File

@@ -57,7 +57,7 @@ class ExternBlockState(State):
super().__init__(parent)
self.linkage = linkage
def _finish(self, visitor: "CxxVisitor"):
def _finish(self, visitor: "CxxVisitor") -> None:
visitor.on_extern_block_end(self)

View File

@@ -185,7 +185,7 @@ class SimpleCxxVisitor:
namespace: NamespaceScope
block: Block
def __init__(self):
def __init__(self) -> None:
self.namespace = NamespaceScope("")
self.block = self.namespace
@@ -259,7 +259,7 @@ class SimpleCxxVisitor:
ns = UsingNamespace("::".join(namespace))
self.block.using_ns.append(ns)
def on_using_alias(self, state: State, using: UsingAlias):
def on_using_alias(self, state: State, using: UsingAlias) -> None:
self.block.using_alias.append(using)
def on_using_declaration(self, state: State, using: UsingDecl) -> None:
@@ -288,7 +288,7 @@ class SimpleCxxVisitor:
def on_class_method(self, state: ClassBlockState, method: Method) -> None:
self.block.methods.append(method)
def on_class_friend(self, state: ClassBlockState, friend: FriendDecl):
def on_class_friend(self, state: ClassBlockState, friend: FriendDecl) -> None:
self.block.friends.append(friend)
def on_class_end(self, state: ClassBlockState) -> None:

View File

@@ -119,7 +119,7 @@ class CxxVisitor(Protocol):
using namespace std;
"""
def on_using_alias(self, state: State, using: UsingAlias):
def on_using_alias(self, state: State, using: UsingAlias) -> None:
"""
.. code-block:: c++
@@ -171,7 +171,7 @@ class CxxVisitor(Protocol):
Called when a field of a class is encountered
"""
def on_class_friend(self, state: ClassBlockState, friend: FriendDecl):
def on_class_friend(self, state: ClassBlockState, friend: FriendDecl) -> None:
"""
Called when a friend declaration is encountered
"""