Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move parsing for the fine-grained flag into the main arg parsing code #4524

Merged
merged 1 commit into from
Jan 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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