Skip to content

fix: save_config annotated as NoReturn but returns None - #106

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/bobber-save-config-annotated-as-noreturn-but
Open

fix: save_config annotated as NoReturn but returns None#106
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/bobber-save-config-annotated-as-noreturn-but

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

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

Changes

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

Details

--- a/bobber/bobber.py
+++ b/bobber/bobber.py
@@ -1,1 +1,1 @@
-def save_config(args: Namespace) -> NoReturn:
+def save_config(args: Namespace) -> 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_save_config_returns_none(self):
+        self.assertEqual(ast.unparse(self._get_return_annotation('save_config')), '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