MCPcopy
hub / github.com/python/mypy / apply_changes

Method apply_changes

mypy/options.py:513–537  ·  view source on GitHub ↗
(self, changes: dict[str, object])

Source from the content-addressed store, hash-verified

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.

Callers 8

test_parserFunction · 0.95
test_parserFunction · 0.95
do_daemonFunction · 0.95
compare_stableMethod · 0.80
clone_for_moduleMethod · 0.80
mainFunction · 0.80

Calls 8

replace_object_stateFunction · 0.90
setattrFunction · 0.85
discardMethod · 0.80
OptionsClass · 0.70
itemsMethod · 0.45
getMethod · 0.45
copyMethod · 0.45
addMethod · 0.45

Tested by 2

test_parserFunction · 0.76
test_parserFunction · 0.76