Skip to content

Commit

Permalink
Add .pre-commit-config.yaml (AllenCellModeling#308)
Browse files Browse the repository at this point in the history
* commit config

* remove pass

* working

* use pre-commit for ci and tox

* add note to contributing
  • Loading branch information
tlambert03 committed Sep 17, 2021
1 parent 0304c50 commit 57e8375
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 31 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -72,4 +72,4 @@ jobs:
- name: Generate Docs
run: |
gitchangelog
make gen-docs
make gen-docs
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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, flake8-debugger]
args: [--count, --show-source, --statistics, --min-python-version=3.7.0]
- 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
6 changes: 0 additions & 6 deletions aicsimageio/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,20 @@ class ConflictingArgumentsError(Exception):
This exception is returned when 2 arguments to the same function are in conflict.
"""

pass


class InvalidDimensionOrderingError(Exception):
"""
A general exception that can be thrown when handling dimension ordering or
validation. Should be provided with a message for the user to be given more context.
"""

pass


class UnexpectedShapeError(Exception):
"""
A general exception that can be thrown when handling shape validation.
Should be provided with a message for the user to be given more context.
"""

pass


class UnsupportedFileFormatError(Exception):
"""
Expand Down
4 changes: 0 additions & 4 deletions aicsimageio/readers/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -153,7 +152,6 @@ def scenes(self) -> Tuple[str, ...]:
>>> for i in range(len(image.scenes))
"""
pass

@property
def current_scene(self) -> str:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
"""
Expand Down
1 change: 0 additions & 1 deletion aicsimageio/writers/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ def save(
"""
# There are no requirements for n-dimensions of data.
# The data provided can be 2D - ND.
pass
11 changes: 9 additions & 2 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,23 @@ 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
W503
max-line-length = 88

[isort]
profile = black
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
10 changes: 3 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 57e8375

Please sign in to comment.