Skip to content

Commit 318cb52

Browse files
committed
fix: fix BadStr badness
1 parent 32c7e44 commit 318cb52

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

tests/test_correlation.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Tests for correlation ID generation."""
22

3-
from typing import final, override
3+
from typing import cast, override
44

55
import pytest
66

@@ -49,19 +49,22 @@ def test_hash_correlation_provider_with_invalid_input() -> None:
4949
provider = HashCorrelationProvider()
5050

5151
# Create an object that raises an exception when converted to string
52-
@final
53-
class BadStr(str):
54-
__slots__ = ()
55-
52+
class BadStr:
5653
@override
5754
def __str__(self) -> str:
5855
error_msg = "Cannot convert to string"
5956
raise ValueError(error_msg)
6057

58+
string = BadStr()
59+
60+
# do bad stuff to get around type issues
61+
string = cast("object", string)
62+
string = cast("str", string)
63+
6164
with pytest.raises(
6265
ValueError, match="Failed to generate correlation ID from input"
6366
):
64-
_ = provider.get_correlation_id(BadStr())
67+
_ = provider.get_correlation_id(string)
6568

6669

6770
def test_hash_correlation_provider_consistency() -> None:

0 commit comments

Comments
 (0)