From 2e76f334c6332d1744259c7cb1de22f39c9c3c60 Mon Sep 17 00:00:00 2001 From: Rupert Swarbrick Date: Thu, 21 May 2026 09:55:26 +0100 Subject: [PATCH] docs: Improve documentation comment for testplan.Element.has_tags This was partly motivated by the fact I couldn't immediately see whether the test was an AND or an OR. Signed-off-by: Rupert Swarbrick --- src/dvsim/testplan.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/dvsim/testplan.py b/src/dvsim/testplan.py index dee1a95a..47b11263 100644 --- a/src/dvsim/testplan.py +++ b/src/dvsim/testplan.py @@ -83,18 +83,19 @@ def _validate(self) -> None: msg = f"'tags' key in {self} is not a list." raise ValueError(msg) - def has_tags(self, tags: set) -> bool: - """Checks if the provided tags match the tags originally set. + def has_tags(self, tags: set[str]) -> bool: + """Return true if the element matches the provided tags. - tags is a list of tags that are we are filtering this testpoints with. - Tags may be preceded with `-` to exclude the testpoints that contain - that tag. + The element should match every item in the set of tags. If one of these + elements is preceded with "-", the meaning is negated (so the element + should not match the tag name). - Vacuously returns true if tags is an empty list. - """ - if not tags: - return True + If tags is empty, this will vacuously return true. + + Args: + tags: The set of named tags against which to match. + """ for tag in tags: if tag.startswith("-"): if tag[1:] in self.tags: