Skip to content

fix: execute_command annotated as NoReturn but returns None - #107

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/bobber-execute-command-annotated-as-noreturn
Open

fix: execute_command annotated as NoReturn but returns None#107
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/bobber-execute-command-annotated-as-noreturn

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

This PR addresses the following issue in bobber/bobber.py: execute_command annotated as NoReturn but returns None.

Changes

  • bobber/bobber.py: execute_command annotated as NoReturn but returns None.

Details

--- a/bobber/bobber.py
+++ b/bobber/bobber.py
@@ -1,1 +1,1 @@
-def execute_command(args: Namespace, version: str) -> NoReturn:
+def execute_command(args: Namespace, version: str) -> None:

Tests

  • tests/test_bobber_annotations.py
--- /dev/null
+++ b/tests/test_bobber_annotations.py
@@ -0,0 +1,15 @@
+import ast
+import unittest
+
+
+class TestReturnAnnotations(unittest.TestCase):
+    def _get_return_annotation(self, func_name):
+        with open('bobber/bobber.py') as f:
+            tree = ast.parse(f.read())
+        for node in ast.walk(tree):
+            if isinstance(node, ast.FunctionDef) and node.name == func_name:
+                return node.returns
+        self.fail(f'{func_name} not found')
+
+    def test_execute_command_returns_none(self):
+        self.assertEqual(ast.unparse(self._get_return_annotation('execute_command')), 'None')

Contributor guidelines

Per this repo's CONTRIBUTING.md:

  • All commits are signed off (Signed-off-by trailer, DCO).

Signed-off-by: Andrew White <andrewh@cdw.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant