Skip to content

Commit 8bdeef9

Browse files
committed
Implement support for "Colour" 0.4.2.
1 parent ec1b303 commit 8bdeef9

8 files changed

+130
-145
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
repos:
22
- repo: https://github.com/asottile/pyupgrade
3-
rev: v2.37.3
3+
rev: v3.2.2
44
hooks:
55
- id: pyupgrade
6-
args: [--py38-plus]
6+
args: [--py39-plus]
77
- repo: https://github.com/ikamensh/flynt/
8-
rev: '0.76'
8+
rev: '0.77'
99
hooks:
1010
- id: flynt
1111
- repo: https://github.com/psf/black
12-
rev: 22.6.0
12+
rev: 22.10.0
1313
hooks:
1414
- id: black
15-
language_version: python3.8
15+
language_version: python3.9
16+
- repo: https://github.com/keewis/blackdoc
17+
rev: v0.3.8
18+
hooks:
19+
- id: blackdoc
20+
language_version: python3.9
1621
- repo: https://github.com/PyCQA/flake8
17-
rev: 5.0.3
22+
rev: 6.0.0
1823
hooks:
1924
- id: flake8
2025
- repo: https://github.com/pycqa/pydocstyle

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8
1+
FROM python:3.11
22

33
WORKDIR /tmp
44
COPY ./requirements.txt /tmp

apps/common.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
======
44
"""
55

6-
import colour
6+
from colour.adaptation import CHROMATIC_ADAPTATION_TRANSFORMS
7+
from colour.colorimetry import CCS_ILLUMINANTS
8+
from colour.models import RGB_COLOURSPACES
9+
from colour.utilities import as_float_array
710

8-
from colour.hints import ArrayLike, Dict, Integer, Iterable, List
11+
from colour.hints import ArrayLike, Dict, Iterable, List
912

1013
__author__ = "Colour Developers"
1114
__copyright__ = "Copyright 2018 Colour Developers"
@@ -24,7 +27,7 @@
2427

2528
RGB_COLOURSPACE_OPTIONS: List[Dict] = [
2629
{"label": key, "value": key}
27-
for key in sorted(colour.RGB_COLOURSPACES.keys())
30+
for key in sorted(RGB_COLOURSPACES.keys())
2831
if key not in ("aces", "adobe1998", "prophoto")
2932
]
3033
"""
@@ -33,7 +36,7 @@
3336

3437
CHROMATIC_ADAPTATION_TRANSFORM_OPTIONS: List[Dict] = [
3538
{"label": key, "value": key}
36-
for key in sorted(colour.CHROMATIC_ADAPTATION_TRANSFORMS.keys())
39+
for key in sorted(CHROMATIC_ADAPTATION_TRANSFORMS.keys())
3740
]
3841
"""
3942
*Chromatic adaptation transform* options for a :class:`Dropdown` class
@@ -43,7 +46,7 @@
4346
ILLUMINANTS_OPTIONS: List[Dict] = [
4447
{"label": key, "value": key}
4548
for key in sorted(
46-
colour.CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"].keys()
49+
CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"].keys()
4750
)
4851
]
4952
"""
@@ -69,7 +72,7 @@
6972
"""
7073

7174

72-
def nuke_format_matrix(M: ArrayLike, decimals: Integer = 10) -> str:
75+
def nuke_format_matrix(M: ArrayLike, decimals: int = 10) -> str:
7376
"""
7477
Format given matrix for usage in *The Foundry Nuke*, i.e. *TCL* code for
7578
a *ColorMatrix* node.
@@ -87,7 +90,7 @@ def nuke_format_matrix(M: ArrayLike, decimals: Integer = 10) -> str:
8790
*The Foundry Nuke* formatted matrix.
8891
"""
8992

90-
M = colour.utilities.as_float_array(M)
93+
M = as_float_array(M)
9194

9295
def pretty(x: Iterable) -> str:
9396
"""Prettify given number."""

apps/rgb_colourspace_chromatically_adapted_primaries.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
from dash.dependencies import Input, Output
1010
from dash.html import A, Code, Div, H3, H5, Li, Pre, Ul
1111

12-
import colour
13-
from colour.hints import Integer
12+
from colour.colorimetry import CCS_ILLUMINANTS
13+
from colour.models import RGB_COLOURSPACES, chromatically_adapted_primaries
14+
from colour.utilities import numpy_print_options
1415

1516
from app import APP, SERVER_URL
1617
from apps.common import (
@@ -55,7 +56,7 @@
5556
App description.
5657
"""
5758

58-
APP_UID: Integer = hash(APP_NAME)
59+
APP_UID: int = hash(APP_NAME)
5960
"""
6061
App unique id.
6162
"""
@@ -179,7 +180,7 @@ def set_primaries_output(
179180
illuminant: str,
180181
chromatic_adaptation_transform: str,
181182
formatter: str,
182-
decimals: Integer,
183+
decimals: int,
183184
) -> str:
184185
"""
185186
Compute and write the chromatically adapted *primaries *of the given
@@ -207,16 +208,14 @@ def set_primaries_output(
207208
Chromatically adapted *primaries*.
208209
"""
209210

210-
P = colour.chromatically_adapted_primaries(
211-
colour.RGB_COLOURSPACES[colourspace].primaries,
212-
colour.RGB_COLOURSPACES[colourspace].whitepoint,
213-
colour.CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"][
214-
illuminant
215-
],
211+
P = chromatically_adapted_primaries(
212+
RGB_COLOURSPACES[colourspace].primaries,
213+
RGB_COLOURSPACES[colourspace].whitepoint,
214+
CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"][illuminant],
216215
chromatic_adaptation_transform,
217216
)
218217

