-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lit] Clean up internal shell parse errors with ScriptFatal #68496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using a type annotation for the function signature instead of this comment? Then it can be checked by type checker tools as well as IDEs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. Are you thinking of something like the following?
I tried running mypy to check this, and it complained:
However, LLVM requires only python 3.6 currently.
Also, is there a way to provide names/descriptions for the tuple members? Is there a way to specify exceptions? I couldn't find a syntax for either.
Assuming the above limitations, it looks like the comment would be useful anyway. I'm not experienced with type annotations in python. Please let me know if I'm doing something wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how you do it in Python 3.6:
https://docs.python.org/3/library/typing.html#typing.NamedTuple
Dataclasses might be relevant here as well.
It was an explicit design choice to not include exceptions in type annotations: https://stackoverflow.com/a/44282299/4182606
I have experience with type annotations in Python, specifically in 3.5 and 3.6 versions, so I'll be happy to review them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand that correctly, I'd be changing the return type rather than just documenting/annotating it. Maybe the type annotation plus a comment naming the fields is enough?
Thanks for the suggestions. I pushed a commit. Let me know if you think something more would be worthwhile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you intend to add names to
typing.Tuple[str, str, int, typing.Optional[str]]
, I'm not sure it's possible in a way that won't scare type checkers away, but I'm sure it's not conventional for Python. If you want to name tuple members, you should create a type withnamedtuple()
, and return it.https://github.com/llvm/llvm-project/pull/68496/files#diff-06d85faa2a7a6970de33ccb78e3e004456eb51ab7303330ec52a5e35db92d415R53 would definitely benefit from named arguments.