Tweak schema_check to handle annotated builtin types (#145154)

As of python 3.9 annotated lists can be written as `list[T]` and `List[T]` has been deprecated.  However schema_check was converting `list[T]` to simply be `list`. This change teaches it to handle `list[T]` the same as `List[T]`.

A couple small drive-by changes I noticed as well:
- Path concatenation should use `os.path.join`, not `+`
- Spelling in error message

Pull Request resolved: https://github.com/pytorch/pytorch/pull/145154
Approved by: https://github.com/bobrenjc93
This commit is contained in:
Aaron Orenstein
2025-01-18 08:47:47 -08:00
committed by PyTorch MergeBot
parent 9e0437a04a
commit cd8d0fa20c
3 changed files with 26 additions and 26 deletions

View File

@ -80,9 +80,9 @@ if __name__ == "__main__":
print(yaml_content)
print("\nWill write the above schema to" + args.prefix + commit.yaml_path)
else:
with open(args.prefix + commit.yaml_path, "w") as f:
with open(os.path.join(args.prefix, commit.yaml_path), "w") as f:
f.write(yaml_content)
with open(args.prefix + commit.cpp_header_path, "w") as f:
with open(os.path.join(args.prefix, commit.cpp_header_path), "w") as f:
f.write(cpp_header)
with open(args.prefix + commit.thrift_schema_path, "w") as f:
with open(os.path.join(args.prefix, commit.thrift_schema_path), "w") as f:
f.write(thrift_schema)