-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[RFC][Formatting] Add scripts for applying Black to the Python code. #6437
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
Conversation
|
It is a bit hard to review 1000 files...maybe just take a look at the pyproject.toml file and assume other parts are correct? |
comaniac
left a comment
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.
Tried to review the first 3 commits because I cannot even open the changes after the formatting commit...
I'd suggest separating two 2 PRs. The first one focuses on the scripts and CI flow (but disable the checking to pass the CI). The second one then formats all Python codes. In this way, as long as the second PR passes the CI we should be be good.
tests/lint/git-black.sh
Outdated
| exit 0 | ||
| fi | ||
|
|
||
| echo "Running git-black against" $1 |
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.
| echo "Running git-black against" $1 | |
| echo "Running git-black on Python files against" $1 |
areusch
left a comment
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.
+1 to splitting the review into a scripts part and a format part.
|
@junrushao1994 @comaniac @areusch I just added the scripts and cleaned some things up, take another pass if you can |
comaniac
left a comment
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. Just some nits. Thanks!
|
@tqchen recommended that we first format the entire code base using these settings then try to land the CI parts, going to open a second PR with the fully formatted repo. |
pyproject.toml
Outdated
| | tests\/ | ||
| | vta\/ | ||
| | web\/ | ||
| )/|tests/lint/add_asf_header.py|tests/lint/check_file_type.py|python/tvm/topi/testing/pool3d_python.py|python/topi/python/test_topi_pooling.py |
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.
can you break these line by line and sort?
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.
These two files actually trigger an internal error with black and I was going to open up a follow up issue to fix these.
| # under the License. | ||
|
|
||
| '''Utility for Hexagon backend''' | ||
| # pylint: disable=invalid-name |
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 come we need this?
python/tvm/support.py
Outdated
| The dictionary of compile-time info. | ||
| """ | ||
| return {k: v for k, v in GetLibInfo().items()} # pylint: disable=unnecessary-comprehension | ||
| } |
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.
there are a lot of these extra closing braces or insertions that look like function_call( with no close ) added. merge mistake? seems like nothing can possibly pass til they're deleted...
| from .util import _internal_assert | ||
|
|
||
| # pylint: disable=redefined-builtin | ||
| # pylint: disable=redefined-builtin,invalid-name |
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.
same question here--do we need to update pylint?
| max_output_range, | ||
| out_dtype): | ||
| """Get the MKLDNN requantized scale.""" | ||
| quantized_out_range = ( |
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's up with this line?
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.
These are a bunch of random edits that made the results of black happier.
tests/lint/git-black.sh
Outdated
| fi | ||
|
|
||
| echo "Running black in checking mode" | ||
| black --diff --check |
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.
I think you either want --diff and assert on an empty output or --check, I don't know what both do?
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.
I think diff and check at same time give that behavior if I understand correctly, check makes it return a -1 status code which should fail this entire script.
|
I think I addressed all the comments, and bumped the CI. |
|
There is some flakiness in the CI. Please retrigger and let's merge it in |
As per the recent RFC https://discuss.tvm.apache.org/t/rfc-introduce-automatic-formatting-of-python-code/7843/10.