Skip to content

Commit 9697745

Browse files
fix circular import
1 parent 179170f commit 9697745

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

i3ipc/con.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import re
22
import sys
3-
from .connection import Connection
43
from .model import Rect, Gaps
54
from . import replies
65
from collections import deque
7-
from typing import Any, cast, Generic, Literal, Optional, TypeVar
6+
from typing import Any, cast, Generic, Literal, Optional, TypeVar, TYPE_CHECKING
7+
8+
if TYPE_CHECKING:
9+
from .connection import Connection
810

911
_Con = TypeVar('_Con', bound='Con')
1012

@@ -121,7 +123,7 @@ class Con(Generic[_Con]):
121123
representation: str
122124
visible: bool
123125

124-
def __init__(self: _Con, data: dict[str, Any], parent: _Con, conn: Connection):
126+
def __init__(self: _Con, data: dict[str, Any], parent: _Con, conn: 'Connection'):
125127
self.ipc_data = data
126128
self._conn = conn
127129
self.parent = parent

i3ipc/events.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
from . import con, connection
1+
from . import con
22
from .replies import BarConfigReply, InputReply
33
from enum import Enum
4-
from typing import Any, Optional
4+
from typing import Any, Optional, TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from .connection import Connection
58

69

710
class IpcBaseEvent:
@@ -66,7 +69,7 @@ class WorkspaceEvent(IpcBaseEvent):
6669
:ivar ipc_data: The raw data from the i3 ipc.
6770
:vartype ipc_data: dict
6871
"""
69-
def __init__(self, data: dict[str, Any], conn: connection.Connection, _Con=con.Con):
72+
def __init__(self, data: dict[str, Any], conn: 'Connection', _Con=con.Con):
7073
self.ipc_data = data
7174
self.change: str = data['change']
7275
self.current: Optional[con.Con] = None
@@ -127,7 +130,7 @@ class WindowEvent(IpcBaseEvent):
127130
:ivar ipc_data: The raw data from the i3 ipc.
128131
:vartype ipc_data: dict
129132
"""
130-
def __init__(self, data: dict[str, Any], conn: connection.Connection, _Con=con.Con):
133+
def __init__(self, data: dict[str, Any], conn: 'Connection', _Con=con.Con):
131134
self.ipc_data = data
132135
self.change: str = data['change']
133136
self.container = _Con(data['container'], None, conn)

0 commit comments

Comments
 (0)