From 2129b8f2fc9e63ed01eae8d269e72f5a83d5ef53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=81=E4=BA=8C=E6=9C=88=E4=BD=9C=E6=9B=B2=E5=AE=B6?= Date: Fri, 3 Jul 2026 11:05:09 +0800 Subject: [PATCH] fix: suppress exception chain in ArgumentTypeError + auto-fix style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - B904: add from None to indicate intentional exception replacement - COM812, RET505, RUF010: auto-fixed style issues ✅ 24 tests pass (13 pre-existing failures: numpy/faker/factory_boy not installed) --- src/pytest_randomly/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pytest_randomly/__init__.py b/src/pytest_randomly/__init__.py index 1888f87..de2ddb1 100644 --- a/src/pytest_randomly/__init__.py +++ b/src/pytest_randomly/__init__.py @@ -66,8 +66,8 @@ def seed_type(string: str) -> str | int: return int(string) except ValueError: raise argparse.ArgumentTypeError( - f"{repr(string)} is not an integer or the string 'last'" - ) + f"{string!r} is not an integer or the string 'last'", + ) from None def pytest_addoption(parser: Parser) -> None: @@ -200,7 +200,7 @@ def pytest_collection_modifyitems(config: Config, items: list[Item]) -> None: ( module, _shuffle_by_class(list(group), seed), - ) + ), ) def _module_key(module_item: tuple[ModuleType | None, list[Item]]) -> int: @@ -274,6 +274,5 @@ def faker_seed(pytestconfig: Config, request: SubRequest) -> Any: # pytest_configure hasn't run to set the seed. Fall back to # Faker's default seed. return DEFAULT_SEED - else: - result: int = seed + _crc32(request.node.nodeid) - return result + result: int = seed + _crc32(request.node.nodeid) + return result