diff --git a/.github/workflows/test_and_version.yml b/.github/workflows/test_and_version.yml index 25a12ea..8a1d092 100644 --- a/.github/workflows/test_and_version.yml +++ b/.github/workflows/test_and_version.yml @@ -28,7 +28,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/pyproject.toml b/pyproject.toml index 782e15b..61630fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "replete" maintainers = [{ name = "Artem Vasenin", email = "vasart169@gmail.com" }] authors = [{ name = "Anton Vasilev" }, { name = "Artem Vasenin" }] readme = "README.md" -requires-python = ">=3.9" +requires-python = ">=3.10" dynamic = ["description", "version"] dependencies = ["coloredlogs", "docstring-parser", "python-dateutil", "xxhash"] @@ -36,7 +36,7 @@ strictParameterNoneValue = false typeCheckingMode = "basic" [tool.ruff] -target-version = "py39" +target-version = "py310" line-length = 120 [tool.ruff.lint] preview = true @@ -45,17 +45,17 @@ fixable = ["ALL"] ignore = ["A003", "E203", "FIX002", "FURB113", "N817", "PTH123", "RET503", "S113", "TD002", "TD003", "TRY003", "UP007", "UP035"] [tool.ruff.lint.per-file-ignores] "**/__init__.py" = [ - "F401", # Allow unused imports in module files + "F401", # Allow unused imports in module files ] "tests/test_cli.py" = [ - "W291", # Need to ignore it for correct formatting + "W291", # Need to ignore it for correct formatting ] "tests/**/*.py" = [ - "E501", # Test strings can be long - "FBT001", # We don't expect to call the tests - "S101", # Asserts in tests are fine - "T201", # Prints are useful for debugging - "TCH001", - "TCH002", - "TCH003", # Tests don't need to be super performant, prefer simpler code + "E501", # Test strings can be long + "FBT001", # We don't expect to call the tests + "S101", # Asserts in tests are fine + "T201", # Prints are useful for debugging + "TCH001", + "TCH002", + "TCH003", # Tests don't need to be super performant, prefer simpler code ] diff --git a/replete/consistent_hash.py b/replete/consistent_hash.py index 5f2a7d3..cfc9ef4 100644 --- a/replete/consistent_hash.py +++ b/replete/consistent_hash.py @@ -63,7 +63,7 @@ def consistent_hash_raw_update( param_items = sorted((str(key), value) for key, value in param.items()) hasher.update(b"\x04") consistent_hash_raw_update(hasher, param_items) - elif param_type is list or param_type is tuple or isinstance(param, (list, tuple)): + elif param_type is list or param_type is tuple or isinstance(param, list | tuple): hasher.update(b"\x05") consistent_hash_raw_update(hasher, param) else: @@ -94,7 +94,7 @@ def _normalize(value: Any) -> Any: chashmeth = getattr(value, "consistent_hash", None) if chashmeth is not None and getattr(chashmeth, "__self__", None) is not None: return chashmeth() # Note: makes the result type-independent. - if value_type is list or value_type is tuple or isinstance(value, (list, tuple)): + if value_type is list or value_type is tuple or isinstance(value, list | tuple): return [_normalize(subvalue) for subvalue in value] if value_type is dict or isinstance(value, collections.abc.Mapping): res_value = [(str(subkey), _normalize(subvalue)) for subkey, subvalue in value.items()] diff --git a/replete/utils.py b/replete/utils.py index 8e8487d..943b2f9 100644 --- a/replete/utils.py +++ b/replete/utils.py @@ -156,7 +156,7 @@ def func_with_idx(idx, *args, **kwargs) -> tuple[int, Any]: raise with futures.ThreadPoolExecutor(max_workers=max_workers) as executor: - idx_args_gen = enumerate(zip(args_list, kwargs_list)) + idx_args_gen = enumerate(zip(args_list, kwargs_list, strict=False)) results = [executor.submit(func_with_idx, idx, *args, **kwargs) for idx, (args, kwargs) in idx_args_gen] cache_results = {} diff --git a/tests/test_consistent_hash.py b/tests/test_consistent_hash.py index 159e08e..99fa026 100644 --- a/tests/test_consistent_hash.py +++ b/tests/test_consistent_hash.py @@ -57,7 +57,7 @@ def consistent_hash_ref(*args: Any, **kwargs: Any) -> int: for param in params: if isinstance(param, Mapping): hashes.append(consistent_hash(**{str(key): value for key, value in param.items()})) - elif isinstance(param, (list, tuple)): + elif isinstance(param, list | tuple): hashes.append(consistent_hash(*param)) else: hashes.append(repr(param)) @@ -77,7 +77,7 @@ def consistent_hash_ref2_raw(args: Sequence[Any] = (), kwargs: dict[str, Any] | elif isinstance(param, Mapping): rec = consistent_hash_ref2_raw((), {str(key): value for key, value in param.items()}) hasher.update(rec.digest()) - elif isinstance(param, (list, tuple)): + elif isinstance(param, list | tuple): rec = consistent_hash_ref2_raw(param) hasher.update(rec.digest()) else: diff --git a/tests/test_utils.py b/tests/test_utils.py index a361db7..36ac3c1 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -48,7 +48,7 @@ def test_futures_processing(futures_processing_test_vars): with Timer() as timer: result = set(futures_processing(func, args, kwargs)) # type: ignore - simple_results = {func(*a, **kw) for a, kw in zip(args, kwargs)} # type: ignore + simple_results = {func(*a, **kw) for a, kw in zip(args, kwargs, strict=False)} # type: ignore assert result == simple_results assert timer.time < wait_time * 3 @@ -60,7 +60,7 @@ def test_futures_processing_in_order(futures_processing_test_vars): with Timer() as timer: result = list(futures_processing(func, args, kwargs, in_order=True)) # type: ignore - simple_results = [func(*a, **kw) for a, kw in zip(args, kwargs)] # type: ignore + simple_results = [func(*a, **kw) for a, kw in zip(args, kwargs, strict=False)] # type: ignore assert result == simple_results assert timer.time < wait_time * 3