From 383119a949e125d7d18fdb3a5e7e1eb51c4e6617 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Thu, 16 Sep 2021 20:13:52 -0400 Subject: [PATCH 1/5] commit config --- .pre-commit-config.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..c784ce2af --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +exclude: aicsimageio/metadata/czi-to-ome-xslt/ +files: aicsimageio +repos: + - repo: https://github.com/PyCQA/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + additional_dependencies: [flake8-typing-imports==1.7.0] + args: [--count, --verbose, --show-source, --statistics] + - repo: https://github.com/myint/autoflake + rev: v1.4 + hooks: + - id: autoflake + args: ["--in-place", "--remove-all-unused-imports"] + - repo: https://github.com/PyCQA/isort + rev: 5.9.3 + hooks: + - id: isort + - repo: https://github.com/psf/black + rev: 21.9b0 + hooks: + - id: black + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.910 + hooks: + - id: mypy From 3bdb043691f6579cec1686406c2f17c6d722b2f2 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Thu, 16 Sep 2021 20:14:45 -0400 Subject: [PATCH 2/5] remove pass --- aicsimageio/exceptions.py | 6 ------ aicsimageio/readers/reader.py | 4 ---- aicsimageio/writers/writer.py | 1 - 3 files changed, 11 deletions(-) diff --git a/aicsimageio/exceptions.py b/aicsimageio/exceptions.py index 0b8bd160d..36e06679a 100644 --- a/aicsimageio/exceptions.py +++ b/aicsimageio/exceptions.py @@ -9,8 +9,6 @@ class ConflictingArgumentsError(Exception): This exception is returned when 2 arguments to the same function are in conflict. """ - pass - class InvalidDimensionOrderingError(Exception): """ @@ -18,8 +16,6 @@ class InvalidDimensionOrderingError(Exception): validation. Should be provided with a message for the user to be given more context. """ - pass - class UnexpectedShapeError(Exception): """ @@ -27,8 +23,6 @@ class UnexpectedShapeError(Exception): Should be provided with a message for the user to be given more context. """ - pass - class UnsupportedFileFormatError(Exception): """ diff --git a/aicsimageio/readers/reader.py b/aicsimageio/readers/reader.py index 1b5937e3c..c238cc60c 100644 --- a/aicsimageio/readers/reader.py +++ b/aicsimageio/readers/reader.py @@ -68,7 +68,6 @@ def _is_supported_image(fs: AbstractFileSystem, path: str, **kwargs: Any) -> boo supported: bool Boolean value indicating if the file is supported by the reader. """ - pass @classmethod def is_supported_image(cls, image: types.ImageLike, **kwargs: Any) -> bool: @@ -153,7 +152,6 @@ def scenes(self) -> Tuple[str, ...]: >>> for i in range(len(image.scenes)) """ - pass @property def current_scene(self) -> str: @@ -264,7 +262,6 @@ def _read_delayed(self) -> xr.DataArray: * If a channel dimension is present, please populate the channel dimensions coordinate array the respective channel coordinate values. """ - pass @abstractmethod def _read_immediate(self) -> xr.DataArray: @@ -283,7 +280,6 @@ def _read_immediate(self) -> xr.DataArray: * If a channel dimension is present, please populate the channel dimensions coordinate array the respective channel coordinate values. """ - pass def _get_stitched_dask_mosaic(self) -> xr.DataArray: """ diff --git a/aicsimageio/writers/writer.py b/aicsimageio/writers/writer.py index 46a9e6d03..aa93e3826 100644 --- a/aicsimageio/writers/writer.py +++ b/aicsimageio/writers/writer.py @@ -45,4 +45,3 @@ def save( """ # There are no requirements for n-dimensions of data. # The data provided can be 2D - ND. - pass From a99b8ce9a5b4dc34d437ca468a54dfe86339b270 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Thu, 16 Sep 2021 20:21:30 -0400 Subject: [PATCH 3/5] working --- .pre-commit-config.yaml | 2 +- setup.cfg | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c784ce2af..51fcece60 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: hooks: - id: flake8 additional_dependencies: [flake8-typing-imports==1.7.0] - args: [--count, --verbose, --show-source, --statistics] + args: [--count, --show-source, --statistics, --min-python-version=3.7.0] - repo: https://github.com/myint/autoflake rev: v1.4 hooks: diff --git a/setup.cfg b/setup.cfg index 0b9f41e2b..8c098c1bc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,15 +26,15 @@ test = pytest [tool:pytest] collect_ignore = ['setup.py'] xfail_strict = true -filterwarnings = +filterwarnings = ignore::UserWarning ignore::FutureWarning [flake8] -exclude = +exclude = docs/ aicsimageio/vendor/ -ignore = +ignore = E203 E402 W291 @@ -42,6 +42,7 @@ ignore = max-line-length = 88 [isort] +profile = black multi_line_output = 3 include_trailing_comma = True force_grid_wrap = 0 From 0fef9df2b72dadc59e9a010bebe231c79deb82a8 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 17 Sep 2021 13:29:05 -0400 Subject: [PATCH 4/5] use pre-commit for ci and tox --- .github/workflows/test-and-lint.yml | 6 +++--- .pre-commit-config.yaml | 2 +- setup.py | 10 +++++----- tox.ini | 10 +++------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test-and-lint.yml b/.github/workflows/test-and-lint.yml index 90323f4ef..aeea6befc 100644 --- a/.github/workflows/test-and-lint.yml +++ b/.github/workflows/test-and-lint.yml @@ -50,9 +50,9 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip - pip install .[test] + pip install pre-commit - name: Lint - run: tox -e lint + run: pre-commit run --all-files --show-diff-on-failure docs: runs-on: ubuntu-latest @@ -72,4 +72,4 @@ jobs: - name: Generate Docs run: | gitchangelog - make gen-docs \ No newline at end of file + make gen-docs diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 51fcece60..1a58eb748 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: rev: 3.9.2 hooks: - id: flake8 - additional_dependencies: [flake8-typing-imports==1.7.0] + additional_dependencies: [flake8-typing-imports, flake8-debugger] args: [--count, --show-source, --statistics, --min-python-version=3.7.0] - repo: https://github.com/myint/autoflake rev: v1.4 diff --git a/setup.py b/setup.py index dc0bba5b9..bbec0bf7f 100644 --- a/setup.py +++ b/setup.py @@ -40,14 +40,9 @@ def run(self): test_requirements = [ *all_formats, - "black>=19.10b0", "codecov>=2.1.4", "distributed>=2021.4.1", "docutils>=0.10,<0.16", - "flake8>=3.8.3", - "flake8-debugger>=3.2.1", - "isort>=5.7.0", - "mypy>=0.800", "psutil>=5.7.0", "pytest>=5.4.3", "pytest-cov>=2.9.0", @@ -61,11 +56,16 @@ def run(self): *setup_requirements, *test_requirements, "asv>=0.4.2", + "black>=19.10b0", "bump2version>=1.0.1", "coverage>=5.1", + "flake8>=3.8.3", + "flake8-debugger>=3.2.1", "gitchangelog>=3.0.4", "ipython>=7.15.0", + "isort>=5.7.0", "m2r2>=0.2.7", + "mypy>=0.800", "pytest-runner>=5.2", "Sphinx>=3.4.3", "sphinx_rtd_theme>=0.5.1", diff --git a/tox.ini b/tox.ini index 44444f42e..66cd87a4b 100644 --- a/tox.ini +++ b/tox.ini @@ -2,13 +2,9 @@ envlist = py37, py38, py39, lint [testenv:lint] -deps = - .[test] -commands = - flake8 aicsimageio --count --verbose --show-source --statistics --exclude aicsimageio/metadata/czi-to-ome-xslt/ - isort aicsimageio --check-only --skip aicsimageio/metadata/czi-to-ome-xslt/ - mypy aicsimageio --exclude aicsimageio/metadata/czi-to-ome-xslt/ - black --check aicsimageio --exclude aicsimageio/metadata/czi-to-ome-xslt/ +skip_install = true +deps = pre-commit +commands = pre-commit run --all-files --show-diff-on-failure [testenv] passenv = From fc7262b1c93481ab62dddf11e0fb5c68bf90c892 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 17 Sep 2021 16:18:10 -0400 Subject: [PATCH 5/5] add note to contributing --- docs/CONTRIBUTING.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index d3f0177aa..eba20f323 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -49,13 +49,20 @@ Ready to contribute? Here's how to set up `aicsimageio` for local development. make build-with-remote -8. Commit your changes and push your branch to GitHub: +8. (Optional) If you'd like to have linting checks run automatically prior to + every `git commit`, then you can install a commit-hook that runs + [pre-commit](https://pre-commit.com/), as follows: + + pip install pre-commit + pre-commit install + +9. Commit your changes and push your branch to GitHub: git add . git commit -m "Resolves gh-###. Your detailed description of your changes." git push origin {your_development_type}/short-description -9. Submit a pull request through the GitHub website. +10. Submit a pull request through the GitHub website. ## Adding a New Custom Reader