diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index e9fb69c2..d0870893 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -46,7 +46,7 @@ outlined on that page and do not file a public issue. ## Coding Style We follow these [python](http://google.github.io/styleguide/pyguide.html) and [C++](https://google.github.io/styleguide/cppguide.html) style guides. -For the linter to work, you will need to install `black`, `flake`, `isort` and `clang-format`, and +For the linter to work, you will need to install `black`, `flake`, `usort` and `clang-format`, and they need to be fairly up to date. ## License diff --git a/INSTALL.md b/INSTALL.md index 1202df08..2cf16c4a 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -43,7 +43,7 @@ export CUB_HOME=$PWD/cub-1.10.0 For developing on top of PyTorch3D or contributing, you will need to run the linter and tests. If you want to run any of the notebook tutorials as `docs/tutorials` or the examples in `docs/examples` you will also need matplotlib and OpenCV. - scikit-image - black -- isort +- usort - flake8 - matplotlib - tdqm @@ -59,7 +59,7 @@ conda install jupyter pip install scikit-image matplotlib imageio plotly opencv-python # Tests/Linting -pip install black 'isort<5' flake8 flake8-bugbear flake8-comprehensions +pip install black usort flake8 flake8-bugbear flake8-comprehensions ``` ## Installing prebuilt binaries for PyTorch3D diff --git a/dev/linter.sh b/dev/linter.sh index 8fa58b21..b1d32c25 100755 --- a/dev/linter.sh +++ b/dev/linter.sh @@ -22,8 +22,14 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DIR=$(dirname "${DIR}") -echo "Running isort..." -isort -y -sp "${DIR}" +if [[ -f "${DIR}/tests/TARGETS" ]] +then + pyfmt "${DIR}" +else +# run usort externally only + echo "Running usort..." + usort "${DIR}" +fi echo "Running black..." black "${DIR}" diff --git a/pytorch3d/implicitron/third_party/hyperlayers.py b/pytorch3d/implicitron/third_party/hyperlayers.py index 640a14ed..1fb32171 100644 --- a/pytorch3d/implicitron/third_party/hyperlayers.py +++ b/pytorch3d/implicitron/third_party/hyperlayers.py @@ -2,9 +2,9 @@ # fmt: off # flake8: noqa '''Pytorch implementations of hyper-network modules. -isort:skip_file ''' import functools + import torch import torch.nn as nn diff --git a/pytorch3d/implicitron/third_party/pytorch_prototyping.py b/pytorch3d/implicitron/third_party/pytorch_prototyping.py index 0823b953..7dd973fc 100644 --- a/pytorch3d/implicitron/third_party/pytorch_prototyping.py +++ b/pytorch3d/implicitron/third_party/pytorch_prototyping.py @@ -2,7 +2,6 @@ # fmt: off # flake8: noqa '''A number of custom pytorch modules with sane defaults that I find useful for model prototyping. -isort:skip_file ''' import torch import torch.nn as nn diff --git a/setup.py b/setup.py index ce007f52..98b83410 100755 --- a/setup.py +++ b/setup.py @@ -144,7 +144,7 @@ setup( install_requires=["fvcore", "iopath"], extras_require={ "all": ["matplotlib", "tqdm>4.29.0", "imageio", "ipywidgets"], - "dev": ["flake8", "isort", "black==19.3b0"], + "dev": ["flake8", "usort", "black==19.3b0"], "implicitron": ["hydra-core>=1.1", "visdom", "lpips", "matplotlib"], }, entry_points={