Skip to content

Commit 8cb28f1

Browse files
committed
style: Fix long lines in comments
why: Ensure all files pass ruff linting rules what: - Break long comments into multiple lines in frozen_dataclass docstring - Split long comment lines in test_frozen_dataclass.py
1 parent eba88a7 commit 8cb28f1

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/libtmux/_internal/frozen_dataclass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ def frozen_dataclass(cls: type[_T]) -> type[_T]:
102102
Traceback (most recent call last):
103103
...
104104
AttributeError: SecureData is immutable: cannot modify field 'secret'
105-
>>> # CAUTION: The _frozen attribute can be modified to bypass immutability protection
106-
>>> # This is a known limitation of this implementation
105+
>>> # CAUTION: The _frozen attribute can be modified to bypass immutability
106+
>>> # protection. This is a known limitation of this implementation
107107
>>> data._frozen = False # intentionally bypassing immutability
108108
>>> data.secret = "hacked" # now works because object is no longer frozen
109109
>>> data.secret

tests/_internal/test_frozen_dataclass.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,32 @@ def test_immutability() -> None:
8080
pane_id="pane123", width=80, height=24, captured_content=["Line1"]
8181
)
8282

83-
# Attempting to modify a field should raise AttributeError with precise error message
84-
with pytest.raises(AttributeError, match=r"PaneSnapshot is immutable: cannot modify field 'width'"):
83+
# Attempting to modify a field should raise AttributeError
84+
# with precise error message
85+
with pytest.raises(
86+
AttributeError, match=r"PaneSnapshot is immutable: cannot modify field 'width'"
87+
):
8588
snapshot.width = 200 # type: ignore
8689

87-
# Attempting to add a new field should raise AttributeError with precise error message
88-
with pytest.raises(AttributeError, match=r"PaneSnapshot is immutable: cannot modify field 'new_field'"):
90+
# Attempting to add a new field should raise AttributeError
91+
# with precise error message
92+
with pytest.raises(
93+
AttributeError,
94+
match=r"PaneSnapshot is immutable: cannot modify field 'new_field'",
95+
):
8996
snapshot.new_field = "value" # type: ignore
9097

91-
# Attempting to delete a field should raise AttributeError with precise error message
92-
with pytest.raises(AttributeError, match=r"PaneSnapshot is immutable: cannot delete field 'width'"):
98+
# Attempting to delete a field should raise AttributeError
99+
# with precise error message
100+
with pytest.raises(
101+
AttributeError, match=r"PaneSnapshot is immutable: cannot delete field 'width'"
102+
):
93103
del snapshot.width
94104

95105
# Calling a method that tries to modify state should fail
96-
with pytest.raises(NotImplementedError, match=r"Snapshot is immutable. resize\(\) not allowed."):
106+
with pytest.raises(
107+
NotImplementedError, match=r"Snapshot is immutable. resize\(\) not allowed."
108+
):
97109
snapshot.resize(200, 50)
98110

99111

@@ -188,7 +200,7 @@ def test_bidirectional_references() -> None:
188200

189201
class DimensionTestCase(t.NamedTuple):
190202
"""Test fixture for validating dimensions in PaneSnapshot.
191-
203+
192204
Note: This implementation intentionally allows any dimension values, including
193205
negative or extremely large values. In a real-world application, you might want
194206
to add validation to the class constructor if certain dimension ranges are required.
@@ -287,7 +299,7 @@ def test_frozen_flag(
287299
error_match: str | None,
288300
) -> None:
289301
"""Test behavior when attempting to manipulate the _frozen flag.
290-
302+
291303
Note: We discovered that setting _frozen=False actually allows mutation,
292304
which could be a potential security issue if users know about this behavior.
293305
In a more secure implementation, the _frozen attribute might need additional

0 commit comments

Comments
 (0)