[py-tx] updated the covaraince of TUpdateRecordValue to allow for mor… #1670
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.
This PR addresses the t.any type in issue #1255 and helps to impose stronger typing in SignalExchangeAPIWithSimpleUpdates by replacing t.Any with state.TFetchedSignalMetadata and making state.TUpdateRecordValue covariant.
Changes:
Replaced t.Any with state.TFetchedSignalMetadata in SignalExchangeAPIWithSimpleUpdates to enhance type specificity and ensure compatibility with the expected metadata structure.
Made state.TUpdateRecordValue Covariant to resolve iterator conflicts in fetch_iter usage across multiple files. The updated covariance improves flexibility and compatibility in the FetchDelta data class, enabling fetch_iter to handle both states.TFetchedSignalMetadata and state.TUpdateRecordValue as well as pre-existing subclass iterator changes.
Effected File List: Cli_state.py, Signal_exchange.py, Fb_threatexchnage.py, File_api.py, Static_sample.py, Stop_ncii_api.py, Techagainstterrorism.py, Test_state.py.
Testing:
Ran all of the type checking with “python -m mypy threatexchange”, then did further testing with
mypy --check-untyped-defs for each affected file in the above effect file list.
When running the specific unit tests, all related tests pass with no changes in functionality; however, test cases in the hashing library fail, which is consistent with the main branch before these changes.
Related Tests:
threatexchange/exchanges/tests/test_state.py
threatexchange/exchanges/tests/test_state_compatibility.py