Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[py-tx] updated the covaraince of TUpdateRecordValue to allow for mor… #1670

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

Mackay-Fisher
Copy link
Contributor

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

Copy link
Contributor

@Dcallies Dcallies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was simpler than I thought it was going to be, but the checks pass and so I accepts. Nice work!

@Dcallies Dcallies merged commit 911f83a into facebook:main Oct 28, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants