File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -1449,9 +1449,7 @@ def set_strict_flags() -> None:
14491449 process_cache_map (parser , special_opts , options )
14501450
14511451 # Process --strict-bytes
1452- if options .strict_bytes :
1453- options .disable_bytearray_promotion = True
1454- options .disable_memoryview_promotion = True
1452+ options .process_strict_bytes ()
14551453
14561454 # An explicitly specified cache_fine_grained implies local_partial_types
14571455 # (because otherwise the cache is not compatible with dmypy)
Original file line number Diff line number Diff line change @@ -466,6 +466,16 @@ def process_incomplete_features(
466466 if feature in COMPLETE_FEATURES :
467467 warning_callback (f"Warning: { feature } is already enabled by default" )
468468
469+ def process_strict_bytes (self ) -> None :
470+ # Sync `--strict-bytes` and `--disable-{bytearray,memoryview}-promotion`
471+ if self .strict_bytes :
472+ # backwards compatibility
473+ self .disable_bytearray_promotion = True
474+ self .disable_memoryview_promotion = True
475+ elif self .disable_bytearray_promotion and self .disable_memoryview_promotion :
476+ # forwards compatibility
477+ self .strict_bytes = True
478+
469479 def apply_changes (self , changes : dict [str , object ]) -> Options :
470480 # Note: effects of this method *must* be idempotent.
471481 new_options = Options ()
Original file line number Diff line number Diff line change @@ -2003,6 +2003,7 @@ def warning_callback(msg: str) -> None:
20032003 options .process_incomplete_features (
20042004 error_callback = error_callback , warning_callback = warning_callback
20052005 )
2006+ options .process_strict_bytes ()
20062007
20072008 try :
20082009 modules = build_stubs (modules , options , find_submodules = not args .check_typeshed )
You can’t perform that action at this time.
0 commit comments