219-
with colour.utilities.numpy_print_options(
218+
with numpy_print_options(
220219
formatter={"float": f"{{: 0.{decimals}f}}".format},
221220
threshold=sys.maxsize,
222221
):

apps/rgb_colourspace_transformation_matrix.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
from dash.dependencies import Input, Output
1111
from dash.html import A, Code, Div, H3, H5, Li, Pre, Ul
1212

13-
import colour
14-
from colour.hints import Integer
13+
from colour.models import RGB_COLOURSPACES, matrix_RGB_to_RGB
14+
from colour.utilities import numpy_print_options
1515

1616
from app import APP, SERVER_URL
1717
from apps.common import (
@@ -57,7 +57,7 @@
5757
App description.
5858
"""
5959

60-
APP_UID: Integer = hash(APP_NAME)
60+
APP_UID: int = hash(APP_NAME)
6161
"""
6262
App unique id.
6363
"""
@@ -190,7 +190,7 @@ def set_RGB_to_RGB_matrix_output(
190190
output_colourspace: str,
191191
chromatic_adaptation_transform: str,
192192
formatter: str,
193-
decimals: Integer,
193+
decimals: int,
194194
) -> str:
195195
"""
196196
Compute and write the colour transformation matrix from given input *RGB*
@@ -217,13 +217,13 @@ def set_RGB_to_RGB_matrix_output(
217217
Colour transformation matrix.
218218
"""
219219

220-
M = colour.matrix_RGB_to_RGB(
221-
colour.RGB_COLOURSPACES[input_colourspace],
222-
colour.RGB_COLOURSPACES[output_colourspace],
220+
M = matrix_RGB_to_RGB(
221+
RGB_COLOURSPACES[input_colourspace],
222+
RGB_COLOURSPACES[output_colourspace],
223223
chromatic_adaptation_transform,
224224
)
225225

226-
with colour.utilities.numpy_print_options(
226+
with numpy_print_options(
227227
formatter={"float": f"{{: 0.{decimals}f}}".format},
228228
threshold=sys.maxsize,
229229
):

pyproject.toml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,51 @@ classifiers = [
3939
]
4040

4141
[tool.poetry.dependencies]
42-
python = ">= 3.8, < 3.11"
43-
colour-science = ">= 0.4.0"
42+
python = ">= 3.9, < 3.12"
43+
colour-science = ">= 0.4.2"
4444
imageio = ">= 2, < 3"
45-
numpy = ">= 1.19, < 2"
46-
scipy = ">= 1.5, < 2"
45+
numpy = ">= 1.20, < 2"
46+
scipy = ">= 1.7, < 2"
4747
dash = "*"
4848
dash-renderer = "*"
4949
gunicorn = "*"
5050
plotly = "*"
5151

5252
black = { version = "*", optional = true } # Development dependency.
53+
blackdoc = { version = "*", optional = true } # Development dependency.
5354
coverage = { version = "!= 6.3", optional = true } # Development dependency.
5455
coveralls = { version = "*", optional = true } # Development dependency.
5556
flake8 = { version = "*", optional = true } # Development dependency.
5657
flynt = { version = "*", optional = true } # Development dependency.
5758
invoke = { version = "*", optional = true } # Development dependency.
58-
mypy = { version = "*", optional = true } # Development dependency.
5959
pre-commit = { version = "*", optional = true } # Development dependency.
6060
pydocstyle = { version = "*", optional = true } # Development dependency.
61+
pyright = { version = "*", optional = true } # Development dependency.
6162
pytest = { version = "*", optional = true } # Development dependency.
6263
pytest-cov = { version = "*", optional = true } # Development dependency.
64+
pytest-xdist = { version = "*", optional = true } # Development dependency.
6365
pyupgrade = { version = "*", optional = true } # Development dependency.
6466

6567
[tool.poetry.dev-dependencies]
6668
black = "*"
69+
blackdoc = "*"
6770
coverage = "*"
6871
coveralls = "*"
6972
flake8 = "*"
7073
flynt = "*"
7174
invoke = "*"
72-
mypy = "*"
7375
pre-commit = "*"
7476
pydocstyle = "*"
77+
pyright = "*"
7578
pytest = "*"
7679
pytest-cov = "*"
80+
pytest-xdist = "*"
7781
pyupgrade = "*"
7882

7983
[tool.poetry.extras]
8084
development = [
8185
"black",
86+
"blackdoc",
8287
"coverage",
8388
"coveralls",
8489
"flake8",
@@ -87,8 +92,10 @@ development = [
8792
"mypy",
8893
"pre-commit",
8994
"pydocstyle",
95+
"pyright",
9096
"pytest",
9197
"pytest-cov",
98+
"pytest-xdist",
9299
"pyupgrade",
93100
]
94101

@@ -97,7 +104,6 @@ line-length = 79
97104
exclude = '''
98105
/(
99106
\.git
100-
| \.mypy_cache
101107
| build
102108
| dist
103109
)/
@@ -106,14 +112,19 @@ exclude = '''
106112
[tool.flynt]
107113
line_length=999
108114

109-
[tool.mypy]
110-
plugins = "numpy.typing.mypy_plugin"
111-
ignore_missing_imports = true
112-
113115
[tool.pydocstyle]
114116
convention = "numpy"
115117
add-ignore = "D104,D200,D202,D205,D301,D400"
116118

119+
[tool.pyright]
120+
reportMissingImports = false
121+
reportMissingModuleSource = false
122+
reportUnboundVariable = false
123+
reportUnnecessaryCast = true
124+
reportUnnecessaryTypeIgnoreComment = true
125+
reportUnsupportedDunderAll = false
126+
reportUnusedExpression = false
127+
117128
[build-system]
118129
requires = [ "poetry_core>=1.0.0" ]
119130
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)