From aaf2da6213e5c118c5ce3ea1bbdebcd692f423f9 Mon Sep 17 00:00:00 2001 From: sqoshi Date: Sat, 2 Oct 2021 13:13:43 +0200 Subject: [PATCH 1/8] added linter check --- .github/workflows/lint.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..02bacc1 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: Python Lint + +on: [pull_request] + +jobs: + lint: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - uses: ricardochaves/python-lint@test + with: + python-root-list: 'python_alelo tests' + use-pylint: false + use-pycodestyle: false + use-flake8: false +# use-black: false + use-mypy: false +# use-isort: false \ No newline at end of file From b31d4d013d94b5d7babedcdb2f37a8bfb3407dab Mon Sep 17 00:00:00 2001 From: sqoshi Date: Sat, 2 Oct 2021 13:16:49 +0200 Subject: [PATCH 2/8] switched to 1.4.0 --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 02bacc1..3851c9f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v1 - - uses: ricardochaves/python-lint@test + - uses: ricardochaves/python-lint@v1.4.0 with: python-root-list: 'python_alelo tests' use-pylint: false From 2a18a365ab5c3a95c396e86b9cc8137b5a6e18c3 Mon Sep 17 00:00:00 2001 From: sqoshi Date: Sat, 2 Oct 2021 13:19:06 +0200 Subject: [PATCH 3/8] configuring yml --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3851c9f..1c48f49 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v1 - uses: ricardochaves/python-lint@v1.4.0 with: - python-root-list: 'python_alelo tests' + python-root-list: 'mask_imposer tests' use-pylint: false use-pycodestyle: false use-flake8: false From 5b2049fd34ba2b79788895753b172b9f88b815bb Mon Sep 17 00:00:00 2001 From: sqoshi Date: Sat, 2 Oct 2021 13:22:28 +0200 Subject: [PATCH 4/8] fixing linters --- .github/workflows/lint.yml | 12 ++++++------ mask_imposer/collector/coords_collector.py | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1c48f49..4a139f6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,9 +12,9 @@ jobs: - uses: ricardochaves/python-lint@v1.4.0 with: python-root-list: 'mask_imposer tests' - use-pylint: false - use-pycodestyle: false - use-flake8: false -# use-black: false - use-mypy: false -# use-isort: false \ No newline at end of file +# use-pylint: false +# use-pycodestyle: false +# use-flake8: false + use-black: false +# use-mypy: false + use-isort: false \ No newline at end of file diff --git a/mask_imposer/collector/coords_collector.py b/mask_imposer/collector/coords_collector.py index 563d4ae..741d091 100644 --- a/mask_imposer/collector/coords_collector.py +++ b/mask_imposer/collector/coords_collector.py @@ -1,8 +1,9 @@ from logging import Logger -from typing import List, Dict, Optional, Any -from termcolor import colored +from typing import Any, Dict, List, Optional import cv2 +from termcolor import colored + from mask_imposer.imposer.mask_pointers import Pointer From 78bd0409d28c21f43059f4f05f288cdcce0eb2a3 Mon Sep 17 00:00:00 2001 From: sqoshi Date: Sat, 2 Oct 2021 13:29:53 +0200 Subject: [PATCH 5/8] fixed some pylint errors --- mask_imposer/collector/coords_collector.py | 2 +- tests/test_mask_image_read.py | 26 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mask_imposer/collector/coords_collector.py b/mask_imposer/collector/coords_collector.py index 741d091..11673f0 100644 --- a/mask_imposer/collector/coords_collector.py +++ b/mask_imposer/collector/coords_collector.py @@ -52,7 +52,7 @@ def collect(self) -> Optional[Dict[int, Pointer]]: cv2.destroyAllWindows() if not confirmed: return self.reset() - self._logger.info(f"Coordinates accepted by user.") + self._logger.info("Coordinates accepted by user.") return self.mask_coords def _assign_mask_coords(self) -> None: diff --git a/tests/test_mask_image_read.py b/tests/test_mask_image_read.py index 87b9b66..22f2297 100644 --- a/tests/test_mask_image_read.py +++ b/tests/test_mask_image_read.py @@ -1,13 +1,13 @@ -from logging import getLogger -from unittest import TestCase - -from mask_imposer.imposer.mask_imposer import Imposer - - -class MaskImageReadTestCase(TestCase): - @classmethod - def setUp(cls) -> None: - cls.imposer = Imposer({}, getLogger("test")) - - # def test_should_read_mask_image(self): - # self.imposer._read_mask_image() +# from logging import getLogger +# from unittest import TestCase +# +# from mask_imposer.imposer.mask_imposer import Imposer +# +# +# class MaskImageReadTestCase(TestCase): +# @classmethod +# def setUp(cls) -> None: +# cls.imposer = Imposer({}, getLogger("test")) +# +# # def test_should_read_mask_image(self): +# # self.imposer._read_mask_image() From 8d1f94e1e90272aff85f0280c49bbb548d4bf216 Mon Sep 17 00:00:00 2001 From: sqoshi Date: Sat, 2 Oct 2021 13:34:37 +0200 Subject: [PATCH 6/8] fixed some pylint errors --- mask_imposer/definitions/images.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mask_imposer/definitions/images.py b/mask_imposer/definitions/images.py index ed692b1..6a0865a 100644 --- a/mask_imposer/definitions/images.py +++ b/mask_imposer/definitions/images.py @@ -10,7 +10,7 @@ class ImageFormat(Enum): webp = "webp" def __str__(self) -> str: - return self.value + return str(self.value) @staticmethod def is_image(f: str) -> bool: From b2919bb93e0ca89fa0dd41b6bfba343ac4caf614 Mon Sep 17 00:00:00 2001 From: sqoshi Date: Sat, 2 Oct 2021 14:47:17 +0200 Subject: [PATCH 7/8] splitted setup.cfg --- .flake8 | 21 +++++++++++++++++++++ .github/workflows/lint.yml | 19 ++++++++----------- .pylintrc | 15 +++++++++++++++ mask_imposer/input_inspector.py | 5 ++++- mypy.ini | 8 ++++++++ setup.cfg | 31 ------------------------------- tox.ini | 30 +++--------------------------- 7 files changed, 59 insertions(+), 70 deletions(-) create mode 100644 .flake8 create mode 100644 .pylintrc create mode 100644 mypy.ini delete mode 100644 setup.cfg diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..b0170af --- /dev/null +++ b/.flake8 @@ -0,0 +1,21 @@ +[flake8] +ignore = + F401, + W503 + +max-complexity = 10 +min-similarity-lines = 300 +max-line-length = 99 +exclude = + .tox, + .git, + __pycache__, + build, + dist, + tests/fixtures/*, + *.pyc, + *.egg-info, + .cache, + .mypy_cache, + .pytest_cache, + .eggs diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4a139f6..612b187 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,6 @@ name: Python Lint -on: [pull_request] +on: [ pull_request ] jobs: lint: @@ -8,13 +8,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: ricardochaves/python-lint@v1.4.0 - with: - python-root-list: 'mask_imposer tests' -# use-pylint: false -# use-pycodestyle: false -# use-flake8: false - use-black: false -# use-mypy: false - use-isort: false \ No newline at end of file + - uses: actions/checkout@v1 + - uses: ricardochaves/python-lint@v1.4.0 + with: + python-root-list: 'mask_imposer tests' + use-black: false + use-isort: false + extra-pycodestyle-options: "--max-line-length=99" \ No newline at end of file diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..27e4b96 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,15 @@ +[FORMAT] +max-line-length = 99 +max-args = 6 +extension-pkg-whitelist = + cv2, + dlib, + _dlib_pybind11 + +[MESSAGES CONTROL] +disable = + missing-docstring, + invalid-name, + import-error, + inconsistent-return-statements, + binary-op-exception \ No newline at end of file diff --git a/mask_imposer/input_inspector.py b/mask_imposer/input_inspector.py index 4261541..4b1101a 100644 --- a/mask_imposer/input_inspector.py +++ b/mask_imposer/input_inspector.py @@ -20,7 +20,10 @@ def __init__(self, logger: ColoredLogger): self._images: List[str] = [] def _find_images(self, path: str) -> List[str]: - """Find images in given path recognized by their extensions [filename.extension].""" + """Find images in given path. + + File is classified as img by extension [x.extension]. + """ all_files = listdir(path) if not all_files: self._logger.critical(f"{path} is empty.") diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..478aef4 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,8 @@ +[mypy] +check_untyped_defs = true +disallow_any_generics = true +disallow_incomplete_defs = true +disallow_untyped_defs = true +no_implicit_optional = true +warn_unused_ignores = true +ignore_missing_imports = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index de214c7..0000000 --- a/setup.cfg +++ /dev/null @@ -1,31 +0,0 @@ -;[options.extras_requires] -;tests = -; pytest>=4.6.9 -;style = -; flake8==3.9.2 -; mypy==0.770 -; pylint==2.9.6 -; isort==5.9.1 - -[mypy] -check_untyped_defs = true -disallow_any_generics = true -disallow_incomplete_defs = true -disallow_untyped_defs = true -no_implicit_optional = true -warn_unused_ignores = true -ignore_missing_imports = true - - - -[pylint.FORMAT] -max-line-length = 99 -max-args = 6 - -[pylint.'MESSAGES CONTROL'] -disable = - missing-docstring, - invalid-name, - import-error, - inconsistent-return-statements, - binary-op-exception \ No newline at end of file diff --git a/tox.ini b/tox.ini index abde27e..a44a873 100644 --- a/tox.ini +++ b/tox.ini @@ -7,16 +7,14 @@ envlist = deps = -rrequirements.txt pytest -commands = pytest {posargs} +commands = + pytest {posargs} [testenv:flake8] skip_install = true deps = flake8 -; flake8-bugbear -; flake8-docstrings>=1.3.1 -; flake8-typing-imports>=1.1 -; pep8-naming + commands = flake8 mask_imposer @@ -52,25 +50,3 @@ deps = isort commands = isort mask_imposer tests - -[flake8] -ignore = - F401, - W503 - -max-complexity = 10 -min-similarity-lines = 300 -max-line-length = 99 -exclude = - .tox, - .git, - __pycache__, - build, - dist, - tests/fixtures/*, - *.pyc, - *.egg-info, - .cache, - .mypy_cache, - .pytest_cache, - .eggs From ccd8cf4e9cf26e0cd4643474965739537f0bac08 Mon Sep 17 00:00:00 2001 From: sqoshi Date: Sat, 2 Oct 2021 14:51:17 +0200 Subject: [PATCH 8/8] mypy ini fix --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index 478aef4..6cd79b9 100644 --- a/mypy.ini +++ b/mypy.ini @@ -4,5 +4,5 @@ disallow_any_generics = true disallow_incomplete_defs = true disallow_untyped_defs = true no_implicit_optional = true -warn_unused_ignores = true +warn_unused_ignores = false ignore_missing_imports = true