File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -499,10 +499,9 @@ def __init__(
499499 is_kwargs_empty = not kwargs
500500
501501 if "application" not in kwargs :
502- if ENV_VAR_PARTNER in os .environ .keys ():
503- kwargs ["application" ] = os .environ [ENV_VAR_PARTNER ]
504- elif "streamlit" in sys .modules :
505- kwargs ["application" ] = "streamlit"
502+ app = self ._detect_application ()
503+ if app :
504+ kwargs ["application" ] = app
506505
507506 if "insecure_mode" in kwargs :
508507 warn_message = "The 'insecure_mode' connection property is deprecated. Please use 'disable_ocsp_checks' instead"
@@ -2283,3 +2282,15 @@ def _check_oauth_parameters(self) -> None:
22832282 "errno" : ER_INVALID_VALUE ,
22842283 },
22852284 )
2285+
2286+ @staticmethod
2287+ def _detect_application () -> None | str :
2288+ if ENV_VAR_PARTNER in os .environ .keys ():
2289+ return os .environ [ENV_VAR_PARTNER ]
2290+ if "streamlit" in sys .modules :
2291+ return "streamlit"
2292+ if all (
2293+ (jpmod in sys .modules )
2294+ for jpmod in ("ipykernel" , "jupyter_core" , "jupyter_client" )
2295+ ):
2296+ return "jupyter_notebook"
You can’t perform that action at this time.
0 commit comments