-
Notifications
You must be signed in to change notification settings - Fork 45
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
Python fixes for running on multiple platforms and outside of docker #103
Conversation
3891c1c
to
a60258d
Compare
@ZedThree Could you have a look? |
@bwrsandman Apologies, I missed this at the time! Will take a look this week. |
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.
LGTM! Please could you just update a couple of type hints?
def load_review() -> Optional[PRReview]: | ||
"""Load review output from the standard REVIEW_FILE path. | ||
This file contains | ||
def load_review(review_file) -> Optional[PRReview]: |
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.
Please could you add a type hint for the argument? I know we're not terribly consistent, but it would be nice to add them for new things
return payload or None | ||
|
||
|
||
def load_and_merge_reviews(review_files) -> Optional[PRReview]: |
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.
And a type hint here too please
def __eq__(self, other): | ||
return type(other) is Comment and self.data == other.data | ||
|
||
comments = OrderedSet() |
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.
What does OrderedSet
give us over- plain set
? Why do we need the comments to be ordered?
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.
When merging the comments, I thought it would be more deterministic if the order wasn't changed but you're right that it's not needed. Shall I remove it?
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 a good point. Maybe could just replace it with a set
and then do sorted(list(comments))
?
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.
What will it sort on?
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.
Oh of course, it uses insertion order, like OrderedDict
. On balance though, I think I would still prefer not to use a whole extra dependency just for this.
I think clang-tidy sorts them by filename then line number? I'm not sure beyond that.
Use list of args when calling subprocess Use Backslashes in line ranges Use posix slashes when looking up files from PR changeset
This fixes getting the version on windows because the forward slashes are not properly interpreted in `subprocess.run` in shell mode.
d248057
to
e2610c9
Compare
LGTM, thanks @bwrsandman ! |
This PR is part of an attempt to run clang-tidy-review outside of docker.
The reason why we would want to do this is better control over github runner setup (packages, commands, environment).
Additionally, it grants the ability to run on non-linux platforms which allows the runner to analyze platform specific files/headers/libraries not available on linux in a docker.
The removal of docker also can speed up the analysis of clang-tidy. In my tests, docker runs for 4 minutes while linux without docker runs for 2, though macos and windows take upwards of 10 minutes.
Main fixes:
subprocess.run
with args list instead of string. This removes the need forshlex
and helps running on windows.\
to/
on windows. This fixes running on windows.In short:
In long: