Add supports_relativization attribute to Data classes
Summary:
Add a class attribute supports_relativization to the Data class hierarchy to indicate whether a data type supports relativization. This infrastructure change will be used in a follow-up diff to improve the Summary analysis by checking this attribute instead of using isinstance checks and would provide a cleaner, more extensible way to check for relativization support compared to type checking.
Why this change:
- Provides a more maintainable and extensible design pattern
- Eliminates the need for external isinstance() checks against specific data types
- Makes it easy for future data types to declare relativization support
Changes:
- Add
supports_relativization: bool = Trueclass attribute to the baseDataclass - Override
supports_relativization = FalseinMapDataclass since it raises NotImplementedError in its relativize() method - Add documentation comments explaining the purpose of the attribute
Differential Revision: D85807192
@shrutipatel31 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D85807192.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 96.56%. Comparing base (dcce1d4) to head (50ff14b).
Additional details and impacted files
@@ Coverage Diff @@
## main #4482 +/- ##
=======================================
Coverage 96.56% 96.56%
=======================================
Files 551 551
Lines 56892 56902 +10
=======================================
+ Hits 54940 54950 +10
Misses 1952 1952
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.