Repository navigation
refactor(python): move TextServiceManager into Server and load from directory - #963
Merged
Merged
Conversation
PCMan
added a commit
that referenced
this pull request
Oct 18, 2026
…irectory (#963) - Remove module-level textServiceMgr global from serviceManager.py. - Make TextServiceManager.__init__ initialize an empty manager without auto-loading. - Add TextServiceManager.load(inputMethodsDir) so callers provide the directory to load. - Add class factory TextServiceManager.fromDir(inputMethodsDir). - Retain enumerateServices(inputMethodsDir=None) for backward compatibility. - Instantiate TextServiceManager in Server.__init__ and call load(input_methods_dir) in a try/except block. - Add createService to Server and update Client.init to delegate to self.server.createService. - Add docstrings to TextServiceInfo and TextServiceManager. - Add unit tests in tests/test_service_manager.py. WHY: Instantiating TextServiceManager at module import time ran filesystem enumeration during import and exposed global mutable state. Decoupling manager instantiation from directory loading ensures the manager remains valid even if loading fails. Allowing callers to pass directories enables loading services from arbitrary locations and makes the code modular, reusable, and easy to test. Generated with assistance from Antigravity (Gemini 3.8 Flash).
PCMan
force-pushed
the
refactor/server-text-service-manager
branch
from
October 18, 2026 17:22
37d75da to
6a3ad90
Compare
PCMan
added a commit
that referenced
this pull request
Oct 18, 2026
…irectory (#963) - Remove module-level textServiceMgr global from serviceManager.py. - Make TextServiceManager.__init__ initialize an empty manager without auto-loading. - Add TextServiceManager.load(inputMethodsDir) so callers provide the directory to load. - Retain enumerateServices(inputMethodsDir=None) for backward compatibility. - Instantiate TextServiceManager in Server.__init__ and call load(input_methods_dir) in a try/except block. - Add createService to Server and update Client.init to delegate to self.server.createService. - Add docstrings to TextServiceInfo and TextServiceManager. - Add unit tests in tests/test_service_manager.py. WHY: Instantiating TextServiceManager at module import time ran filesystem enumeration during import and exposed global mutable state. Decoupling manager instantiation from directory loading ensures the manager remains valid even if loading fails. Allowing callers to pass directories enables loading services from arbitrary locations and makes the code modular, reusable, and easy to test. Generated with assistance from Antigravity (Gemini 3.8 Flash).
PCMan
force-pushed
the
refactor/server-text-service-manager
branch
from
October 18, 2026 17:28
6a3ad90 to
1e87bca
Compare
PCMan
added a commit
that referenced
this pull request
Oct 18, 2026
…irectory (#963) - Remove module-level textServiceMgr global from serviceManager.py. - Make TextServiceManager.__init__ initialize an empty manager without auto-loading. - Add TextServiceManager.load(inputMethodsDir) so callers provide the directory to load. - Instantiate TextServiceManager in Server.__init__ and call load(input_methods_dir) in a try/except block. - Add createService to Server and update Client.init to delegate to self.server.createService. - Add docstrings to TextServiceInfo and TextServiceManager. - Add unit tests in tests/test_service_manager.py. WHY: Instantiating TextServiceManager at module import time ran filesystem enumeration during import and exposed global mutable state. Decoupling manager instantiation from directory loading ensures the manager remains valid even if loading fails. Allowing callers to pass directories enables loading services from arbitrary locations and makes the code modular, reusable, and easy to test. Generated with assistance from Antigravity (Gemini 3.8 Flash).
PCMan
force-pushed
the
refactor/server-text-service-manager
branch
from
October 18, 2026 17:31
1e87bca to
738f16e
Compare
PCMan
added a commit
that referenced
this pull request
Oct 18, 2026
…irectory (#963) - Remove module-level textServiceMgr global from serviceManager.py. - Make TextServiceManager.__init__ initialize an empty manager without auto-loading. - Add TextServiceManager.load(input_methods_dir) so callers provide the directory to load. - Instantiate TextServiceManager in Server.__init__ and call load(input_methods_dir) in a try/except block. - Add createService to Server and update Client.init to delegate to self.server.createService. - Add docstrings to TextServiceInfo and TextServiceManager. - Add unit tests in tests/test_service_manager.py. WHY: Instantiating TextServiceManager at module import time ran filesystem enumeration during import and exposed global mutable state. Decoupling manager instantiation from directory loading ensures the manager remains valid even if loading fails. Allowing callers to pass directories enables loading services from arbitrary locations and makes the code modular, reusable, and easy to test. Generated with assistance from Antigravity (Gemini 3.8 Flash).
PCMan
force-pushed
the
refactor/server-text-service-manager
branch
from
October 18, 2026 17:32
738f16e to
b302d72
Compare
PCMan
added a commit
that referenced
this pull request
Oct 18, 2026
…irectory (#963) - Remove module-level textServiceMgr global from serviceManager.py. - Make TextServiceManager.__init__ initialize an empty manager without auto-loading. - Add TextServiceManager.load(input_methods_dir) so callers provide the directory to load. - Instantiate TextServiceManager in Server.__init__ and call load(input_methods_dir) in a try/except block. - Add createService to Server and update Client.init to delegate to self.server.createService. - Add docstrings to TextServiceInfo and TextServiceManager. - Add unit tests in tests/test_service_manager.py. WHY: Instantiating TextServiceManager at module import time ran filesystem enumeration during import and exposed global mutable state. Decoupling manager instantiation from directory loading ensures the manager remains valid even if loading fails. Allowing callers to pass directories enables loading services from arbitrary locations and makes the code modular, reusable, and easy to test. Generated with assistance from Antigravity (Gemini 3.8 Flash).
PCMan
force-pushed
the
refactor/server-text-service-manager
branch
from
October 18, 2026 17:33
b302d72 to
54c2063
Compare
PCMan
added a commit
that referenced
this pull request
Oct 18, 2026
…irectory (#963) - Remove module-level textServiceMgr global from serviceManager.py. - Make TextServiceManager.__init__ initialize an empty manager without auto-loading. - Add TextServiceManager.load(input_methods_dir) so callers provide the directory to load. - Instantiate TextServiceManager in Server.__init__ and call load(input_methods_dir) in a try/except block. - Add createService to Server and update Client.init to delegate to self.server.createService. - Add docstrings to TextServiceInfo and TextServiceManager. - Add unit tests in tests/test_service_manager.py. WHY: Instantiating TextServiceManager at module import time ran filesystem enumeration during import and exposed global mutable state. Decoupling manager instantiation from directory loading ensures the manager remains valid even if loading fails. Allowing callers to pass directories enables loading services from arbitrary locations and makes the code modular, reusable, and easy to test. Generated with assistance from Antigravity (Gemini 3.8 Flash).
PCMan
force-pushed
the
refactor/server-text-service-manager
branch
from
October 18, 2026 17:35
54c2063 to
af5e3a7
Compare
PCMan
added a commit
that referenced
this pull request
Oct 18, 2026
…irectory (#963) - Remove module-level textServiceMgr global from serviceManager.py. - Make TextServiceManager.__init__ initialize an empty manager without auto-loading. - Add TextServiceManager.load(input_methods_dir) so callers provide the directory to load. - Instantiate TextServiceManager in Server.__init__ and call load(input_methods_dir) in a try/except block. - Add createService to Server and update Client.init to delegate to self.server.createService. - Add docstrings to TextServiceInfo and TextServiceManager. - Add unit tests in tests/test_service_manager.py. WHY: Instantiating TextServiceManager at module import time ran filesystem enumeration during import and exposed global mutable state. Decoupling manager instantiation from directory loading ensures the manager remains valid even if loading fails. Allowing callers to pass directories enables loading services from arbitrary locations and makes the code modular, reusable, and easy to test. Generated with assistance from Antigravity (Gemini 3.8 Flash).
PCMan
force-pushed
the
refactor/server-text-service-manager
branch
from
October 18, 2026 17:37
af5e3a7 to
b98b423
Compare
…irectory (#963) - Remove module-level textServiceMgr global from serviceManager.py. - Make TextServiceManager.__init__ initialize an empty manager without auto-loading. - Add TextServiceManager.load(input_methods_dir) so callers provide the directory to load. - Instantiate TextServiceManager in Server.__init__ and accept injected input_methods_dir. - Inject input_methods_dir from main() into Server(input_methods_dir). - Add createService to Server and update Client.init to delegate to self.server.createService. - Add docstrings to TextServiceInfo and TextServiceManager. - Add unit tests in tests/test_service_manager.py. WHY: Instantiating TextServiceManager at module import time ran filesystem enumeration during import and exposed global mutable state. Decoupling manager instantiation from directory loading ensures the manager remains valid even if loading fails. Injecting input_methods_dir into Server and TextServiceManager enables loading services from arbitrary locations, simplifies dependency management, and improves test isolation. Generated with assistance from Antigravity (Gemini 3.8 Flash).
PCMan
force-pushed
the
refactor/server-text-service-manager
branch
from
October 18, 2026 17:39
b98b423 to
277dac5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
TextServiceManager.load(input_methods_dir: str)so callers provide the directory to scan instead of hardcodinginput_methods. Follows EAFP and allowsOSErrorto propagate to callers.TextServiceManager.__init__initializes an empty instance (self.services = {}) without auto-loading.Server:Server.__init__(self, input_methods_dir: str = None)now accepts an optional injectedinput_methods_dirinstead of hardcoding it.main()resolves the defaultinput_methodsdirectory and injects it intoServer(input_methods_dir).Server.createServiceto encapsulate service manager operations and updatedClient.initto delegate toself.server.createService.textServiceMgr = TextServiceManager()and unusedthreadingimport fromserviceManager.py.TextServiceInfoandTextServiceManager.tests/test_service_manager.pycovering manager initialization, directory loading, raisingOSErroron invalid directory, service creation, and isolated server delegation.Rationale
Instantiating
TextServiceManagerat the module level ran filesystem enumeration during import and exposed global mutable state. Decoupling manager instantiation from directory loading and injectinginput_methods_dirintoServerensures components remain valid even if loading fails. This makesServerandTextServiceManagermodular, decoupled from fixed filesystem paths, and straightforward to test in isolation.Generated with assistance from Antigravity (Gemini 3.8 Flash).