driazati commented on code in PR #10906:
URL: https://github.com/apache/tvm/pull/10906#discussion_r843120750


##########
tests/scripts/ci.py:
##########
@@ -434,6 +436,26 @@ def cli_name(s: str) -> str:
     return s.replace("_", "-")
 
 
+def typing_get_origin(annotation):
+    if sys.version_info >= (3, 8):
+        return typing.get_origin(annotation)
+    else:
+        return annotation.__origin__

Review Comment:
   Thanks for the fix! Python's treatment of `Optional` is pretty annoying and 
has changed at some point between 3.7 and 3.10 (moved from an alias to `Union` 
to its own thing), I noticed on 3.7 this fails though:
   
   ```
   Traceback (most recent call last):
     File "tests/scripts/ci.py", line 681, in <module>
       main()
     File "tests/scripts/ci.py", line 657, in main
       add_subparser(func, subparsers)
     File "tests/scripts/ci.py", line 506, in add_subparser
       is_optional = is_optional_type(value.annotation)
     File "tests/scripts/ci.py", line 456, in is_optional_type
       return (typing_get_origin(annotation) == typing.Union) and (
     File "tests/scripts/ci.py", line 445, in typing_get_origin
       return annotation.__origin__
   AttributeError: type object 'bool' has no attribute '__origin__'
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to