diff --git a/mypy/dmypy_server.py b/mypy/dmypy_server.py index faa4f9c8274c..c05d43eced1f 100644 --- a/mypy/dmypy_server.py +++ b/mypy/dmypy_server.py @@ -86,13 +86,11 @@ class Server: def __init__(self, flags: List[str]) -> None: """Initialize the server with the desired mypy flags.""" self.saved_cache = {} # type: mypy.build.SavedCache - if '--experimental' in flags: - self.fine_grained = True - self.fine_grained_initialized = False - flags.remove('--experimental') - else: - self.fine_grained = False - sources, options = mypy.main.process_options(['-i'] + flags, False) + self.fine_grained_initialized = False + sources, options = mypy.main.process_options(['-i'] + flags, + require_targets=False, + server_options=True) + self.fine_grained = options.fine_grained_incremental if sources: sys.exit("dmypy: start/restart does not accept sources") if options.report_dirs: diff --git a/mypy/main.py b/mypy/main.py index 90b1285abc51..b64dcccd3fa4 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -206,7 +206,8 @@ def invert_flag_name(flag: str) -> str: def process_options(args: List[str], - require_targets: bool = True + require_targets: bool = True, + server_options: bool = False, ) -> Tuple[List[BuildSource], Options]: """Parse command line arguments.""" @@ -389,6 +390,9 @@ def add_invertible_flag(flag: str, parser.add_argument('--no-fast-parser', action='store_true', dest='special-opts:no_fast_parser', help=argparse.SUPPRESS) + if server_options: + parser.add_argument('--experimental', action='store_true', dest='fine_grained_incremental', + help="enable fine-grained incremental mode") report_group = parser.add_argument_group( title='report generation', diff --git a/mypy/options.py b/mypy/options.py index 91160f577057..f05253d034fc 100644 --- a/mypy/options.py +++ b/mypy/options.py @@ -141,6 +141,7 @@ def __init__(self) -> None: self.debug_cache = False self.quick_and_dirty = False self.skip_version_check = False + self.fine_grained_incremental = False # Paths of user plugins self.plugins = [] # type: List[str]