fix: Add compatibility module for StrEnum and assert_never (#12) #18
+28
−11
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.
Note
This pull request is a fix to the #12
This pull request introduces a new compatibility module to support Python versions earlier than 3.11, ensuring that features like
StrEnum
andassert_never
are available across all supported environments. The main changes involve refactoring imports throughout the codebase to use these compatibility shims, improving cross-version compatibility and maintainability.Python compatibility improvements:
chatkit/_compat.py
that provides backports forStrEnum
andassert_never
for Python versions < 3.11.chatkit/errors.py
,chatkit/agents.py
,chatkit/server.py
, andtests/helpers/mock_widget.py
to useStrEnum
andassert_never
from the new_compat
module instead of directly from the standard library.assert_never
from thetyping
module in files where it is now provided by_compat
.These changes ensure that the codebase remains functional and consistent across both older and newer Python versions.