fix!: Replace Python 2-style ABC patterns with Python 3 equivalents#430
Merged
Conversation
Replace `__metaclass__ = ABCMeta` class-body assignments with `(ABC)` base class inheritance, and replace `@abstractproperty` decorators (deprecated since Python 3.3) with the correct `@property` + `@abstractmethod` stacking. Files changed: - ldclient/interfaces.py: 11 classes updated, 5 @abstractproperty replaced - ldclient/hook.py: Hook class updated, metadata @abstractproperty replaced - ldclient/plugin.py: Plugin class updated - ldclient/migrations/migrator.py: Migrator class updated - ldclient/testing/integrations/persistent_feature_store_test_base.py: tester_class @abstractproperty replaced - ldclient/testing/integrations/big_segment_store_test_base.py: tester_class @abstractproperty replaced Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@abstractproperty was not strictly enforcing the abstract contract, so PostingHook could be instantiated without implementing metadata. With @Property + @AbstractMethod Python raises TypeError at instantiation time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
keelerm84
approved these changes
Jun 5, 2026
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
__metaclass__ = ABCMetaclass-body assignments (Python 2-only, silently ignored in Python 3) with proper(ABC)base class inheritance across 4 modules and 11 classes.@abstractpropertydecorators (deprecated since Python 3.3) with the correct@property+@abstractmethodstacking in 7 locations across 4 files.ABCMetaandabstractpropertyfrom allfrom abc import ...lines.Files changed
ldclient/interfaces.py__metaclass__→(ABC); 5@abstractproperty→@property+@abstractmethodldclient/hook.pyHookclass +metadatapropertyldclient/plugin.pyPluginclassldclient/migrations/migrator.pyMigratorclassldclient/testing/integrations/persistent_feature_store_test_base.pytester_classpropertyldclient/testing/integrations/big_segment_store_test_base.pytester_classpropertyWhy
In Python 3,
__metaclass__ = ABCMetainside a class body is a no-op — the metaclass is never applied, so@abstractmethoddecorators were not enforced. Using(ABC)as a base class is the correct Python 3 pattern and actually enforces the abstract interface.@abstractpropertyhas been deprecated since Python 3.3 and emitsDeprecationWarningin newer Python versions. The correct replacement is to stack@propertyon top of@abstractmethod.Test plan
make test— 1005 passed, 194 skipped (database integration tests, expected)🤖 Generated with Claude Code
Note
Medium Risk
Marked breaking because stricter ABC enforcement can surface at runtime if custom subclasses omitted required abstract members; behavior of complete implementations should be unchanged.
Overview
Replaces legacy Python 2 abstract-base patterns with idiomatic Python 3 across SDK interfaces, hooks, plugins, migrations, and integration test bases.
__metaclass__ = ABCMetais removed in favor of inheriting(ABC)on classes such asFeatureStore,Hook,Plugin,Migrator, and relatedldclient.interfacestypes, so@abstractmethodis actually enforced at instantiation time.@abstractpropertyis replaced with@property+@abstractmethodon abstract properties likeHook.metadata,FeatureStore.initialized, and test-basetester_class. Imports drop unusedABCMeta/abstractproperty.Contract test
PostingHooknow implementsmetadataso it stays a validHooksubclass under the stricter ABC rules.Reviewed by Cursor Bugbot for commit 3162cfa. Bugbot is set up for automated code reviews on this repo. Configure here.
Tracked Internally: SDK-2463