[libcxx-commits] [libcxx] [lit] Clean up internal shell parse errors with ScriptFatal (PR #68496)

Vlad Serebrennikov via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 9 21:19:09 PDT 2023


================
@@ -1009,7 +1020,8 @@ def formatOutput(title, data, limit=None):
     return out
 
 
-# Normally returns out, err, exitCode, timeoutInfo.
+# Always either returns the tuple (out, err, exitCode, timeoutInfo) or raises a
----------------
Endilll wrote:

That's how you do it in Python 3.6:
```python
def executeScriptInternal(
    test, litConfig, tmpBase, commands, cwd, debug=True
) -> typing.Optional[typing.Tuple[str, str, int, str]]:
```

> Also, is there a way to provide names/descriptions for the tuple members?

https://docs.python.org/3/library/typing.html#typing.NamedTuple
[Dataclasses](https://docs.python.org/3/library/dataclasses.html) might be relevant here as well.

> Is there a way to specify exceptions?

It was an explicit design choice to not include exceptions in type annotations: https://stackoverflow.com/a/44282299/4182606

> I'm not experienced with type annotations in python. Please let me know if I'm doing something wrong.

I have experience with type annotations in Python, specifically in 3.5 and 3.6 versions, so I'll be happy to review them.

https://github.com/llvm/llvm-project/pull/68496


More information about the libcxx-commits mailing list