diff --git a/mypy/main.py b/mypy/main.py index 4b52ea20049cb..cb67a6b6c2f88 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -979,6 +979,10 @@ def add_invertible_flag( action="store_true", help="Disable experimental support for recursive type aliases", ) + # Deprecated reverse variant of the above. + internals_group.add_argument( + "--enable-recursive-aliases", action="store_true", help=argparse.SUPPRESS + ) parser.add_argument( "--enable-incomplete-feature", action="append", @@ -1336,6 +1340,12 @@ def set_strict_flags() -> None: if options.logical_deps: options.cache_fine_grained = True + if options.enable_recursive_aliases: + print( + "Warning: --enable-recursive-aliases is deprecated;" + " recursive types are enabled by default" + ) + # Set target. if special_opts.modules + special_opts.packages: options.build_type = BuildType.MODULE diff --git a/mypy/options.py b/mypy/options.py index 835eee030b90b..b89ad97708c17 100644 --- a/mypy/options.py +++ b/mypy/options.py @@ -326,6 +326,8 @@ def __init__(self) -> None: self.many_errors_threshold = defaults.MANY_ERRORS_THRESHOLD # Disable recursive type aliases (currently experimental) self.disable_recursive_aliases = False + # Deprecated reverse version of the above, do not use. + self.enable_recursive_aliases = False # To avoid breaking plugin compatibility, keep providing new_semantic_analyzer @property diff --git a/test-data/unit/cmdline.test b/test-data/unit/cmdline.test index 36d48dc2252eb..124b24352cb41 100644 --- a/test-data/unit/cmdline.test +++ b/test-data/unit/cmdline.test @@ -1476,3 +1476,11 @@ note: A user-defined top-level module with name "typing" is not supported [out] Failed to find builtin module mypy_extensions, perhaps typeshed is broken? == Return code: 2 + +[case testRecursiveAliasesFlagDeprecated] +# cmd: mypy --enable-recursive-aliases a.py +[file a.py] +pass +[out] +Warning: --enable-recursive-aliases is deprecated; recursive types are enabled by default +== Return code: 0