Skip to content

Commit e08f5a1

Browse files
committed
Merge branch 'feature/v0.4.7' into develop
2 parents 12044e4 + 7307e88 commit e08f5a1

21 files changed

+77
-95
lines changed

colour/hints/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import re
1313
import typing
1414
from collections.abc import Generator, Iterable, Iterator, Mapping, Sequence
15+
from os import PathLike
1516
from types import ModuleType
1617
from typing import ( # noqa: UP035
1718
Any,
@@ -64,6 +65,7 @@
6465
"NewType",
6566
"Protocol",
6667
"Sequence",
68+
"PathLike",
6769
"Set",
6870
"SupportsIndex",
6971
"TextIO",

colour/io/ctl.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
import numpy as np
2222

2323
if typing.TYPE_CHECKING:
24-
from pathlib import Path
2524
from colour.hints import (
2625
Any,
2726
ArrayLike,
2827
Dict,
2928
NDArrayFloat,
29+
PathLike,
3030
)
3131

3232
from colour.hints import Sequence
@@ -66,8 +66,8 @@
6666

6767
@required("ctlrender")
6868
def ctl_render(
69-
path_input: str | Path,
70-
path_output: str | Path,
69+
path_input: str | PathLike,
70+
path_output: str | PathLike,
7171
ctl_transforms: Sequence[str] | Dict[str, Sequence[str]],
7272
*args: Any,
7373
**kwargs: Any,

colour/io/fichet2021.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
from colour.constants import CONSTANT_LIGHT_SPEED
3434

3535
if typing.TYPE_CHECKING:
36-
from pathlib import Path
3736
from colour.hints import (
3837
Any,
3938
Callable,
4039
Literal,
40+
PathLike,
4141
)
4242

4343
from colour.hints import Dict, NDArrayFloat, Sequence, Tuple
@@ -318,7 +318,7 @@ class Specification_Fichet2021:
318318

319319
@staticmethod
320320
@required("OpenImageIO")
321-
def from_spectral_image(path: str | Path) -> Specification_Fichet2021:
321+
def from_spectral_image(path: str | PathLike) -> Specification_Fichet2021:
322322
"""
323323
Create a *Fichet et al. (2021)* spectral image specification from given
324324
image path.
@@ -424,7 +424,7 @@ def from_spectral_image(path: str | Path) -> Specification_Fichet2021:
424424
@typing.overload
425425
@required("OpenImageIO")
426426
def read_spectral_image_Fichet2021(
427-
path: str | Path,
427+
path: str | PathLike,
428428
bit_depth: Literal["float16", "float32"] = ...,
429429
additional_data: Literal[True] = True,
430430
) -> Tuple[ComponentsFichet2021, Specification_Fichet2021]: ...
@@ -433,7 +433,7 @@ def read_spectral_image_Fichet2021(
433433
@typing.overload
434434
@required("OpenImageIO")
435435
def read_spectral_image_Fichet2021(
436-
path: str | Path,
436+
path: str | PathLike,
437437
bit_depth: Literal["float16", "float32"] = ...,
438438
*,
439439
additional_data: Literal[False],
@@ -443,15 +443,15 @@ def read_spectral_image_Fichet2021(
443443
@typing.overload
444444
@required("OpenImageIO")
445445
def read_spectral_image_Fichet2021(
446-
path: str | Path,
446+
path: str | PathLike,
447447
bit_depth: Literal["float16", "float32"],
448448
additional_data: bool = False,
449449
) -> ComponentsFichet2021: ...
450450

451451

452452
@required("OpenImageIO")
453453
def read_spectral_image_Fichet2021(
454-
path: str | Path,
454+
path: str | PathLike,
455455
bit_depth: Literal["float16", "float32"] = "float32",
456456
additional_data: bool = False,
457457
) -> ComponentsFichet2021 | Tuple[ComponentsFichet2021, Specification_Fichet2021]:
@@ -751,7 +751,7 @@ def write_spectral_image_Fichet2021(
751751
| MultiSpectralDistributions
752752
| ComponentsFichet2021
753753
| ValuesView,
754-
path: str | Path,
754+
path: str | PathLike,
755755
bit_depth: Literal["float16", "float32"] = "float32",
756756
specification: Specification_Fichet2021 = SPECIFICATION_FICHET2021_DEFAULT,
757757
components_to_RGB_callable: Callable = components_to_sRGB_Fichet2021,

colour/io/image.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
import numpy as np
1414

1515
if typing.TYPE_CHECKING:
16-
from pathlib import Path
1716
from colour.hints import (
1817
Any,
1918
ArrayLike,
2019
DTypeReal,
2120
Literal,
2221
NDArrayFloat,
22+
PathLike,
2323
Sequence,
2424
Tuple,
2525
Type,
@@ -332,7 +332,7 @@ def convert_bit_depth(
332332
@typing.overload
333333
@required("OpenImageIO")
334334
def read_image_OpenImageIO(
335-
path: str | Path,
335+
path: str | PathLike,
336336
bit_depth: Literal[
337337
"uint8", "uint16", "float16", "float32", "float64", "float128"
338338
] = ...,
@@ -344,7 +344,7 @@ def read_image_OpenImageIO(
344344
@typing.overload
345345
@required("OpenImageIO")
346346
def read_image_OpenImageIO(
347-
path: str | Path,
347+
path: str | PathLike,
348348
bit_depth: Literal[
349349
"uint8", "uint16", "float16", "float32", "float64", "float128"
350350
] = ...,
@@ -357,7 +357,7 @@ def read_image_OpenImageIO(
357357
@typing.overload
358358
@required("OpenImageIO")
359359
def read_image_OpenImageIO(
360-
path: str | Path,
360+
path: str | PathLike,
361361
bit_depth: Literal["uint8", "uint16", "float16", "float32", "float64", "float128"],
362362
additional_data: Literal[False],
363363
**kwargs: Any,
@@ -366,7 +366,7 @@ def read_image_OpenImageIO(
366366

367367
@required("OpenImageIO")
368368
def read_image_OpenImageIO(
369-
path: str | Path,
369+
path: str | PathLike,
370370
bit_depth: Literal[
371371
"uint8", "uint16", "float16", "float32", "float64", "float128"
372372
] = "float32",
@@ -455,7 +455,7 @@ def read_image_OpenImageIO(
455455

456456

457457
def read_image_Imageio(
458-
path: str | Path,
458+
path: str | PathLike,
459459
bit_depth: Literal[
460460
"uint8", "uint16", "float16", "float32", "float64", "float128"
461461
] = "float32",
@@ -526,7 +526,7 @@ def read_image_Imageio(
526526

527527

528528
def read_image(
529-
path: str | Path,
529+
path: str | PathLike,
530530
bit_depth: Literal[
531531
"uint8", "uint16", "float16", "float32", "float64", "float128"
532532
] = "float32",
@@ -606,7 +606,7 @@ def read_image(
606606
@required("OpenImageIO")
607607
def write_image_OpenImageIO(
608608
image: ArrayLike,
609-
path: str | Path,
609+
path: str | PathLike,
610610
bit_depth: Literal[
611611
"uint8", "uint16", "float16", "float32", "float64", "float128"
612612
] = "float32",
@@ -731,7 +731,7 @@ def write_image_OpenImageIO(
731731

732732
def write_image_Imageio(
733733
image: ArrayLike,
734-
path: str | Path,
734+
path: str | PathLike,
735735
bit_depth: Literal[
736736
"uint8", "uint16", "float16", "float32", "float64", "float128"
737737
] = "float32",
@@ -824,7 +824,7 @@ def write_image_Imageio(
824824

825825
def write_image(
826826
image: ArrayLike,
827-
path: str | Path,
827+
path: str | PathLike,
828828
bit_depth: Literal[
829829
"uint8", "uint16", "float16", "float32", "float64", "float128"
830830
] = "float32",

colour/io/luts/__init__.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
import typing
2121

2222
if typing.TYPE_CHECKING:
23-
from pathlib import Path
24-
25-
if typing.TYPE_CHECKING:
26-
from colour.hints import Any, LiteralLUTReadMethod, LiteralLUTWriteMethod
23+
from colour.hints import Any, LiteralLUTReadMethod, LiteralLUTWriteMethod, PathLike
2724

2825
from colour.utilities import (
2926
CanonicalMapping,
@@ -110,7 +107,7 @@
110107

111108

112109
def read_LUT(
113-
path: str | Path,
110+
path: str | PathLike,
114111
method: LiteralLUTReadMethod | str | None = None,
115112
**kwargs: Any,
116113
) -> LUT1D | LUT3x1D | LUT3D | LUTSequence | LUTOperatorMatrix:
@@ -259,7 +256,7 @@ def read_LUT(
259256

260257
def write_LUT(
261258
LUT: LUT1D | LUT3x1D | LUT3D | LUTSequence | LUTOperatorMatrix,
262-
path: str | Path,
259+
path: str | PathLike,
263260
decimals: int = 7,
264261
method: LiteralLUTWriteMethod | str | None = None,
265262
**kwargs: Any,

colour/io/luts/cinespace_csp.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919

2020
import typing
2121

22-
if typing.TYPE_CHECKING:
23-
from pathlib import Path
24-
2522
import numpy as np
2623

2724
if typing.TYPE_CHECKING:
28-
from colour.hints import ArrayLike, List, NDArrayFloat, NDArrayInt
25+
from colour.hints import ArrayLike, List, NDArrayFloat, NDArrayInt, PathLike
2926

3027
from colour.io.luts import LUT1D, LUT3D, LUT3x1D, LUTSequence
3128
from colour.utilities import (
@@ -50,7 +47,7 @@
5047
]
5148

5249

53-
def read_LUT_Cinespace(path: str | Path) -> LUT3x1D | LUT3D | LUTSequence:
50+
def read_LUT_Cinespace(path: str | PathLike) -> LUT3x1D | LUT3D | LUTSequence:
5451
"""
5552
Read given *Cinespace* *.csp* *LUT* file.
5653
@@ -247,7 +244,7 @@ def _parse_table_section(lines: list[str]) -> tuple[NDArrayInt, NDArrayFloat]:
247244

248245

249246
def write_LUT_Cinespace(
250-
LUT: LUT1D | LUT3x1D | LUT3D | LUTSequence, path: str | Path, decimals: int = 7
247+
LUT: LUT1D | LUT3x1D | LUT3D | LUTSequence, path: str | PathLike, decimals: int = 7
251248
) -> bool:
252249
"""
253250
Write given *LUT* to given *Cinespace* *.csp* *LUT* file.

colour/io/luts/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import typing
1414

1515
if typing.TYPE_CHECKING:
16-
from pathlib import Path
16+
from colour.hints import PathLike
1717

1818
__author__ = "Colour Developers"
1919
__copyright__ = "Copyright 2013 Colour Developers"
@@ -27,7 +27,7 @@
2727
]
2828

2929

30-
def path_to_title(path: str | Path) -> str:
30+
def path_to_title(path: str | PathLike) -> str:
3131
"""
3232
Convert given file path to title.
3333

colour/io/luts/iridas_cube.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
import typing
2020

21-
if typing.TYPE_CHECKING:
22-
from pathlib import Path
23-
2421
import numpy as np
2522

23+
if typing.TYPE_CHECKING:
24+
from colour.hints import PathLike
25+
2626
from colour.io.luts import LUT1D, LUT3D, LUT3x1D, LUTSequence
2727
from colour.io.luts.common import path_to_title
2828
from colour.utilities import (
@@ -46,7 +46,7 @@
4646
]
4747

4848

49-
def read_LUT_IridasCube(path: str | Path) -> LUT3x1D | LUT3D:
49+
def read_LUT_IridasCube(path: str | PathLike) -> LUT3x1D | LUT3D:
5050
"""
5151
Read given *Iridas* *.cube* *LUT* file.
5252
@@ -187,7 +187,7 @@ def read_LUT_IridasCube(path: str | Path) -> LUT3x1D | LUT3D:
187187

188188

189189
def write_LUT_IridasCube(
190-
LUT: LUT1D | LUT3x1D | LUT3D | LUTSequence, path: str | Path, decimals: int = 7
190+
LUT: LUT1D | LUT3x1D | LUT3D | LUTSequence, path: str | PathLike, decimals: int = 7
191191
) -> bool:
192192
"""
193193
Write given *LUT* to given *Iridas* *.cube* *LUT* file.

colour/io/luts/resolve_cube.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
import typing
2121

22-
if typing.TYPE_CHECKING:
23-
from pathlib import Path
24-
2522
import numpy as np
2623

24+
if typing.TYPE_CHECKING:
25+
from colour.hints import PathLike
26+
2727
from colour.io.luts import LUT1D, LUT3D, LUT3x1D, LUTSequence
2828
from colour.io.luts.common import path_to_title
2929
from colour.utilities import (
@@ -47,7 +47,7 @@
4747
]
4848

4949

50-
def read_LUT_ResolveCube(path: str | Path) -> LUT3x1D | LUT3D | LUTSequence:
50+
def read_LUT_ResolveCube(path: str | PathLike) -> LUT3x1D | LUT3D | LUTSequence:
5151
"""
5252
Read given *Resolve* *.cube* *LUT* file.
5353
@@ -241,7 +241,7 @@ def read_LUT_ResolveCube(path: str | Path) -> LUT3x1D | LUT3D | LUTSequence:
241241

242242
def write_LUT_ResolveCube(
243243
LUT: LUT1D | LUT3x1D | LUT3D | LUTSequence,
244-
path: str | Path,
244+
path: str | PathLike,
245245
decimals: int = 7,
246246
) -> bool:
247247
"""

colour/io/luts/sony_spi1d.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
import typing
1515

16-
if typing.TYPE_CHECKING:
17-
from pathlib import Path
18-
1916
import numpy as np
2017

18+
if typing.TYPE_CHECKING:
19+
from colour.hints import PathLike
20+
2121
from colour.io.luts import LUT1D, LUT3x1D, LUTSequence
2222
from colour.io.luts.common import path_to_title
2323
from colour.utilities import (
@@ -41,7 +41,7 @@
4141
]
4242

4343

44-
def read_LUT_SonySPI1D(path: str | Path) -> LUT1D | LUT3x1D:
44+
def read_LUT_SonySPI1D(path: str | PathLike) -> LUT1D | LUT3x1D:
4545
"""
4646
Read given *Sony* *.spi1d* *LUT* file.
4747
@@ -159,7 +159,7 @@ def read_LUT_SonySPI1D(path: str | Path) -> LUT1D | LUT3x1D:
159159

160160

161161
def write_LUT_SonySPI1D(
162-
LUT: LUT1D | LUT3x1D | LUTSequence, path: str | Path, decimals: int = 7
162+
LUT: LUT1D | LUT3x1D | LUTSequence, path: str | PathLike, decimals: int = 7
163163
) -> bool:
164164
"""
165165
Write given *LUT* to given *Sony* *.spi1d* *LUT* file.

0 commit comments

Comments
 (0)