From 7ae95a182aabdfe4756db791c5a44be70fd62559 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Sun, 9 Oct 2022 21:08:38 +0100 Subject: [PATCH 1/2] Temporarily put back --enable-recursive-aliases --- mypy/main.py | 10 ++++++++++ mypy/options.py | 2 ++ 2 files changed, 12 insertions(+) diff --git a/mypy/main.py b/mypy/main.py index e8be9f0d01fe..12ea8c46ae6c 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 + ) internals_group.add_argument( "--custom-typeshed-dir", metavar="DIR", help="Use the custom typeshed in DIR" ) @@ -1318,6 +1322,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 1910f9532913..e37a4017e14f 100644 --- a/mypy/options.py +++ b/mypy/options.py @@ -320,6 +320,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 From e930a7e45b39ef202487a36a725d7f2490029d92 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Sun, 9 Oct 2022 21:13:06 +0100 Subject: [PATCH 2/2] Add a test --- test-data/unit/cmdline.test | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test-data/unit/cmdline.test b/test-data/unit/cmdline.test index 168cf0a8d738..b600f21edbdc 100644 --- a/test-data/unit/cmdline.test +++ b/test-data/unit/cmdline.test @@ -1474,3 +1474,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