11"""A textual widget used to display environment information."""
22
33import random
4- from typing import Optional
54
65from rich .panel import Panel
76from rich .style import Style
2827_UI_HOSTNAME_POSTFIX : str = "/data-manager-ui"
2928
3029
31- class EnvWidget (Static ): # type: ignore
30+ class EnvWidget (Static ):
3231 """Displays the environment."""
3332
34- as_access_token : Optional [ str ] = None
35- dm_access_token : Optional [ str ] = None
33+ as_access_token : str | None = None
34+ dm_access_token : str | None = None
3635
3736 def __init__ (self , environment_name : str ) -> None :
3837 super ().__init__ ()
3938 self .environment_name = environment_name
4039 self .environment = Environment (environment_name )
4140
42- self .as_api : Optional [ AsApi ] = None
41+ self .as_api : AsApi | None = None
4342 if self .environment .as_api :
4443 self .as_api = AsApi ()
4544 self .as_api .set_api_url (self .environment .as_api , verify_ssl_cert = False )
46- self .dm_api : Optional [ DmApi ] = None
45+ self .dm_api : DmApi | None = None
4746 if self .environment .dm_api :
4847 self .dm_api = DmApi ()
4948 self .dm_api .set_api_url (self .environment .dm_api , verify_ssl_cert = False )
50- self .ui_api : Optional [ UiApi ] = None
49+ self .ui_api : UiApi | None = None
5150 if self .environment .ui_api :
5251 self .ui_api = UiApi ()
5352 self .ui_api .set_api_url (self .environment .ui_api , verify_ssl_cert = False )
@@ -127,7 +126,7 @@ def render(self) -> RenderResult:
127126 kc_host = Text (f"{ self .environment .keycloak_hostname } " , style = _KEY_VALUE_STYLE )
128127
129128 # The API lines are also dynamically styled.
130- as_hostname : Optional [ str ] = self .environment .as_hostname
129+ as_hostname : str | None = self .environment .as_hostname
131130 if as_hostname :
132131 as_hostname_text : Text = Text (f"{ as_hostname } " , style = _KEY_VALUE_STYLE )
133132 if self .as_access_token :
@@ -137,7 +136,7 @@ def render(self) -> RenderResult:
137136 else :
138137 as_hostname_text = Text ("Undefined" , style = _VALUE_ERROR_STYLE )
139138
140- dm_hostname : Optional [ str ] = self .environment .dm_hostname
139+ dm_hostname : str | None = self .environment .dm_hostname
141140 if dm_hostname :
142141 dm_hostname_text : Text = Text (f"{ dm_hostname } " , style = _KEY_VALUE_STYLE )
143142 if self .dm_access_token :
@@ -147,7 +146,7 @@ def render(self) -> RenderResult:
147146 else :
148147 dm_hostname_text = Text ("Undefined" , style = _VALUE_ERROR_STYLE )
149148
150- ui_hostname : Optional [ str ] = self .environment .ui_hostname
149+ ui_hostname : str | None = self .environment .ui_hostname
151150 if ui_hostname :
152151 ui_hostname_text : Text = Text (
153152 ui_hostname + _UI_HOSTNAME_POSTFIX + " " , style = _KEY_VALUE_STYLE
0 commit comments