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 @@ -495,10 +495,9 @@ def __init__(
495495 is_kwargs_empty = not kwargs
496496
497497 if "application" not in kwargs :
498- if ENV_VAR_PARTNER in os .environ .keys ():
499- kwargs ["application" ] = os .environ [ENV_VAR_PARTNER ]
500- elif "streamlit" in sys .modules :
501- kwargs ["application" ] = "streamlit"
498+ app = self ._detect_application ()
499+ if app :
500+ kwargs ["application" ] = app
502501
503502 if "insecure_mode" in kwargs :
504503 warn_message = "The 'insecure_mode' connection property is deprecated. Please use 'disable_ocsp_checks' instead"
@@ -2272,3 +2271,15 @@ def _check_oauth_required_parameters(self) -> None:
22722271 "errno" : ER_NO_CLIENT_ID ,
22732272 },
22742273 )
2274+
2275+ @staticmethod
2276+ def _detect_application () -> None | str :
2277+ if ENV_VAR_PARTNER in os .environ .keys ():
2278+ return os .environ [ENV_VAR_PARTNER ]
2279+ if "streamlit" in sys .modules :
2280+ return "streamlit"
2281+ if all (
2282+ (jpmod in sys .modules )
2283+ for jpmod in ("ipykernel" , "jupyter_core" , "jupyter_client" )
2284+ ):
2285+ return "jupyter_notebook"
You can’t perform that action at this time.
0 commit comments