Skip to content

Commit d6dbb08

Browse files
Add __dir__ to BaseAutoMatcher.
1 parent 8cb4735 commit d6dbb08

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/utils/matchers/meta.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ def setter(value):
7171
msg = f"{type(self).__name__} object has no attribute {name}"
7272
raise AttributeError(msg)
7373

74+
def __dir__(self):
75+
dynamic_methods = []
76+
for field_name in self.__domain_class__.__annotations__:
77+
method_base = field_name.rstrip("_") if field_name in {"id", "type"} else field_name
78+
dynamic_methods.extend([f"with_{method_base}", f"and_{method_base}"])
79+
return list(super().__dir__()) + dynamic_methods
80+
7481
@staticmethod
7582
def append_matcher_description(field_matcher: Matcher[Any], field_name: str, description: Description) -> None:
7683
if not isinstance(field_matcher, IsAnything):

0 commit comments

Comments
 (0)