11
11
# License for the specific language governing permissions and limitations
12
12
# under the License.
13
13
import os
14
+ from typing import Optional
14
15
15
16
import clickhouse_driver
16
17
from clickhouse_driver .errors import Error
@@ -45,12 +46,12 @@ class ClickHouseContainer(DbContainer):
45
46
46
47
def __init__ (
47
48
self ,
48
- image = "clickhouse/clickhouse-server:latest" ,
49
- port = 9000 ,
50
- user = None ,
51
- password = None ,
52
- dbname = None
53
- ):
49
+ image : str = "clickhouse/clickhouse-server:latest" ,
50
+ port : int = 9000 ,
51
+ user : Optional [ str ] = None ,
52
+ password : Optional [ str ] = None ,
53
+ dbname : Optional [ str ] = None
54
+ ) -> None :
54
55
super ().__init__ (image = image )
55
56
56
57
self .CLICKHOUSE_USER = user or self .CLICKHOUSE_USER
@@ -60,16 +61,16 @@ def __init__(
60
61
self .with_exposed_ports (self .port_to_expose )
61
62
62
63
@wait_container_is_ready (Error , EOFError )
63
- def _connect (self ):
64
+ def _connect (self ) -> None :
64
65
with clickhouse_driver .Client .from_url (self .get_connection_url ()) as client :
65
66
client .execute ("SELECT version()" )
66
67
67
- def _configure (self ):
68
+ def _configure (self ) -> None :
68
69
self .with_env ("CLICKHOUSE_USER" , self .CLICKHOUSE_USER )
69
70
self .with_env ("CLICKHOUSE_PASSWORD" , self .CLICKHOUSE_PASSWORD )
70
71
self .with_env ("CLICKHOUSE_DB" , self .CLICKHOUSE_DB )
71
72
72
- def get_connection_url (self , host = None ):
73
+ def get_connection_url (self , host : Optional [ str ] = None ) -> str :
73
74
return self ._create_connection_url (
74
75
dialect = "clickhouse" ,
75
76
username = self .CLICKHOUSE_USER ,
0 commit comments