From c811b560c30dc23053e01d859463cd6b474f5f3e Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 14 Dec 2024 20:08:30 +1300 Subject: [PATCH] Update `.pre-commit-config.yaml` file. --- .pre-commit-config.yaml | 19 ++- colour_datasets/__init__.py | 4 +- colour_datasets/loaders/asano2015.py | 2 +- colour_datasets/loaders/dyer2017.py | 136 ++++++++++-------- colour_datasets/loaders/ebner1998.py | 16 +-- .../loaders/tests/test_asano2015.py | 1 - .../loaders/tests/test_dyer2017.py | 1 - .../loaders/tests/test_hung1995.py | 1 - .../loaders/tests/test_jakob2019.py | 1 - .../loaders/tests/test_jiang2013.py | 1 - .../loaders/tests/test_karge2015.py | 1 - .../loaders/tests/test_labsphere2019.py | 1 - colour_datasets/loaders/tests/test_luo1997.py | 1 - colour_datasets/loaders/tests/test_luo1999.py | 1 - .../loaders/tests/test_solomotav2023.py | 1 - .../loaders/tests/test_winquist2022.py | 1 - .../loaders/tests/test_xrite2016.py | 1 - .../loaders/tests/test_zhao2009.py | 1 - colour_datasets/records/tests/test_zenodo.py | 4 +- colour_datasets/records/zenodo.py | 2 +- colour_datasets/utilities/common.py | 9 +- .../utilities/tests/test_common.py | 2 +- docs/conf.py | 2 +- pyproject.toml | 5 +- tasks.py | 4 +- 25 files changed, 105 insertions(+), 113 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b50f8a..c52c83d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: "v4.5.0" + rev: "v5.0.0" hooks: - id: check-added-large-files - id: check-case-conflict @@ -15,32 +15,29 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.3.0 hooks: - id: codespell - args: ["--ignore-words-list=exitance,seperately"] + args: + ["--ignore-words-list=assertIn,exitance,seperately,socio-economic"] exclude: "BIBLIOGRAPHY.bib|CONTRIBUTORS.rst" - - repo: https://github.com/ikamensh/flynt - rev: "1.0.1" - hooks: - - id: flynt - args: [--verbose] - repo: https://github.com/PyCQA/isort rev: "5.13.2" hooks: - id: isort - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.14" + rev: "v0.8.2" hooks: - id: ruff-format - id: ruff + args: [--fix] - repo: https://github.com/adamchainz/blacken-docs - rev: 1.16.0 + rev: 1.19.1 hooks: - id: blacken-docs language_version: python3.10 - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.1.0" + rev: "v4.0.0-alpha.8" hooks: - id: prettier - repo: https://github.com/pre-commit/pygrep-hooks diff --git a/colour_datasets/__init__.py b/colour_datasets/__init__.py index b621187..1b4ef01 100644 --- a/colour_datasets/__init__.py +++ b/colour_datasets/__init__.py @@ -56,8 +56,8 @@ try: _version = ( - subprocess.check_output( - ["git", "describe"], # noqa: S603, S607 + subprocess.check_output( # noqa: S603 + ["git", "describe"], # noqa: S607 cwd=os.path.dirname(__file__), stderr=subprocess.STDOUT, ) diff --git a/colour_datasets/loaders/asano2015.py b/colour_datasets/loaders/asano2015.py index 66b998f..a6d2720 100644 --- a/colour_datasets/loaders/asano2015.py +++ b/colour_datasets/loaders/asano2015.py @@ -74,7 +74,7 @@ class Specification_Asano2015( References ---------- :cite:`Asano2015` - """ # noqa: D405, D407, D410, D411 + """ def __new__( cls, diff --git a/colour_datasets/loaders/dyer2017.py b/colour_datasets/loaders/dyer2017.py index 7f69217..5be60f8 100644 --- a/colour_datasets/loaders/dyer2017.py +++ b/colour_datasets/loaders/dyer2017.py @@ -564,39 +564,45 @@ def __init__( self.path = path self._header: SpectralDataHeader_AMPAS = SpectralDataHeader_AMPAS() self.header = optional(header, self._header) - self._units: Literal[ - "absorptance", - "exitance", - "flux", - "intensity", - "irradiance", - "radiance", - "reflectance", - "relative", - "transmittance", - "R-Factor", - "T-Factor", - "other", - ] | None = None + self._units: ( + Literal[ + "absorptance", + "exitance", + "flux", + "intensity", + "irradiance", + "radiance", + "reflectance", + "relative", + "transmittance", + "R-Factor", + "T-Factor", + "other", + ] + | None + ) = None self.units = units - self._reflection_geometry: Literal[ - "di:8", - "de:8", - "8:di", - "8:de", - "d:d", - "d:0", - "45a:0", - "45c:0", - "0:45a", - "45x:0", - "0:45x", - "other", - ] | None = None + self._reflection_geometry: ( + Literal[ + "di:8", + "de:8", + "8:di", + "8:de", + "d:d", + "d:0", + "45a:0", + "45c:0", + "0:45a", + "45x:0", + "0:45x", + "other", + ] + | None + ) = None self.reflection_geometry = reflection_geometry - self._transmission_geometry: Literal[ - "0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other" - ] | None = None + self._transmission_geometry: ( + Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] | None + ) = None self.transmission_geometry = transmission_geometry self._bandwidth_FWHM: float | None = None self.bandwidth_FWHM = bandwidth_FWHM @@ -1062,39 +1068,45 @@ def __init__( self.path = path self._header: SpectralDataHeader_AMPAS = SpectralDataHeader_AMPAS() self.header = optional(header, self._header) - self._units: Literal[ - "absorptance", - "exitance", - "flux", - "intensity", - "irradiance", - "radiance", - "reflectance", - "relative", - "transmittance", - "R-Factor", - "T-Factor", - "other", - ] | None = None + self._units: ( + Literal[ + "absorptance", + "exitance", + "flux", + "intensity", + "irradiance", + "radiance", + "reflectance", + "relative", + "transmittance", + "R-Factor", + "T-Factor", + "other", + ] + | None + ) = None self.units = units - self._reflection_geometry: Literal[ - "di:8", - "de:8", - "8:di", - "8:de", - "d:d", - "d:0", - "45a:0", - "45c:0", - "0:45a", - "45x:0", - "0:45x", - "other", - ] | None = None + self._reflection_geometry: ( + Literal[ + "di:8", + "de:8", + "8:di", + "8:de", + "d:d", + "d:0", + "45a:0", + "45c:0", + "0:45a", + "45x:0", + "0:45x", + "other", + ] + | None + ) = None self.reflection_geometry = reflection_geometry - self._transmission_geometry: Literal[ - "0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other" - ] | None = None + self._transmission_geometry: ( + Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] | None + ) = None self.transmission_geometry = transmission_geometry self._bandwidth_FWHM: float | None = None self.bandwidth_FWHM = bandwidth_FWHM diff --git a/colour_datasets/loaders/ebner1998.py b/colour_datasets/loaders/ebner1998.py index 2552ea0..a52d906 100644 --- a/colour_datasets/loaders/ebner1998.py +++ b/colour_datasets/loaders/ebner1998.py @@ -148,14 +148,14 @@ def _parse_float_values(data: str) -> NDArrayFloat: attribute, value = line.split("\t", 1) hue, data = int(attribute), _parse_float_values(value) - self._content["Constant Perceived-Hue Data"][ - hue - ] = ConstantPerceivedHueColourMatches_Ebner1998( - f"Reference Hue Angle - {hue}", - XYZ_r, - data[0], - data[1:], - {"h": hue}, + self._content["Constant Perceived-Hue Data"][hue] = ( + ConstantPerceivedHueColourMatches_Ebner1998( + f"Reference Hue Angle - {hue}", + XYZ_r, + data[0], + data[1:], + {"h": hue}, + ) ) return self._content diff --git a/colour_datasets/loaders/tests/test_asano2015.py b/colour_datasets/loaders/tests/test_asano2015.py index eb48800..8f3ff22 100644 --- a/colour_datasets/loaders/tests/test_asano2015.py +++ b/colour_datasets/loaders/tests/test_asano2015.py @@ -1,6 +1,5 @@ """Define the unit tests for the :mod:`colour_datasets.loaders.asano2015` module.""" - import numpy as np from colour import SpectralShape from colour.constants import TOLERANCE_ABSOLUTE_TESTS diff --git a/colour_datasets/loaders/tests/test_dyer2017.py b/colour_datasets/loaders/tests/test_dyer2017.py index 7708e53..e1d8761 100644 --- a/colour_datasets/loaders/tests/test_dyer2017.py +++ b/colour_datasets/loaders/tests/test_dyer2017.py @@ -1,6 +1,5 @@ """Define the unit tests for the :mod:`colour_datasets.loaders.dyer2017` module.""" - import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS diff --git a/colour_datasets/loaders/tests/test_hung1995.py b/colour_datasets/loaders/tests/test_hung1995.py index a976cae..850f9e6 100644 --- a/colour_datasets/loaders/tests/test_hung1995.py +++ b/colour_datasets/loaders/tests/test_hung1995.py @@ -1,6 +1,5 @@ """Define the unit tests for the :mod:`colour_datasets.loaders.hung1995` module.""" - import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS diff --git a/colour_datasets/loaders/tests/test_jakob2019.py b/colour_datasets/loaders/tests/test_jakob2019.py index 9e124ec..7fa1900 100644 --- a/colour_datasets/loaders/tests/test_jakob2019.py +++ b/colour_datasets/loaders/tests/test_jakob2019.py @@ -1,6 +1,5 @@ """Define the unit tests for the :mod:`colour_datasets.loaders.jakob2019` module.""" - from colour_datasets.loaders import DatasetLoader_Jakob2019, build_Jakob2019 __author__ = "Colour Developers" diff --git a/colour_datasets/loaders/tests/test_jiang2013.py b/colour_datasets/loaders/tests/test_jiang2013.py index e7cc64e..f3a632c 100644 --- a/colour_datasets/loaders/tests/test_jiang2013.py +++ b/colour_datasets/loaders/tests/test_jiang2013.py @@ -1,6 +1,5 @@ """Define the unit tests for the :mod:`colour_datasets.loaders.jiang2013` module.""" - from colour import SpectralShape from colour_datasets.loaders import DatasetLoader_Jiang2013, build_Jiang2013 diff --git a/colour_datasets/loaders/tests/test_karge2015.py b/colour_datasets/loaders/tests/test_karge2015.py index cb43de6..07669fa 100644 --- a/colour_datasets/loaders/tests/test_karge2015.py +++ b/colour_datasets/loaders/tests/test_karge2015.py @@ -1,6 +1,5 @@ """Define the unit tests for the :mod:`colour_datasets.loaders.karge2015` module.""" - from colour import SpectralShape from colour_datasets.loaders import DatasetLoader_Karge2015, build_Karge2015 diff --git a/colour_datasets/loaders/tests/test_labsphere2019.py b/colour_datasets/loaders/tests/test_labsphere2019.py index 18b7d32..0fbf313 100644 --- a/colour_datasets/loaders/tests/test_labsphere2019.py +++ b/colour_datasets/loaders/tests/test_labsphere2019.py @@ -3,7 +3,6 @@ module. """ - from colour import SpectralShape from colour_datasets.loaders import ( diff --git a/colour_datasets/loaders/tests/test_luo1997.py b/colour_datasets/loaders/tests/test_luo1997.py index f352fac..c6ba504 100644 --- a/colour_datasets/loaders/tests/test_luo1997.py +++ b/colour_datasets/loaders/tests/test_luo1997.py @@ -1,6 +1,5 @@ """Define the unit tests for the :mod:`colour_datasets.loaders.luo1997` module.""" - import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS diff --git a/colour_datasets/loaders/tests/test_luo1999.py b/colour_datasets/loaders/tests/test_luo1999.py index 93b674c..80135ea 100644 --- a/colour_datasets/loaders/tests/test_luo1999.py +++ b/colour_datasets/loaders/tests/test_luo1999.py @@ -1,6 +1,5 @@ """Define the unit tests for the :mod:`colour_datasets.loaders.luo1999` module.""" - import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS diff --git a/colour_datasets/loaders/tests/test_solomotav2023.py b/colour_datasets/loaders/tests/test_solomotav2023.py index af7d72b..0aba835 100644 --- a/colour_datasets/loaders/tests/test_solomotav2023.py +++ b/colour_datasets/loaders/tests/test_solomotav2023.py @@ -1,6 +1,5 @@ """Define the unit tests for the :mod:`colour_datasets.loaders.solomotav2023` module.""" - from colour import SpectralShape from colour_datasets.loaders import ( diff --git a/colour_datasets/loaders/tests/test_winquist2022.py b/colour_datasets/loaders/tests/test_winquist2022.py index 155e752..5c05aab 100644 --- a/colour_datasets/loaders/tests/test_winquist2022.py +++ b/colour_datasets/loaders/tests/test_winquist2022.py @@ -3,7 +3,6 @@ module. """ - import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS diff --git a/colour_datasets/loaders/tests/test_xrite2016.py b/colour_datasets/loaders/tests/test_xrite2016.py index 4043f5e..01afa35 100644 --- a/colour_datasets/loaders/tests/test_xrite2016.py +++ b/colour_datasets/loaders/tests/test_xrite2016.py @@ -1,6 +1,5 @@ """Define the unit tests for the :mod:`colour_datasets.loaders.xrite2016` module.""" - from colour.characterisation import ColourChecker from colour_datasets.loaders import DatasetLoader_XRite2016, build_XRite2016 diff --git a/colour_datasets/loaders/tests/test_zhao2009.py b/colour_datasets/loaders/tests/test_zhao2009.py index 43fcb14..fa0b045 100644 --- a/colour_datasets/loaders/tests/test_zhao2009.py +++ b/colour_datasets/loaders/tests/test_zhao2009.py @@ -1,6 +1,5 @@ """Define the unit tests for the :mod:`colour_datasets.loaders.zhao2009` module.""" - from colour import SpectralShape from colour_datasets.loaders import DatasetLoader_Zhao2009, build_Zhao2009 diff --git a/colour_datasets/records/tests/test_zenodo.py b/colour_datasets/records/tests/test_zenodo.py index 16fbd1a..200a328 100644 --- a/colour_datasets/records/tests/test_zenodo.py +++ b/colour_datasets/records/tests/test_zenodo.py @@ -172,7 +172,7 @@ def test__repr__(self): """ self.assertIsInstance( - eval( # noqa: PGH001, S307 + eval( # noqa: S307 repr(self._record), {}, {"Record": Record, "Configuration": Configuration}, @@ -345,7 +345,7 @@ def test__repr__(self): """ self.assertIsInstance( - eval( # noqa: PGH001, S307 + eval( # noqa: S307 repr(self._community), {}, {"Community": Community, "Configuration": Configuration}, diff --git a/colour_datasets/records/zenodo.py b/colour_datasets/records/zenodo.py index bcf01ce..87a616f 100644 --- a/colour_datasets/records/zenodo.py +++ b/colour_datasets/records/zenodo.py @@ -392,7 +392,7 @@ def urls_download(urls: Dict) -> None: try: if use_urls_txt_file and urls_txt: urls = {} - urls_txt_file = tempfile.NamedTemporaryFile(delete=False).name + urls_txt_file = tempfile.NamedTemporaryFile(delete=False).name # noqa: SIM115 url_download( urls_txt["links"]["self"], urls_txt_file, diff --git a/colour_datasets/utilities/common.py b/colour_datasets/utilities/common.py index dc7b0ae..3c0782a 100644 --- a/colour_datasets/utilities/common.py +++ b/colour_datasets/utilities/common.py @@ -48,7 +48,7 @@ def __enter__(self) -> suppress_stdout: """Redirect the standard output upon entering the context manager.""" self._stdout = sys.stdout - sys.stdout = open(os.devnull, "w") # noqa: SIM115 + sys.stdout = open(os.devnull, "w") return self @@ -280,9 +280,10 @@ def unpack_gzipfile( os.makedirs(extraction_directory) try: - with gzip.open(filename) as gzip_file, open( - extraction_path, "wb" - ) as output_file: + with ( + gzip.open(filename) as gzip_file, + open(extraction_path, "wb") as output_file, + ): shutil.copyfileobj(gzip_file, output_file) except Exception as error: print(error) # noqa: T201 diff --git a/colour_datasets/utilities/tests/test_common.py b/colour_datasets/utilities/tests/test_common.py index 669f8f6..5cef05e 100644 --- a/colour_datasets/utilities/tests/test_common.py +++ b/colour_datasets/utilities/tests/test_common.py @@ -66,7 +66,7 @@ class TestUrlDownload: def setup_method(self): """Initialise the common tests attributes.""" - self._temporary_file = tempfile.NamedTemporaryFile(delete=False).name + self._temporary_file = tempfile.NamedTemporaryFile(delete=False).name # noqa: SIM115 def teardown_method(self): """After tests actions.""" diff --git a/docs/conf.py b/docs/conf.py index 8964aa4..7e5a527 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,7 +9,7 @@ sys.path.append(str(Path(__file__).parent.parent)) -import colour_datasets as package # noqa: E402 +import colour_datasets as package basename = re.sub("_(\\w)", lambda x: x.group(1).upper(), package.__name__.title()) diff --git a/pyproject.toml b/pyproject.toml index f8942e9..afc92bf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,12 +100,9 @@ build-backend = "hatchling.build" packages = [ "colour_datasets" ] [tool.codespell] -ignore-words-list = "exitance,seperately" +ignore-words-list = "assertIn,exitance,seperately,socio-economic" skip = "BIBLIOGRAPHY.bib,CONTRIBUTORS.rst" -[tool.flynt] -line_length=999 - [tool.isort] ensure_newline_before_comments = true force_grid_wrap = 0 diff --git a/tasks.py b/tasks.py index 8442958..c1875e0 100644 --- a/tasks.py +++ b/tasks.py @@ -349,9 +349,7 @@ def virtualise(ctx: Context, tests: bool = True): ctx.run(f"mv {PYPI_ARCHIVE_NAME}-{APPLICATION_VERSION} {unique_name}") ctx.run(f"rm -rf {unique_name}/{PYTHON_PACKAGE_NAME}/resources") ctx.run( - "ln -s ../../../{0}/resources {1}/{0}".format( - PYTHON_PACKAGE_NAME, unique_name - ) + f"ln -s ../../../{PYTHON_PACKAGE_NAME}/resources {unique_name}/{PYTHON_PACKAGE_NAME}" # noqa: E501 ) with ctx.cd(unique_name):