diff --git a/hypothesis-python/.coveragerc b/hypothesis-python/.coveragerc index 21234500ff..7732c620a2 100644 --- a/hypothesis-python/.coveragerc +++ b/hypothesis-python/.coveragerc @@ -28,3 +28,4 @@ exclude_lines = if TYPE_CHECKING: if sys\.version_info if "[\w\.]+" in sys\.modules: + if .+ := sys\.modules\.get\("[\w\.]+"\) diff --git a/hypothesis-python/src/hypothesis/strategies/_internal/types.py b/hypothesis-python/src/hypothesis/strategies/_internal/types.py index d979081415..aba2e457a0 100644 --- a/hypothesis-python/src/hypothesis/strategies/_internal/types.py +++ b/hypothesis-python/src/hypothesis/strategies/_internal/types.py @@ -275,7 +275,7 @@ def is_annotated_type(thing): def get_constraints_filter_map(): - if at := sys.modules.get("annotated_types"): # pragma: no branch + if at := sys.modules.get("annotated_types"): return { # Due to the order of operator.gt/ge/lt/le arguments, order is inversed: at.Gt: lambda constraint: partial(operator.lt, constraint.gt), @@ -290,7 +290,7 @@ def get_constraints_filter_map(): def _get_constraints(args: Tuple[Any, ...]) -> Iterator["at.BaseMetadata"]: - if at := sys.modules.get("annotated_types"): # pragma: no branch + if at := sys.modules.get("annotated_types"): for arg in args: if isinstance(arg, at.BaseMetadata): yield arg