mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Add parsing logic for Tuple[()]
annotation (#58340)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/58340 Test Plan: Imported from OSS Reviewed By: jamesr66a Differential Revision: D28459502 Pulled By: ansley fbshipit-source-id: 4bb188448d66269b42b068858b895debac86e9ee
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b9d1ad9c78
commit
5268b5a29a
@ -61,6 +61,11 @@ def createResolutionCallbackFromEnv(lookup_base):
|
||||
while i < len(expr) and expr[i] not in (',', '[', ']'):
|
||||
i += 1
|
||||
|
||||
# Special case logic for the empty Tuple as a subscript (used
|
||||
# in the type annotation `Tuple[()]`)
|
||||
if expr[:i] == '()':
|
||||
return (), i
|
||||
|
||||
base = lookupInModule(expr[:i].strip(), module)
|
||||
assert base is not None, f"Unresolvable type {expr[:i]}"
|
||||
if i == len(expr) or expr[i] != '[':
|
||||
|
Reference in New Issue
Block a user