I have a Python repo that I’m working on in VSCode.
The repo structure is like this:
main_repo
-- utils
---- client
------ my_client.py
my_client.py contains this code:
class CustomClient(DataClient):
def __init__(self, client_type=None, lazy_init=False):
self.client_type = client_type
self._is_initialized = False # Tracks whether initialization has occurred
# Initialize eagerly if not lazy
if lazy_init is False:
self.initialize()
def initialize(self):
"""Explicitly initialize the base class if lazy_init=True."""
if not self._is_initialized:
super().__init__(...) # initialization logic
self._is_initialized = True
@staticmethod
def SpecificClient(lazy_init=False):
"""Factory method to create a Client of a certain type."""
return CustomClient(client_type="foo", lazy_init=lazy_init)
So, the idea is that I can create a client like this:
client = CustomClient.SpecificClient(lazy_init=True)
client.initialize()
The client initialization triggers a web page for SSO login, and the issue is that this is happening every time I save a file in the IDE.
So, I imagine there is some background process that is checking the code, goes through the client.initialize()
calls and executes them upon saving.
I tried changing the initialize method to:
def initialize(self):
"""Explicitly initialize the base class if lazy_init=True."""
stack = inspect.stack()
for frame in stack:
if "pylint" in frame.filename or "mypy" in frame.filename:
return
if not self._is_initialized:
super().__init__(...) # initialization logic
self._is_initialized = True
but it’s still launching the SSO everytime.
I tried disabling the extensions, I left only the ones shown in this picture, but I still have this issue:
Any suggestions?
3