Coverage for faststream/rabbit/helpers/state.py: 82%

11 statements  

« prev     ^ index     » next       coverage.py v7.17.3, created at 2026-11-17 21:20 +0000

1from dataclasses import dataclass 

2from typing import TYPE_CHECKING, Protocol 

3 

4from faststream.exceptions import IncorrectState 

5 

6if TYPE_CHECKING: 

7 from aio_pika import RobustConnection 

8 

9 

10class ConnectionState(Protocol): 

11 __slots__ = () 

12 

13 @property 

14 def connection(self) -> "RobustConnection": ... 

15 

16 

17class EmptyConnectionState: 

18 __slots__ = () 

19 

20 @property 

21 def connection(self) -> "RobustConnection": 

22 msg = "You should connect broker first." 

23 raise IncorrectState(msg) 

24 

25 

26@dataclass(slots=True) 

27class ConnectedState: 

28 connection: "RobustConnection"