Skip to content

Commit 16db987

Browse files
msullivanJukkaL
authored andcommitted
Move argument parsing for the fine-grained flag into the main arg parsing code (#4524)
1 parent d2c0419 commit 16db987

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

mypy/dmypy_server.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,11 @@ class Server:
8686
def __init__(self, flags: List[str]) -> None:
8787
"""Initialize the server with the desired mypy flags."""
8888
self.saved_cache = {} # type: mypy.build.SavedCache
89-
if '--experimental' in flags:
90-
self.fine_grained = True
91-
self.fine_grained_initialized = False
92-
flags.remove('--experimental')
93-
else:
94-
self.fine_grained = False
95-
sources, options = mypy.main.process_options(['-i'] + flags, False)
89+
self.fine_grained_initialized = False
90+
sources, options = mypy.main.process_options(['-i'] + flags,
91+
require_targets=False,
92+
server_options=True)
93+
self.fine_grained = options.fine_grained_incremental
9694
if sources:
9795
sys.exit("dmypy: start/restart does not accept sources")
9896
if options.report_dirs:

mypy/main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ def invert_flag_name(flag: str) -> str:
206206

207207

208208
def process_options(args: List[str],
209-
require_targets: bool = True
209+
require_targets: bool = True,
210+
server_options: bool = False,
210211
) -> Tuple[List[BuildSource], Options]:
211212
"""Parse command line arguments."""
212213

@@ -389,6 +390,9 @@ def add_invertible_flag(flag: str,
389390
parser.add_argument('--no-fast-parser', action='store_true',
390391
dest='special-opts:no_fast_parser',
391392
help=argparse.SUPPRESS)
393+
if server_options:
394+
parser.add_argument('--experimental', action='store_true', dest='fine_grained_incremental',
395+
help="enable fine-grained incremental mode")
392396

393397
report_group = parser.add_argument_group(
394398
title='report generation',

mypy/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def __init__(self) -> None:
141141
self.debug_cache = False
142142
self.quick_and_dirty = False
143143
self.skip_version_check = False
144+
self.fine_grained_incremental = False
144145

145146
# Paths of user plugins
146147
self.plugins = [] # type: List[str]

0 commit comments

Comments
 (0)