| 511 | self.disable_memoryview_promotion = False |
| 512 | |
| 513 | def apply_changes(self, changes: dict[str, object]) -> Options: |
| 514 | # Note: effects of this method *must* be idempotent. |
| 515 | new_options = Options() |
| 516 | # Under mypyc, we don't have a __dict__, so we need to do worse things. |
| 517 | replace_object_state(new_options, self, copy_dict=True) |
| 518 | for key, value in changes.items(): |
| 519 | setattr(new_options, key, value) |
| 520 | if changes.get("ignore_missing_imports"): |
| 521 | # This is the only option for which a per-module and a global |
| 522 | # option sometimes beheave differently. |
| 523 | new_options.ignore_missing_imports_per_module = True |
| 524 | |
| 525 | # These two act as overrides, so apply them when cloning. |
| 526 | # Similar to global codes enabling overrides disabling, so we start from latter. |
| 527 | new_options.disabled_error_codes = self.disabled_error_codes.copy() |
| 528 | new_options.enabled_error_codes = self.enabled_error_codes.copy() |
| 529 | for code_str in new_options.disable_error_code: |
| 530 | code = error_codes[code_str] |
| 531 | new_options.disabled_error_codes.add(code) |
| 532 | new_options.enabled_error_codes.discard(code) |
| 533 | for code_str in new_options.enable_error_code: |
| 534 | code = error_codes[code_str] |
| 535 | new_options.enabled_error_codes.add(code) |
| 536 | new_options.disabled_error_codes.discard(code) |
| 537 | return new_options |
| 538 | |
| 539 | def compare_stable(self, other_snapshot: dict[str, object]) -> bool: |
| 540 | """Compare options in a way that is stable for snapshot() -> apply_changes() roundtrip. |