Skip to content

Commit 95417b2

Browse files
Fix name analysis
1 parent e3e2074 commit 95417b2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

record_api/type_analysis.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ class NamedOutput(BaseModel):
373373
def from_input(cls, input: NamedInput) -> typing.Optional[NamedOutput]:
374374
if isinstance(input, BuiltinNamedInput):
375375
return cls(name=input.__root__)
376-
if "<" in input.name:
376+
if not input.name.isidentifier():
377377
return None
378378
return cls(name=input.name, module=input.module)
379379

@@ -382,9 +382,12 @@ def annotation(self) -> typing.Union[cst.Name, cst.Attribute]:
382382
first_name, *rest = (
383383
self.module.split(".") + [self.name] if self.module else [self.name]
384384
)
385-
expr: typing.Union[cst.Name, cst.Attribute] = cst.Name(first_name)
386-
for name in rest:
387-
expr = cst.Attribute(expr, cst.Name(name))
385+
try:
386+
expr: typing.Union[cst.Name, cst.Attribute] = cst.Name(first_name)
387+
for name in rest:
388+
expr = cst.Attribute(expr, cst.Name(name))
389+
except cst._nodes.base.CSTValidationError:
390+
return cst.Name("Unknown")
388391
return expr
389392

390393

0 commit comments

Comments
 (0)