Skip to content

fix: main annotated as NoReturn but returns None - #108

Open
andrewwhitecdw wants to merge 2 commits into
NVIDIA:mainfrom
andrewwhitecdw:codequality/bobber-main-annotated-as-noreturn-but-returns
Open

fix: main annotated as NoReturn but returns None#108
andrewwhitecdw wants to merge 2 commits into
NVIDIA:mainfrom
andrewwhitecdw:codequality/bobber-main-annotated-as-noreturn-but-returns

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

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

Changes

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

Details

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

Contributor guidelines

Per this repo's CONTRIBUTING.md:

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

andrewwhitecdw and others added 2 commits July 30, 2026 11:58
Signed-off-by: Andrew White <andrewh@cdw.com>
Auditor: The stated issue is likely wrong: `main` appears to delegate to `execute_command`, which is already annotated `NoReturn`; if `execute_command` is correct, `main` never returns normally and `NoReturn` is the right annotation. The added test is tautological—it checks the literal source annotation via AST rather than verifying actual runtime or type-checker behavior—so it does not prove the fix and would lock in a less accurate annotation.
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