Skip to content

Commit

Permalink
Merge pull request #17 from sqoshi/16-ci-linters
Browse files Browse the repository at this point in the history
Added CI linter check.
  • Loading branch information
sqoshi authored Oct 2, 2021
2 parents e64bfd9 + ccd8cf4 commit cb963fa
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 76 deletions.
21 changes: 21 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Python Lint

on: [ pull_request ]

jobs:
lint:

runs-on: ubuntu-latest

steps:
- 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"
15 changes: 15 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions mask_imposer/collector/coords_collector.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -51,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:
Expand Down
2 changes: 1 addition & 1 deletion mask_imposer/definitions/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion mask_imposer/input_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
8 changes: 8 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -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 = false
ignore_missing_imports = true
31 changes: 0 additions & 31 deletions setup.cfg

This file was deleted.

26 changes: 13 additions & 13 deletions tests/test_mask_image_read.py
Original file line number Diff line number Diff line change
@@ -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()
30 changes: 3 additions & 27 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

0 comments on commit cb963fa

Please sign in to comment.