Skip to content

Commit 23d8793

Browse files
committed
Isolate "compat feature" support to dmlc.py
1 parent 0e3e906 commit 23d8793

File tree

4 files changed

+27
-42
lines changed

4 files changed

+27
-42
lines changed

py/dml/breaking_changes.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -461,33 +461,3 @@ class dml_forbid_warning_statement(BreakingChange):
461461
'''
462462
short = "Disallow the `_warning` statement"
463463
required_after = api_7
464-
465-
466-
467-
compat_features = {
468-
'broken_unused_types': dml_forbid_broken_unused_types,
469-
'broken_conditional_is': dml_forbid_broken_conditional_is,
470-
'port_proxy_ifaces': dml_remove_port_proxy_ifaces,
471-
'port_proxy_attrs': dml_remove_port_proxy_attrs,
472-
'function_in_extern_struct': dml_forbid_function_in_extern_struct,
473-
'optional_version_statement': dml_require_version_statement,
474-
'io_memory': dml_transaction_by_default,
475-
'port_obj_param': dml_remove_port_obj_param,
476-
'shared_logs_on_device': dml_shared_logs_locally,
477-
'suppress_WLOGMIXUP': dml_enable_WLOGMIXUP,
478-
'legacy_attributes': dml_remove_legacy_attributes,
479-
'lenient_typechecking': dml_strict_typechecking,
480-
'no_method_index_asserts': dml_range_check_method_indices,
481-
'meaningless_log_levels': dml_restrict_log_levels,
482-
'dml12_inline': dml12_disable_inline_constants,
483-
'dml12_not': dml12_not_typecheck,
484-
'dml12_misc': dml12_remove_misc_quirks,
485-
'dml12_goto': dml12_remove_goto,
486-
'dml12_int': dml12_fix_int_quirks,
487-
'experimental_vect': dml_forbid_experimental_vect,
488-
'warning_statement': dml_forbid_warning_statement,
489-
}
490-
491-
# temporary hack to keep existing dml.globals.enabled_compat based checks working
492-
for name in compat_features:
493-
globals()[name] = name

py/dml/dmlc.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -582,14 +582,38 @@ def main(argv):
582582
'dml12-remove-goto',
583583
'dml12-fix-int-quirks'])
584584

585+
compat_features = {
586+
'broken_unused_types': breaking_changes.dml_forbid_broken_unused_types,
587+
'broken_conditional_is': breaking_changes.dml_forbid_broken_conditional_is,
588+
'port_proxy_ifaces': breaking_changes.dml_remove_port_proxy_ifaces,
589+
'port_proxy_attrs': breaking_changes.dml_remove_port_proxy_attrs,
590+
'function_in_extern_struct':
591+
breaking_changes.dml_forbid_function_in_extern_struct,
592+
'optional_version_statement':
593+
breaking_changes.dml_require_version_statement,
594+
'io_memory': breaking_changes.dml_transaction_by_default,
595+
'port_obj_param': breaking_changes.dml_remove_port_obj_param,
596+
'shared_logs_on_device': breaking_changes.dml_shared_logs_locally,
597+
'suppress_WLOGMIXUP': breaking_changes.dml_enable_WLOGMIXUP,
598+
'legacy_attributes': breaking_changes.dml_remove_legacy_attributes,
599+
'lenient_typechecking': breaking_changes.dml_strict_typechecking,
600+
'no_method_index_asserts': breaking_changes.dml_range_check_method_indices,
601+
'meaningless_log_levels': breaking_changes.dml_restrict_log_levels,
602+
'dml12_inline': breaking_changes.dml12_disable_inline_constants,
603+
'dml12_not': breaking_changes.dml12_not_typecheck,
604+
'dml12_misc': breaking_changes.dml12_remove_misc_quirks,
605+
'dml12_goto': breaking_changes.dml12_remove_goto,
606+
'dml12_int': breaking_changes.dml12_fix_int_quirks,
607+
'experimental_vect': breaking_changes.dml_forbid_experimental_vect,
608+
'warning_statement': breaking_changes.dml_forbid_warning_statement,
609+
}
585610
if options.no_compat:
586611
if options.breaking_change:
587612
parser.error("cannot pass both --no-compat and --breaking-change")
588613
for flag in options.no_compat:
589614
for tag in flag.split(','):
590-
if tag in breaking_changes.compat_features:
591-
options.breaking_change.append(
592-
breaking_changes.compat_features[tag].tag())
615+
if tag in compat_features:
616+
options.breaking_change.append(compat_features[tag].tag())
593617
else:
594618
parser.error(f'invalid tag {tag} for --no-compat.')
595619

@@ -607,11 +631,6 @@ def main(argv):
607631

608632
breaking_changes.BreakingChange.enabled_breaking_changes = set(
609633
changes.values())
610-
# temp hack to make existing code continue to work
611-
dml.globals.enabled_compat = {
612-
tag for (tag, bc) in breaking_changes.compat_features.items()
613-
if not bc.enabled
614-
}
615634

616635
if not breaking_changes.dml_enable_WLOGMIXUP.enabled:
617636
ignore_warning('WLOGMIXUP')

py/dml/globals.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
# types.TypeSequence -> codegen.TypeSequenceInfo
5656
type_sequence_infos = {}
5757

58-
enabled_compat = set()
5958

6059
# 1.4 style integer semantics is used in 1.2 if False is returned
6160
def compat_dml12_int(site):

py/dml/toplevel.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,6 @@ def parse_main_file(inputfilename, explicit_import_path):
368368
dml.globals.dml_version = version
369369
version_str = fmt_version(version)
370370
if version != (1, 2):
371-
for feature in [breaking_changes.dml12_inline, breaking_changes.dml12_not,
372-
breaking_changes.dml12_misc]:
373-
dml.globals.enabled_compat.discard(feature)
374371
breaking_changes.BreakingChange.enabled_breaking_changes.update([
375372
breaking_changes.dml12_disable_inline_constants,
376373
breaking_changes.dml12_not_typecheck,

0 commit comments

Comments
 (0)