Skip to content

[RFC][Formatting] Add scripts for applying Black to the Python code. - #6437

Merged
tqchen merged 7 commits into
apache:masterfrom
jroesch:blackd
Sep 13, 2020
Merged

[RFC][Formatting] Add scripts for applying Black to the Python code.#6437
tqchen merged 7 commits into
apache:masterfrom
jroesch:blackd

Conversation

@jroesch

Copy link
Copy Markdown
Member

@jroesch

Copy link
Copy Markdown
MemberAuthor

@junrushao

Copy link
Copy Markdown
Member

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?

@comaniaccomaniac left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadtests/lint/git-black.sh Outdated
Comment threadtests/lint/git-black.sh Outdated
exit 0
fi

echo "Running git-black against" $1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo"Running git-black against"$1
echo"Running git-black on Python files against"$1

Comment threadpyproject.toml Outdated

@areuschareusch left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadtests/lint/git-black.sh Outdated
@jroesch

Copy link
Copy Markdown
MemberAuthor

@areusch@tqchen@comaniac I can rollback the formatting, the first 3 or 4 commits were focused on formatting then I went through the process to see if it would actually work.

@jroeschjroesch changed the title [RFC][Formatting] Apply black to entire Python code base. [RFC][Formatting] Add scripts for applying Black to the Python code.Sep 10, 2020
@jroesch

Copy link
Copy Markdown
MemberAuthor

@junrushao1994@comaniac@areusch I just added the scripts and cleaned some things up, take another pass if you can

@comaniaccomaniac left a comment

Copy link
Copy Markdown
Contributor

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!

Comment threadtests/lint/git-black.sh Outdated
@jroesch

Copy link
Copy Markdown
MemberAuthor

@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.

@jroesch

Copy link
Copy Markdown
MemberAuthor

This is blocked on #6448 and #6451, once we land those two it should be possible to add the checking to the CI, format once more and land this.

Comment threadtests/lint/git-black.sh Outdated
Comment threadpyproject.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

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
MemberAuthor

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

Copy link
Copy Markdown
Contributor

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?

Comment threadpython/tvm/support.py Outdated
The dictionary of compile-time info.
"""
return {k: v for k, v in GetLibInfo().items()} # pylint: disable=unnecessary-comprehension
}

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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 = (

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
MemberAuthor

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.

Comment threadtests/lint/git-black.sh Outdated
fi

echo "Running black in checking mode"
black --diff --check

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
MemberAuthor

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.

Comment threadtests/lint/git-black.sh Outdated
@jroesch

Copy link
Copy Markdown
MemberAuthor

I think I addressed all the comments, and bumped the CI.

@junrushao

Copy link
Copy Markdown
Member

There is some flakiness in the CI. Please retrigger and let's merge it in

@tqchen
tqchen merged commit cdd3206 into apache:masterSep 13, 2020
@jroesch
jroesch deleted the blackd branch February 4, 2021 04:42
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@jroesch@junrushao@leandron@areusch@tqchen@comaniac