| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
I experimented with an alternative diff: diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index d9e893f1f1..c8ab574e33 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -3046,7 +3046,7 @@ def pre_render(self) -> None:
"""
pass
- def parse_arg(self, argname: str, displayname: str):
+ def parse_arg(self, argname: str, displayname: str) -> str:
if self.format_unit == 'O&':
return """
if (!{converter}({argname}, &{paramname})) {{{{
@@ -3081,7 +3081,7 @@ def parse_arg(self, argname: str, displayname: str):
return """
{paramname} = {cast}{argname};
""".format(argname=argname, paramname=self.parser_name, cast=cast)
- return None
+ raise AssertionError(f"Unknown format unit {self.format_unit!r}")
def set_template_dict(self, template_dict: TemplateDict) -> None:
passHowever, mypy pointed out that there are lots of places in clinic.py that explicitly check to see whether the result of the parse_arg() method call is None or not, and that these would all become redundant if parse_arg() always returned a str: Tools\clinic\clinic.py:1020: error: Statement is unreachable [unreachable]
parsearg = """
^
Tools\clinic\clinic.py:1100: error: Statement is unreachable [unreachable]
parser_code = None
^~~~~~~~~~~~~~~~~~
Tools\clinic\clinic.py:1115: error: Statement is unreachable [unreachable]
if not new_or_init:
^
Tools\clinic\clinic.py:1193: error: Statement is unreachable [unreachable]
parser_code = None
^~~~~~~~~~~~~~~~~~
Tools\clinic\clinic.py:1247: error: Statement is unreachable [unreachable]
declarations = declare_parser(f, hasformat=True)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It also causes some runtime tests to fail, as well. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
CConverter.parse_arg() returns str | None, and all subclasses of CConverter return super().parse_arg() in at least one branch. As such, all subclasses must also return str | None.