Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.23.0
rev: v9.26.0
hooks:
- id: commitlint
language_version: 20.17.0
stages:
- commit-msg
additional_dependencies: ['conventional-changelog-conventionalcommits']
additional_dependencies: ['conventional-changelog-conventionalcommits@4.6.3']
- repo: https://github.com/pycqa/isort
rev: 7.0.0
rev: 9.0.0a3
hooks:
- id: isort
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.12.0
rev: 26.5.1
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
rev: v2.4.2
hooks:
- id: codespell
args: ["-x", ".codespellignorelines"]
Expand Down
3 changes: 2 additions & 1 deletion luigi_tools/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

"""This module provides some specific luigi parameters."""

import collections.abc
import dataclasses
import typing
Expand Down Expand Up @@ -111,7 +112,7 @@ def __init__(self, cls_type, *args, **kwargs):
self._cls_type = cls_type
super().__init__(*args, **kwargs)

def normalize(self, value):
def normalize(self, value): # pylint: disable=arguments-renamed
"""Normalize the given value to a dataclass initialized object."""
if isinstance(value, self._cls_type):
value = dataclasses.asdict(value)
Expand Down
1 change: 1 addition & 0 deletions luigi_tools/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

"""This module provides some specific luigi targets."""

from pathlib import Path

import luigi
Expand Down
5 changes: 5 additions & 0 deletions luigi_tools/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

"""This module provides some specific luigi tasks and associated tools."""

import logging
import types
from copy import deepcopy
Expand Down Expand Up @@ -276,6 +277,10 @@ def __call__(self, task_that_inherits):

# Add it to the inheriting task with new default values
setattr(task_that_inherits, param_name, new_param)
# Luigi 3.8+ parameters are descriptors. Class decorators run after class
# creation, so Python does not call __set_name__ for these copied parameters.
set_name = getattr(new_param, "__set_name__", lambda *_args: None)
set_name(task_that_inherits, param_name)

# Do not emit warning because of wrong type
def _warn_on_wrong_global_param_type(_self, global_param_name, global_param_value):
Expand Down
1 change: 1 addition & 0 deletions luigi_tools/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

"""This module provides some functions to work with luigi tasks."""

import configparser
import logging
import os
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ line_length = 100
force_single_line = true

[tool.pytest.ini_options]
addopts = [
"--code-highlight=no",
]
testpaths = [
"tests",
]
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

from pathlib import Path

from setuptools import find_namespace_packages
from setuptools import setup
from setuptools import find_namespace_packages # pylint: disable=import-error
from setuptools import setup # pylint: disable=import-error

reqs = [
"luigi>=3.1",
Expand All @@ -28,7 +28,7 @@
doc_reqs = [
"docutils<0.21", # Temporary fix for m2r2
"m2r2",
"sphinx",
"sphinx>=6.2",
"sphinx-bluebrain-theme",
]

Expand Down Expand Up @@ -60,7 +60,7 @@
install_requires=reqs,
extras_require={
"docs": doc_reqs,
"graphviz": ["graphviz"],
"graphviz": ["graphviz>=0.20"],
"test": test_reqs,
},
include_package_data=True,
Expand Down
20 changes: 4 additions & 16 deletions tests/test_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,33 +1135,21 @@ def output(self):
return luigi.LocalTarget("not_existing_file")

# Test with values from config
with set_luigi_config(
{
"TaskDataClassParameter": {
"a": """{
with set_luigi_config({"TaskDataClassParameter": {"a": """{
"a": {"a": 1, "b": "2"},
"b": {"c": 3.0, "d": 4},
"c": {"e": 5, "f": 6},
"d": {"7": 8.0, "9": 10.0}
}"""
}
}
):
}"""}}):
assert luigi.build([TaskDataClassParameter()], local_scheduler=True)

# Parsing fails with integer keys
with set_luigi_config(
{
"TaskDataClassParameter": {
"a": """{
with set_luigi_config({"TaskDataClassParameter": {"a": """{
"a": {"a": 1, "b": "2"},
"b": {"c": 3.0, "d": 4},
"c": {"e": 5, "f": 6},
"d": {7: 8.0, 9: 10.0}
}"""
}
}
):
}"""}}):
with pytest.raises(ValueError):
luigi.build([TaskDataClassParameter()], local_scheduler=True)

Expand Down
1 change: 1 addition & 0 deletions tests/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

"""A few helpers for luigi-tools test suite."""

from pathlib import Path


Expand Down
13 changes: 9 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ commands =
[testenv:min_versions]
basepython = python3.10
deps =
Requirements-Builder
uv
allowlist_externals = uv
commands_pre =
requirements-builder --level=min --extras=test -o {envtmpdir}/requirements_min.txt setup.py
pip install -r {envtmpdir}/requirements_min.txt
pip freeze
uv pip compile \
--resolution lowest-direct \
--all-extras \
--output-file {envtmpdir}/requirements_min.txt \
pyproject.toml
uv pip install --no-cache -r {envtmpdir}/requirements_min.txt
uv pip freeze

[testenv:lint]
basepython = python3.10
Expand Down
Loading