Skip to content

Commit cd93ec3

Browse files
committed
Implement support for typing annotations.
1 parent f835350 commit cd93ec3

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55

66
import dash
77
import os
8+
from colour.hints import Optional
89
from flask import Flask
910

11+
1012
__author__ = "Colour Developers"
1113
__copyright__ = "Copyright 2018 Colour Developers"
1214
__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause"
@@ -30,7 +32,7 @@
3032
*Flask* server hosting the *Dash* app.
3133
"""
3234

33-
SERVER_URL: str = os.environ.get("COLOUR_DASH_SERVER")
35+
SERVER_URL: Optional[str] = os.environ.get("COLOUR_DASH_SERVER")
3436
"""
3537
Server url used to construct permanent links for the individual apps.
3638
"""

apps/common.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import colour
77

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

1010
__author__ = "Colour Developers"
1111
__copyright__ = "Copyright 2018 Colour Developers"
@@ -87,10 +87,10 @@ def nuke_format_matrix(M: ArrayLike, decimals: Integer = 10) -> str:
8787
*The Foundry Nuke* formatted matrix.
8888
"""
8989

90-
def pretty(x: ArrayLike) -> str:
91-
"""
92-
Prettify given number.
93-
"""
90+
M = colour.utilities.as_float_array(M)
91+
92+
def pretty(x: Iterable) -> str:
93+
"""Prettify given number."""
9494

9595
return " ".join(map(f"{{: 0.{decimals}f}}".format, x))
9696

apps/rgb_colourspace_chromatically_adapted_primaries.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
App description.
5656
"""
5757

58-
APP_UID: str = hash(APP_NAME)
58+
APP_UID: Integer = hash(APP_NAME)
5959
"""
6060
App unique id.
6161
"""
@@ -132,7 +132,7 @@
132132
A(
133133
"Permalink",
134134
href=urllib.parse.urljoin(
135-
SERVER_URL, APP_PATH
135+
str(SERVER_URL), APP_PATH
136136
),
137137
target="_blank",
138138
)
@@ -221,8 +221,8 @@ def set_primaries_output(
221221
threshold=sys.maxsize,
222222
):
223223
if formatter == "str":
224-
P = str(P)
224+
P_f = str(P)
225225
elif formatter == "repr":
226-
P = repr(P)
226+
P_f = repr(P)
227227

228-
return P
228+
return P_f

apps/rgb_colourspace_transformation_matrix.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
App description.
5858
"""
5959

60-
APP_UID: str = hash(APP_NAME)
60+
APP_UID: Integer = hash(APP_NAME)
6161
"""
6262
App unique id.
6363
"""
@@ -140,7 +140,7 @@
140140
A(
141141
"Permalink",
142142
href=urllib.parse.urljoin(
143-
SERVER_URL, APP_PATH
143+
str(SERVER_URL), APP_PATH
144144
),
145145
target="_blank",
146146
)
@@ -228,9 +228,9 @@ def set_RGB_to_RGB_matrix_output(
228228
threshold=sys.maxsize,
229229
):
230230
if formatter == "str":
231-
M = str(M)
231+
M_f = str(M)
232232
elif formatter == "repr":
233-
M = repr(M)
233+
M_f = repr(M)
234234
else:
235235

236236
def slugify(string: str) -> str:
@@ -243,12 +243,13 @@ def slugify(string: str) -> str:
243243
string = re.sub(pattern, "_", string)
244244
return string
245245

246-
M = NUKE_COLORMATRIX_NODE_TEMPLATE.format(
246+
M_f = NUKE_COLORMATRIX_NODE_TEMPLATE.format(
247247
nuke_format_matrix(M, decimals),
248248
(
249249
f"{slugify(input_colourspace)}"
250250
f"__to__"
251251
f"{slugify(output_colourspace)}"
252252
),
253253
)
254-
return M
254+
255+
return M_f

0 commit comments

Comments
 (0)