Skip to content

Commit 9708f0d

Browse files
committed
Add docstrings to __eq__, __hash__, and __repr__ methods in ShadowRoot class for clarity
1 parent 5151b8d commit 9708f0d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

py/selenium/webdriver/remote/shadowroot.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,31 @@ def __init__(self, session, id_) -> None:
3030
self._id = id_
3131

3232
def __eq__(self, other_shadowroot) -> bool:
33+
"""Compare this ShadowRoot with another ShadowRoot for equality.
34+
35+
Args:
36+
other_shadowroot: The other ShadowRoot object to compare with.
37+
38+
Returns:
39+
True if both ShadowRoot objects have the same ID, False otherwise.
40+
"""
3341
return self._id == other_shadowroot._id
3442

3543
def __hash__(self) -> int:
44+
"""Return the hash code for this ShadowRoot.
45+
46+
Returns:
47+
The integer hash of the ShadowRoot ID.
48+
"""
3649
return int(md5_hash(self._id.encode("utf-8")).hexdigest(), 16)
3750

3851
def __repr__(self) -> str:
52+
"""Return a string representation of the ShadowRoot object.
53+
54+
Returns:
55+
A string representation showing the module, class name, session ID,
56+
and ShadowRoot element ID.
57+
"""
3958
return '<{0.__module__}.{0.__name__} (session="{1}", element="{2}")>'.format(
4059
type(self), self.session.session_id, self._id
4160
)

0 commit comments

Comments
 (0)