Skip to content

upgrade usort to 1.0.2 and black to 22.3.0 #5106

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 8 commits into from
Jul 22, 2022

Conversation

pmeier
Copy link
Collaborator

@pmeier pmeier commented Dec 16, 2021

Compared to usort==0.6.4 which we are currently using, there are two major improvments in 1.0.0:

  1. Multiple import statements that import from the same module will be merged into one.
  2. Imports inside an import statement are sorted lexiographically.

For example

from foo import baz
from foo import spam, ham
from foo import bar

will be turned into

from foo import bar, baz, ham, spam

That means we need to pay even less attention to import's while reviewing and would prevent stuff like

from typing import Callable, Optional, Collection
from typing import Union, Tuple, List, Dict, Any

Note that usort==1.0.0 is not yet released, but it is scheduled for the next weeks. I ran locally with the current preview 1.0.0rc1 and it works as expected. Since we will only touch import's, the noise on git blame is minimal.

@facebook-github-bot
Copy link

facebook-github-bot commented Dec 16, 2021

💊 CI failures summary and remediations

As of commit e46fbc2 (more details on the Dr. CI page):


  • 2/2 failures introduced in this PR

🕵️ 1 new failure recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See CircleCI build lint_python_and_config (1/1)

Step: "Install pre-commit hooks" (full log | diagnosis details | 🔁 rerun)

An unexpected error has occurred: CalledProcess...nstall', '.', 'black == 21.9b0', 'usort == 1.0.0')
[INFO]�[m Initializing environment for https://github.com/omnilib/ufmt.
[INFO]�[m Initializing environment for https://github.com/omnilib/ufmt:black == 21.9b0,usort == 1.0.0.
[INFO]�[m Initializing environment for https://gitlab.com/pycqa/flake8.
[INFO]�[m Initializing environment for https://github.com/PyCQA/pydocstyle.
[INFO]�[m Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO]�[m Once installed this environment will be reused.
[INFO]�[m This may take a few minutes...
[INFO]�[m Installing environment for https://github.com/omnilib/ufmt.
[INFO]�[m Once installed this environment will be reused.
[INFO]�[m This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/home/circleci/.cache/pre-commit/repo3s9waikz/py_env-python3.7/bin/python', '-mpip', 'install', '.', 'black == 21.9b0', 'usort == 1.0.0')
return code: 1
expected return code: 0
stdout:
    Processing /home/circleci/.cache/pre-commit/repo3s9waikz
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Installing backend dependencies: started
      Installing backend dependencies: finished with status 'done'

1 failure not recognized by patterns:

Job Step Action
CircleCI cmake_windows_cpu set -ex
source packaging/windows/internal/vc_install_helper.sh
packaging/build_cmake.sh
🔁 rerun

This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@NicolasHug
Copy link
Member

NicolasHug commented Dec 16, 2021

Thanks @pmeier for the initiative.
For ref for fb employees, this is the corresponding internal post: https://fb.workplace.com/groups/pyfmt/permalink/925830131387837/

I'll have to make sure updating to 1.0 doesn't clash with the internal tooling. Since I'll be on PTO in 2 days, let's do all this next year :) ?

@NicolasHug NicolasHug changed the title upgrade usort to 1.0.0 upgrade usort to 1.0.0 and black to 22.3.0 May 16, 2022
@pmeier pmeier changed the title upgrade usort to 1.0.0 and black to 22.3.0 upgrade usort to 1.0.2 and black to 22.3.0 May 17, 2022
@NicolasHug NicolasHug marked this pull request as ready for review July 22, 2022 10:24
Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

After a lot of back and forth I think I finally managed to make this consistent with internal linting. There was a minor formatting bug on the internal side that was fixed as well.

The repo is quiet today so it's a good time to merge this. I'll approve and merge, if anything goes wrong by EOD I'll have time to revert. Current CI failure are unrelated

@NicolasHug NicolasHug merged commit 6ca9c76 into pytorch:main Jul 22, 2022
@github-actions
Copy link

Hey @NicolasHug!

You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Jul 22, 2022

The repo is quiet today so it's a good time to merge this.

I have my branch on proto transforms fully conflicting now )))
No worries, I'll be able to fix it

vfdev-5 added a commit that referenced this pull request Jul 22, 2022
Up versions according to #5106
@vfdev-5 vfdev-5 mentioned this pull request Jul 22, 2022
vfdev-5 added a commit that referenced this pull request Jul 22, 2022
@NicolasHug
Copy link
Member

Your best bet is probably to format with the new versions before merging with main

facebook-github-bot pushed a commit that referenced this pull request Jul 25, 2022
Summary:
* upgrade usort to

* Also update black

* Actually use 1.0.2

* Apply pre-commit

Reviewed By: datumbox

Differential Revision: D38071391

fbshipit-source-id: ecfb6639e5ccfcc9ff7aa4db5f06a7fab05e9074

Co-authored-by: Nicolas Hug <[email protected]>
vfdev-5 added a commit that referenced this pull request Jul 28, 2022
* [proto] Added few transforms tests, part 1 (#6262)

* Added supported/unsupported data checks in the tests for cutmix/mixup

* Added RandomRotation, RandomAffine transforms tests

* Added tests for RandomZoomOut, Pad

* Update test_prototype_transforms.py

* Added RandomCrop transform and tests (#6271)

* [proto] Added GaussianBlur transform and tests (#6273)

* Added GaussianBlur transform and tests

* Fixing code format

* Copied correctness test

* [proto] Added random color transforms and tests (#6275)

* Added random color transforms and tests

* Disable smoke test for RandomSolarize, RandomAdjustSharpness

* Added RandomPerspective and tests (#6284)

- replaced real image creation by mocks for other tests

* Added more functional tests (#6285)

* [proto] Added elastic transform and tests (#6295)

* WIP [proto] Added functional elastic transform with tests

* Added more functional tests

* WIP on elastic op

* Added elastic transform and tests

* Added tests

* Added tests for ElasticTransform

* Try to format code as in #5106

* Fixed bug in affine get_params test

* Implemented RandomErase on PIL input as fallback to tensors (#6309)

Added tests

* Added image_size computation for BoundingBox.rotate if expand (#6319)

* Added image_size computation for BoundingBox.rotate if expand

* Added tests

* Added erase_image_pil and eager/jit erase_image_tensor test (#6320)

* Updates according to the review

Co-authored-by: Vasilis Vryniotis <[email protected]>
facebook-github-bot pushed a commit that referenced this pull request Aug 2, 2022
Summary:
* [proto] Added few transforms tests, part 1 (#6262)

* Added supported/unsupported data checks in the tests for cutmix/mixup

* Added RandomRotation, RandomAffine transforms tests

* Added tests for RandomZoomOut, Pad

* Update test_prototype_transforms.py

* Added RandomCrop transform and tests (#6271)

* [proto] Added GaussianBlur transform and tests (#6273)

* Added GaussianBlur transform and tests

* Fixing code format

* Copied correctness test

* [proto] Added random color transforms and tests (#6275)

* Added random color transforms and tests

* Disable smoke test for RandomSolarize, RandomAdjustSharpness

* Added RandomPerspective and tests (#6284)

- replaced real image creation by mocks for other tests

* Added more functional tests (#6285)

* [proto] Added elastic transform and tests (#6295)

* WIP [proto] Added functional elastic transform with tests

* Added more functional tests

* WIP on elastic op

* Added elastic transform and tests

* Added tests

* Added tests for ElasticTransform

* Try to format code as in #5106

* Fixed bug in affine get_params test

* Implemented RandomErase on PIL input as fallback to tensors (#6309)

Added tests

* Added image_size computation for BoundingBox.rotate if expand (#6319)

* Added image_size computation for BoundingBox.rotate if expand

* Added tests

* Added erase_image_pil and eager/jit erase_image_tensor test (#6320)

* Updates according to the review

Reviewed By: NicolasHug

Differential Revision: D38351755

fbshipit-source-id: 4b52b530f93c3dfa92326e01803665cb44003a63

Co-authored-by: Vasilis Vryniotis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants