Skip to content

Commit 4c249af

Browse files
committed
Merge branch 'feature/typing' into develop
2 parents b58e1d5 + 7b195da commit 4c249af

17 files changed

+1532
-1368
lines changed

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E203

.github/workflows/continuous-integration-package.yml renamed to .github/workflows/continuous-integration-quality-unit-tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Continuous Integration - Package
1+
name: Continuous Integration - Quality & Unit Tests
22

33
on: [push, pull_request]
44

@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
os: [macOS-latest, ubuntu-20.04, windows-2019]
11-
python-version: [3.7, 3.8, 3.9]
11+
python-version: [3.8, 3.9, '3.10']
1212
fail-fast: false
1313
runs-on: ${{ matrix.os }}
1414
steps:
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install Poetry
3030
run: |
3131
curl -L https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -o get-poetry.py
32-
python get-poetry.py --version 1.0.10
32+
python get-poetry.py
3333
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
3434
shell: bash
3535
- name: Install Package Dependencies
@@ -46,9 +46,9 @@ jobs:
4646
run: |
4747
poetry run python -OO -c "import $CI_PACKAGE"
4848
shell: bash
49-
- name: Test with nosetests
49+
- name: Test with Pytest
5050
run: |
51-
poetry run python -W ignore -m nose -q -v --with-doctest --doctest-options=+ELLIPSIS --with-coverage --traverse-namespace --cover-package=$CI_PACKAGE $CI_PACKAGE
51+
poetry run python -W ignore -m py.test --disable-warnings --doctest-modules --ignore=$CI_PACKAGE/examples --cov=$CI_PACKAGE $CI_PACKAGE
5252
shell: bash
5353
- name: Upload Coverage to coveralls.io
5454
run: |
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Continuous Integration - Static Type Checking
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
continuous-integration-package:
7+
name: ${{ matrix.os }} - Python ${{ matrix.python-version }}
8+
strategy:
9+
matrix:
10+
os: [macOS-latest]
11+
python-version: [3.9]
12+
fail-fast: false
13+
runs-on: ${{ matrix.os }}
14+
steps:
15+
- uses: actions/checkout@v1
16+
- name: Environment Variables
17+
run: |
18+
echo "CI_PACKAGE=colour" >> $GITHUB_ENV
19+
shell: bash
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v1
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Install Dependencies (macOS)
25+
run: |
26+
brew install gnu-sed graphviz
27+
ln -s /usr/local/bin/gsed /usr/local/bin/sed
28+
shell: bash
29+
- name: Static Type Checking
30+
run: |
31+
pip install -r requirements.txt
32+
mypy --install-types --non-interactive --show-error-codes --warn-unused-ignores --warn-redundant-casts -p $CI_PACKAGE

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.pyc
22
.DS_Store
33
.coverage
4+
.dmypy.json
45
.idea
56
.ipynb_checkpoints/
67
__pycache__

.pre-commit-config.yaml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
repos:
2+
- repo: https://github.com/asottile/pyupgrade
3+
rev: v2.31.0
4+
hooks:
5+
- id: pyupgrade
6+
args: [--py38-plus]
7+
- repo: https://github.com/ikamensh/flynt/
8+
rev: '0.76'
9+
hooks:
10+
- id: flynt
11+
- repo: https://github.com/psf/black
12+
rev: 22.1.0
13+
hooks:
14+
- id: black
15+
language_version: python3.8
216
- repo: https://gitlab.com/pycqa/flake8
3-
rev: 3.7.8
17+
rev: 4.0.1
418
hooks:
519
- id: flake8
6-
exclude: examples|setup\.py
7-
- repo: https://github.com/pre-commit/mirrors-yapf
8-
rev: v0.23.0
9-
hooks:
10-
- id: yapf
11-
exclude: setup\.py

.style.yapf

Lines changed: 0 additions & 180 deletions
This file was deleted.

colour_checker_detection/__init__.py

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Colour - Checker Detection
43
==========================
@@ -10,6 +9,8 @@
109
- detection : Colour checker detection.
1110
"""
1211

12+
from __future__ import annotations
13+
1314
import cv2
1415
import numpy as np
1516
import os
@@ -25,52 +26,60 @@
2526
detect_colour_checkers_segmentation,
2627
)
2728

28-
__author__ = 'Colour Developers'
29-
__copyright__ = 'Copyright (C) 2018-2021 - Colour Developers'
30-
__license__ = 'New BSD License - https://opensource.org/licenses/BSD-3-Clause'
31-
__maintainer__ = 'Colour Developers'
32-
__email__ = 'colour-developers@colour-science.org'
33-
__status__ = 'Production'
29+
__author__ = "Colour Developers"
30+
__copyright__ = "Copyright (C) 2018-2021 - Colour Developers"
31+
__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause"
32+
__maintainer__ = "Colour Developers"
33+
__email__ = "colour-developers@colour-science.org"
34+
__status__ = "Production"
3435

3536
__all__ = [
36-
'SETTINGS_SEGMENTATION_COLORCHECKER_CLASSIC',
37-
'SETTINGS_SEGMENTATION_COLORCHECKER_SG',
38-
'colour_checkers_coordinates_segmentation',
39-
'extract_colour_checkers_segmentation',
40-
'detect_colour_checkers_segmentation',
37+
"SETTINGS_SEGMENTATION_COLORCHECKER_CLASSIC",
38+
"SETTINGS_SEGMENTATION_COLORCHECKER_SG",
39+
"colour_checkers_coordinates_segmentation",
40+
"extract_colour_checkers_segmentation",
41+
"detect_colour_checkers_segmentation",
4142
]
4243

43-
RESOURCES_DIRECTORY = os.path.join(os.path.dirname(__file__), 'resources')
44-
EXAMPLES_RESOURCES_DIRECTORY = os.path.join(
45-
RESOURCES_DIRECTORY, 'colour-checker-detection-examples-datasets')
46-
TESTS_RESOURCES_DIRECTORY = os.path.join(
47-
RESOURCES_DIRECTORY, 'colour-checker-detection-tests-datasets')
44+
RESOURCES_DIRECTORY: str = os.path.join(os.path.dirname(__file__), "resources")
45+
EXAMPLES_RESOURCES_DIRECTORY: str = os.path.join(
46+
RESOURCES_DIRECTORY, "colour-checker-detection-examples-datasets"
47+
)
48+
TESTS_RESOURCES_DIRECTORY: str = os.path.join(
49+
RESOURCES_DIRECTORY, "colour-checker-detection-tests-datasets"
50+
)
4851

49-
__application_name__ = 'Colour - Checker Detection'
52+
__application_name__ = "Colour - Checker Detection"
5053

51-
__major_version__ = '0'
52-
__minor_version__ = '1'
53-
__change_version__ = '2'
54-
__version__ = '.'.join(
55-
(__major_version__,
56-
__minor_version__,
57-
__change_version__)) # yapf: disable
54+
__major_version__ = "0"
55+
__minor_version__ = "1"
56+
__change_version__ = "2"
57+
__version__ = ".".join(
58+
(__major_version__, __minor_version__, __change_version__)
59+
)
5860

5961
try:
60-
version = subprocess.check_output( # nosec
61-
['git', 'describe'],
62-
cwd=os.path.dirname(__file__),
63-
stderr=subprocess.STDOUT).strip()
64-
version = version.decode('utf-8')
62+
_version = (
63+
subprocess.check_output( # nosec
64+
["git", "describe"],
65+
cwd=os.path.dirname(__file__),
66+
stderr=subprocess.STDOUT,
67+
)
68+
.strip()
69+
.decode("utf-8")
70+
)
6571
except Exception:
66-
version = __version__
72+
_version = __version__
6773

6874
colour.utilities.ANCILLARY_COLOUR_SCIENCE_PACKAGES[
69-
'colour-checker-detection'] = version
70-
colour.utilities.ANCILLARY_RUNTIME_PACKAGES['opencv'] = cv2.__version__
75+
"colour-checker-detection"
76+
] = _version
77+
colour.utilities.ANCILLARY_RUNTIME_PACKAGES["opencv"] = cv2.__version__
78+
79+
del _version
7180

7281
# TODO: Remove legacy printing support when deemed appropriate.
7382
try:
74-
np.set_printoptions(legacy='1.13')
83+
np.set_printoptions(legacy="1.13")
7584
except TypeError:
7685
pass

0 commit comments

Comments
 (0)