Skip to content

Commit eed5f01

Browse files
committed
Move argument parsing for the fine-grained flag into the main arg parsing code
1 parent 8082af2 commit eed5f01

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
@@ -84,13 +84,11 @@ class Server:
8484
def __init__(self, flags: List[str]) -> None:
8585
"""Initialize the server with the desired mypy flags."""
8686
self.saved_cache = {} # type: mypy.build.SavedCache
87-
if '--experimental' in flags:
88-
self.fine_grained = True
89-
self.fine_grained_initialized = False
90-
flags.remove('--experimental')
91-
else:
92-
self.fine_grained = False
93-
sources, options = mypy.main.process_options(['-i'] + flags, False)
87+
self.fine_grained_initialized = False
88+
sources, options = mypy.main.process_options(['-i'] + flags,
89+
require_targets=False,
90+
server_options=True)
91+
self.fine_grained = options.fine_grained_incremental
9492
if sources:
9593
sys.exit("dmypy: start/restart does not accept sources")
9694
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)