Skip to content

Commit

Permalink
Move argument parsing for the fine-grained flag into the main arg par…
Browse files Browse the repository at this point in the history
…sing code (#4524)
  • Loading branch information
msullivan authored and JukkaL committed Jan 31, 2018
1 parent d2c0419 commit 16db987
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
12 changes: 5 additions & 7 deletions mypy/dmypy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions mypy/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 16db987

Please sign in to comment.