Refactor: Eliminate circular dependencies in psd_tools.api using Protocols #515
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
This PR refactors the
psd_tools.apipackage to eliminate circular dependency issues by introducingtyping.Protocolclasses. The refactoring improves type safety while maintaining backward compatibility.Changes
src/psd_tools/api/protocols.py- DefinesLayerProtocol,GroupMixinProtocol, andPSDProtocolinterfacesAnytype hints with proper Protocol references in:mask.py- UsesLayerProtocolinstead ofAnyeffects.py- UsesLayerProtocolinstead ofAnysmart_object.py- UsesLayerProtocolwith proper type hintspil_io.py- Uses Protocol forward references withTYPE_CHECKINGnumpy_io.py- Uses Protocol forward references withTYPE_CHECKINGlayers.py- UsesPSDImageforward references withTYPE_CHECKINGpsd_image.py- UsesLayerforward references withTYPE_CHECKINGobjectinheritance)Technical Approach
Anywhere needed to accommodate implementation details (TypeVars, etc.)Testing
Impact
Anytypes in favor of explicit Protocol interfaces🤖 Generated with Claude Code