Test backward compatibility for function signatures with @compatibility(is_backward_compatible=True). Currently this checks for exact signature matches, which may lead to false positives. If this becomes too annoying, we can refine this check to actually parse out
(self)
| 4053 | |
| 4054 | |
| 4055 | def test_function_back_compat(self): |
| 4056 | """ |
| 4057 | Test backward compatibility for function signatures with |
| 4058 | @compatibility(is_backward_compatible=True). Currently this checks for |
| 4059 | exact signature matches, which may lead to false positives. If this |
| 4060 | becomes too annoying, we can refine this check to actually parse out |
| 4061 | the saved schema strings and check if the change is truly backward- |
| 4062 | incompatible. |
| 4063 | """ |
| 4064 | signature_strs = [] |
| 4065 | |
| 4066 | for obj in _BACK_COMPAT_OBJECTS: |
| 4067 | if not isinstance(obj, type): |
| 4068 | signature_strs.append(self._fn_to_stable_annotation_str(obj)) |
| 4069 | |
| 4070 | signature_strs.sort() |
| 4071 | |
| 4072 | try: |
| 4073 | self.assertExpected('\n'.join(signature_strs) + '\n', 'fx_backcompat_function_signatures') |
| 4074 | except AssertionError as e: |
| 4075 | msg = f"{e}\n****** ERROR ******\nAn FX function that has been marked " \ |
| 4076 | f"as backwards-compatible has experienced a signature change. See the " \ |
| 4077 | f"above exception context for more information. If this change was " \ |
| 4078 | f"unintended, please revert it. If it was intended, check with the FX " \ |
| 4079 | f"team to ensure that the proper deprecation protocols have been followed " \ |
| 4080 | f"and subsequently --accept the change." |
| 4081 | raise AssertionError(msg) # noqa: TRY200 |
| 4082 | |
| 4083 | def test_class_member_back_compat(self): |
| 4084 | """ |
nothing calls this directly
no test coverage detected