Skip to content

Commit e1f4b1a

Browse files
committed
chore(mypy): drop now-unused type:ignore comments
why: mypy flags 10 ignores as unused after stub/type updates upstream; re-tag the 6 that still need attr-defined ignores using explicit error code. what: - frozen_dataclass_sealable.py: drop 3 unused, retag seal/is_sealable - tests/_internal/test_frozen_dataclass.py: drop 7 unused, retag 4 (new_field, _internal_cache ×2, _frozen) with explicit attr-defined code
1 parent 503d386 commit e1f4b1a

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/libtmux/_internal/frozen_dataclass_sealable.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,10 @@ def is_sealable_class_method(cls_param: type) -> bool:
675675
return True
676676

677677
# Add custom methods to the class
678-
cls.__setattr__ = custom_setattr # type: ignore
679-
cls.__delattr__ = custom_delattr # type: ignore
680-
cls.__init__ = custom_init # type: ignore
681-
cls.seal = seal_method # type: ignore
682-
cls.is_sealable = classmethod(is_sealable_class_method) # type: ignore
678+
cls.__setattr__ = custom_setattr
679+
cls.__delattr__ = custom_delattr
680+
cls.__init__ = custom_init
681+
cls.seal = seal_method # type: ignore[attr-defined]
682+
cls.is_sealable = classmethod(is_sealable_class_method) # type: ignore[attr-defined]
683683

684684
return cls

tests/_internal/test_frozen_dataclass.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ def test_immutability() -> None:
8585
with pytest.raises(
8686
AttributeError, match=r"PaneSnapshot is immutable: cannot modify field 'width'"
8787
):
88-
snapshot.width = 200 # type: ignore
88+
snapshot.width = 200
8989

9090
# Attempting to add a new field should raise AttributeError
9191
# with precise error message
9292
with pytest.raises(
9393
AttributeError,
9494
match=r"PaneSnapshot is immutable: cannot modify field 'new_field'",
9595
):
96-
snapshot.new_field = "value" # type: ignore
96+
snapshot.new_field = "value" # type: ignore[attr-defined]
9797

9898
# Attempting to delete a field should raise AttributeError
9999
# with precise error message
@@ -141,8 +141,8 @@ def test_internal_attributes() -> None:
141141
)
142142

143143
# Should be able to set internal attributes
144-
snapshot._internal_cache = {"test": "value"} # type: ignore
145-
assert snapshot._internal_cache == {"test": "value"} # type: ignore
144+
snapshot._internal_cache = {"test": "value"} # type: ignore[attr-defined]
145+
assert snapshot._internal_cache == {"test": "value"} # type: ignore[attr-defined]
146146

147147

148148
def test_nested_mutability_leak() -> None:
@@ -154,7 +154,7 @@ def test_nested_mutability_leak() -> None:
154154

155155
# Can't reassign the field itself
156156
with pytest.raises(AttributeError, match="immutable"):
157-
snapshot.captured_content = ["new"] # type: ignore
157+
snapshot.captured_content = ["new"]
158158

159159
# But we can modify its contents (limitation of Python immutability)
160160
snapshot.captured_content.append("mutated")
@@ -259,7 +259,7 @@ def test_snapshot_dimensions(
259259

260260
# Verify immutability
261261
with pytest.raises(AttributeError, match="immutable"):
262-
pane.width = 100 # type: ignore
262+
pane.width = 100
263263

264264

265265
class FrozenFlagTestCase(t.NamedTuple):
@@ -311,14 +311,14 @@ def test_frozen_flag(
311311

312312
# Attempt to unfreeze if requested
313313
if unfreeze_attempt:
314-
pane._frozen = False # type: ignore
314+
pane._frozen = False # type: ignore[attr-defined]
315315

316316
# Attempt mutation and check if it fails as expected
317317
if expect_mutation_error:
318318
with pytest.raises(AttributeError, match=error_match):
319-
pane.width = 200 # type: ignore
319+
pane.width = 200
320320
else:
321-
pane.width = 200 # type: ignore
321+
pane.width = 200
322322
assert pane.width == 200
323323

324324

@@ -422,7 +422,7 @@ def test_inheritance_behavior(
422422
if mutate_derived:
423423
if expect_derived_error:
424424
with pytest.raises(AttributeError):
425-
derived.width = 100 # type: ignore
425+
derived.width = 100
426426
else:
427-
derived.width = 100 # type: ignore
427+
derived.width = 100
428428
assert derived.width == 100

0 commit comments

Comments
 (0)