-
Notifications
You must be signed in to change notification settings - Fork 137
refactor: use classmethod in factory methods #1179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
refactor: use classmethod in factory methods #1179
Conversation
|
Can you elaborate a bit on the practical impacts here? Is there some specific thing you are trying to do that you can't accomplish? |
@tconley1428, sure. My concrete use case is to replace the It's currently impossible to fully replace it, because the client's Basically, using |
What was changed
Switched to
classmethods in all factory methods I found without thoroughly analyzing the entire codebase (please let me know if I missed any factory methods!).Also fixed some small issues with directly setting defaults to
MappingProxyTypeinstances instead of usingdefault_factory.Why?
Switching to
classmethodandcls(where possible) will enhance type safety, support inheritance, and boost overall code maintainability. For example, it will be easier to replace theWorkflowHandleclass withClientby simply subclassingClientand overriding the appropriate methods, andClient.connectwill still work as intended (currently, it returns the original, temporaryClientinstance, which makesClientclosed to extension).Checklist
Closes - (no GitHub issue created)
How was this tested:
Tested by running all tests (
poe test), linters (poe lint,poe format), and manually testing some changes by running local temporal worker and clients in my private project.Nope, this change is backward-compatible.