File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed
Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -35,12 +35,13 @@ def from_env(cls) -> 'AppConfig':
3535 app_token = os .environ .get ('SINGLESTOREDB_APP_TOKEN' )
3636 user_token = os .environ .get ('SINGLESTOREDB_USER_TOKEN' )
3737
38- if is_gateway_enabled :
39- # Make sure the required variables are present
40- # and present useful error message if not
41- app_token = cls ._read_variable ('SINGLESTOREDB_APP_TOKEN' )
42- else :
43- user_token = cls ._read_variable ('SINGLESTOREDB_USER_TOKEN' )
38+ # Make sure the required variables are present
39+ # and present useful error message if not
40+ if running_interactively :
41+ if is_gateway_enabled :
42+ app_token = cls ._read_variable ('SINGLESTOREDB_APP_TOKEN' )
43+ else :
44+ user_token = cls ._read_variable ('SINGLESTOREDB_USER_TOKEN' )
4445
4546 return cls (
4647 listen_port = int (port ),
@@ -52,12 +53,11 @@ def from_env(cls) -> 'AppConfig':
5253 )
5354
5455 @property
55- def token (self ) -> str :
56+ def token (self ) -> Optional [str ]:
57+ """
58+ Returns None if running non-interactively
59+ """
5660 if self .is_gateway_enabled :
57- # We make sure this is not null while constructing the object
58- assert self .app_token is not None
5961 return self .app_token
6062 else :
61- # We make sure this is not null while constructing the object
62- assert self .user_token is not None
6363 return self .user_token
Original file line number Diff line number Diff line change 11from dataclasses import dataclass
2+ from typing import Optional
23
34
45@dataclass
56class ConnectionInfo :
67 url : str
7- token : str
8+
9+ # Only present in interactive mode
10+ token : Optional [str ]
You can’t perform that action at this time.
0 commit comments