Fix type annotation inconsistency in negotiate() method #787
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.
Title: Fix type inconsistency in multiselect negotiate method and add temporary files to gitignore
Description:
Problem
This PR addresses a type inconsistency between the abstract interface and its implementation in the multiselect protocol negotiation:
• The IProtocolMuxer.negotiate() method in libp2p/abc.py has return type Optional[TProtocol] (allowing None)
• The implementation in libp2p/protocol_muxer/multiselect.py had return type TProtocol (not allowing None)
• There was a FIXME comment in the code acknowledging this mismatch
This inconsistency could cause type checking errors and potential runtime issues when the method legitimately returns None during failed negotiations.
Changes Made
Benefits
• ✅ Resolves type checking inconsistencies
• ✅ Aligns implementation with abstract interface contract
• ✅ Prevents accidental commits of temporary files
• ✅ Improves code maintainability and type safety
Testing
• Verified type annotations are consistent between interface and implementation
• Confirmed gitignore pattern correctly excludes temporary files
• No functional changes to existing behavior
Checklist
Code changes implemented
Type consistency verified
Gitignore updated