diff options
author | robot-piglet <[email protected]> | 2025-07-27 14:17:18 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2025-07-27 14:28:59 +0300 |
commit | e74d928d0f6c56f02ed72685ff569160f049174a (patch) | |
tree | e5ee17ec64fb59e5be233dee5ec40e23d2b3a324 /contrib/python | |
parent | 0c4a0ee940a18305115568ee3d2831e0fbbe04b1 (diff) |
Intermediate changes
commit_hash:f52a543082ebbfceb217aa858510084bd9a96c06
Diffstat (limited to 'contrib/python')
8 files changed, 42 insertions, 40 deletions
diff --git a/contrib/python/pytest-lazy-fixtures/.dist-info/METADATA b/contrib/python/pytest-lazy-fixtures/.dist-info/METADATA index 8bb4f657de4..932d5acb8a8 100644 --- a/contrib/python/pytest-lazy-fixtures/.dist-info/METADATA +++ b/contrib/python/pytest-lazy-fixtures/.dist-info/METADATA @@ -1,22 +1,15 @@ -Metadata-Version: 2.1 +Metadata-Version: 2.4 Name: pytest-lazy-fixtures -Version: 1.1.4 +Version: 1.2.0 Summary: Allows you to use fixtures in @pytest.mark.parametrize. -Home-page: https://github.com/dev-petrov/pytest-lazy-fixtures -License: MIT -Keywords: tests,pytest,lazy,fixture -Author: Petrov Anton -Author-email: [email protected] -Requires-Python: >=3.8,<4.0 -Classifier: License :: OSI Approved :: MIT License -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.8 -Classifier: Programming Language :: Python :: 3.9 -Classifier: Programming Language :: Python :: 3.10 -Classifier: Programming Language :: Python :: 3.11 -Classifier: Programming Language :: Python :: 3.12 -Requires-Dist: pytest (>=7) +Project-URL: Homepage, https://github.com/dev-petrov/pytest-lazy-fixtures Project-URL: Repository, https://github.com/dev-petrov/pytest-lazy-fixtures +Author-email: Petrov Anton <[email protected]> +License-Expression: MIT +License-File: LICENSE +Keywords: fixture,lazy,pytest,tests +Requires-Python: >=3.8 +Requires-Dist: pytest>=7 Description-Content-Type: text/markdown # pytest-lazy-fixtures @@ -166,4 +159,3 @@ Distributed under the terms of the `MIT` license, `pytest-lazy-fixtures` is free ## Issues If you encounter any problems, please file an issue along with a detailed description. - diff --git a/contrib/python/pytest-lazy-fixtures/.dist-info/entry_points.txt b/contrib/python/pytest-lazy-fixtures/.dist-info/entry_points.txt index 82c4b1f2746..be1d9689fac 100644 --- a/contrib/python/pytest-lazy-fixtures/.dist-info/entry_points.txt +++ b/contrib/python/pytest-lazy-fixtures/.dist-info/entry_points.txt @@ -1,3 +1,2 @@ [pytest11] -pytest_lazyfixture=pytest_lazy_fixtures.plugin - +pytest_lazyfixture = pytest_lazy_fixtures.plugin diff --git a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture.py b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture.py index 28fc00d5299..986ba2639bf 100644 --- a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture.py +++ b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture.py @@ -1,8 +1,11 @@ +from __future__ import annotations + from dataclasses import dataclass from operator import attrgetter -from typing import Optional +from typing import TYPE_CHECKING -import pytest +if TYPE_CHECKING: + import pytest @dataclass @@ -13,7 +16,7 @@ class LazyFixtureWrapper: def fixture_name(self) -> str: return self.name.split(".", maxsplit=1)[0] - def _get_attr(self, fixture) -> Optional[str]: + def _get_attr(self, fixture) -> str | None: splitted = self.name.split(".", maxsplit=1) if len(splitted) == 1: return fixture diff --git a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture_callable.py b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture_callable.py index 3cea3a95501..4e371763f7d 100644 --- a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture_callable.py +++ b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture_callable.py @@ -1,17 +1,20 @@ -from inspect import isfunction -from typing import Callable, Optional, Union +from __future__ import annotations -import pytest +from inspect import isfunction +from typing import TYPE_CHECKING, Callable from .lazy_fixture import LazyFixtureWrapper +if TYPE_CHECKING: + import pytest + class LazyFixtureCallableWrapper(LazyFixtureWrapper): - _func: Optional[Callable] + _func: Callable | None args: tuple kwargs: dict - def __init__(self, callable_or_name: Union[Callable, str], *args, **kwargs): + def __init__(self, callable_or_name: Callable | str, *args, **kwargs): if callable(callable_or_name): self._func = callable_or_name self.name = ( @@ -27,10 +30,12 @@ class LazyFixtureCallableWrapper(LazyFixtureWrapper): func = self._func if func is None: func = self.load_fixture(request) - assert callable(func) + if not callable(func): + msg = "Passed fixture is not callable" + raise TypeError(msg) return func -def lfc(name: Union[Callable, str], *args, **kwargs) -> LazyFixtureCallableWrapper: +def lfc(name: Callable | str, *args, **kwargs) -> LazyFixtureCallableWrapper: """lfc is a lazy fixture callable.""" return LazyFixtureCallableWrapper(name, *args, **kwargs) diff --git a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/loader.py b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/loader.py index d2d39ff4f80..75156ac3a63 100644 --- a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/loader.py +++ b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/loader.py @@ -13,9 +13,9 @@ def load_lazy_fixtures(value, request: pytest.FixtureRequest): if isinstance(value, LazyFixtureWrapper): return value.load_fixture(request) # we need to check exact type - if type(value) is dict: # noqa: E721 - return {load_lazy_fixtures(key, request): load_lazy_fixtures(value, request) for key, value in value.items()} + if type(value) is dict: + return {load_lazy_fixtures(key, request): load_lazy_fixtures(val, request) for key, val in value.items()} # we need to check exact type - elif type(value) in {list, tuple, set}: - return type(value)([load_lazy_fixtures(value, request) for value in value]) + if type(value) in {list, tuple, set}: + return type(value)(load_lazy_fixtures(val, request) for val in value) return value diff --git a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/normalizer.py b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/normalizer.py index f557e4da9ca..699400c084b 100644 --- a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/normalizer.py +++ b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/normalizer.py @@ -1,5 +1,7 @@ +from __future__ import annotations + import copy -from typing import Any, Dict, Iterable, Iterator, List, Tuple +from typing import Any, Iterable, Iterator import pytest @@ -7,7 +9,7 @@ from .lazy_fixture import LazyFixtureWrapper from .lazy_fixture_callable import LazyFixtureCallableWrapper -def _get_fixturenames_closure_and_arg2fixturedefs(fm, metafunc, value) -> Tuple[List[str], Dict[str, Any]]: +def _get_fixturenames_closure_and_arg2fixturedefs(fm, metafunc, value) -> tuple[list[str], dict[str, Any]]: if isinstance(value, LazyFixtureCallableWrapper): extra_fixturenames_args, arg2fixturedefs_args = _get_fixturenames_closure_and_arg2fixturedefs( fm, @@ -33,7 +35,7 @@ def _get_fixturenames_closure_and_arg2fixturedefs(fm, metafunc, value) -> Tuple[ return fixturenames_closure, arg2fixturedefs extra_fixturenames, arg2fixturedefs = [], {} # we need to check exact type - if type(value) is dict: # noqa: E721 + if type(value) is dict: value = list(value.values()) # we need to check exact type if type(value) in {list, tuple, set}: @@ -60,7 +62,7 @@ def _copy_metafunc(metafunc): return copied -def _uniq(values: "Iterable[str]") -> "Iterator[str]": +def _uniq(values: Iterable[str]) -> Iterator[str]: seen = set() for value in values: if value not in seen: diff --git a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/plugin.py b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/plugin.py index f3475e199c8..0c43a845986 100644 --- a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/plugin.py +++ b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/plugin.py @@ -6,15 +6,16 @@ from .normalizer import normalize_metafunc_calls @pytest.hookimpl(tryfirst=True) -def pytest_fixture_setup(fixturedef, request): +def pytest_fixture_setup(fixturedef, request): # noqa: ARG001 val = getattr(request, "param", None) if val is not None: request.param = load_lazy_fixtures(val, request) -def pytest_make_parametrize_id(config, val, argname): +def pytest_make_parametrize_id(config, val, argname): # noqa: ARG001 if isinstance(val, LazyFixtureWrapper): return val.name + return None @pytest.hookimpl(hookwrapper=True) diff --git a/contrib/python/pytest-lazy-fixtures/ya.make b/contrib/python/pytest-lazy-fixtures/ya.make index 2fa4dab7cd0..1d9e3cd718a 100644 --- a/contrib/python/pytest-lazy-fixtures/ya.make +++ b/contrib/python/pytest-lazy-fixtures/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(1.1.4) +VERSION(1.2.0) LICENSE(MIT) |