|
18 | 18 | from mypy.find_sources import InvalidSourceList, create_source_list
|
19 | 19 | from mypy.fscache import FileSystemCache
|
20 | 20 | from mypy.modulefinder import BuildSource, FindModuleCache, SearchPaths, get_search_dirs, mypy_path
|
21 |
| -from mypy.options import BuildType, Options |
| 21 | +from mypy.options import INCOMPLETE_FEATURES, BuildType, Options |
22 | 22 | from mypy.split_namespace import SplitNamespace
|
23 | 23 | from mypy.version import __version__
|
24 | 24 |
|
@@ -979,6 +979,12 @@ def add_invertible_flag(
|
979 | 979 | action="store_true",
|
980 | 980 | help="Disable experimental support for recursive type aliases",
|
981 | 981 | )
|
| 982 | + parser.add_argument( |
| 983 | + "--enable-incomplete-feature", |
| 984 | + action="append", |
| 985 | + metavar="FEATURE", |
| 986 | + help="Enable support of incomplete/experimental features for early preview", |
| 987 | + ) |
982 | 988 | internals_group.add_argument(
|
983 | 989 | "--custom-typeshed-dir", metavar="DIR", help="Use the custom typeshed in DIR"
|
984 | 990 | )
|
@@ -1107,6 +1113,7 @@ def add_invertible_flag(
|
1107 | 1113 | parser.add_argument(
|
1108 | 1114 | "--cache-map", nargs="+", dest="special-opts:cache_map", help=argparse.SUPPRESS
|
1109 | 1115 | )
|
| 1116 | + # This one is deprecated, but we will keep it for few releases. |
1110 | 1117 | parser.add_argument(
|
1111 | 1118 | "--enable-incomplete-features", action="store_true", help=argparse.SUPPRESS
|
1112 | 1119 | )
|
@@ -1274,6 +1281,17 @@ def set_strict_flags() -> None:
|
1274 | 1281 | # Enabling an error code always overrides disabling
|
1275 | 1282 | options.disabled_error_codes -= options.enabled_error_codes
|
1276 | 1283 |
|
| 1284 | + # Validate incomplete features. |
| 1285 | + for feature in options.enable_incomplete_feature: |
| 1286 | + if feature not in INCOMPLETE_FEATURES: |
| 1287 | + parser.error(f"Unknown incomplete feature: {feature}") |
| 1288 | + if options.enable_incomplete_features: |
| 1289 | + print( |
| 1290 | + "Warning: --enable-incomplete-features is deprecated, use" |
| 1291 | + " --enable-incomplete-feature=FEATURE instead" |
| 1292 | + ) |
| 1293 | + options.enable_incomplete_feature = list(INCOMPLETE_FEATURES) |
| 1294 | + |
1277 | 1295 | # Compute absolute path for custom typeshed (if present).
|
1278 | 1296 | if options.custom_typeshed_dir is not None:
|
1279 | 1297 | options.abs_custom_typeshed_dir = os.path.abspath(options.custom_typeshed_dir)
|
|
0 commit comments