Skip to content

Commit dafd079

Browse files
committed
Remove --fast-parser flag from mypy
1 parent 49a0e88 commit dafd079

File tree

12 files changed

+23
-65
lines changed

12 files changed

+23
-65
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ this:
116116

117117
$ python3 -m pip install -U mypy
118118

119-
Except on Windows, it's best to always use the `--fast-parser`
120-
option to mypy; this requires installing `typed-ast`:
119+
This should automatically installed the appropriate version of
120+
mypy's parser, typed-ast. If for some reason it does not, you
121+
can install it manually:
121122

122123
$ python3 -m pip install -U typed-ast
123124

docs/source/command_line.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ flag (or its long form ``--help``)::
1515
[--check-untyped-defs] [--disallow-subclassing-any]
1616
[--warn-incomplete-stub] [--warn-redundant-casts]
1717
[--warn-no-return] [--warn-unused-ignores] [--show-error-context]
18-
[--fast-parser] [-i] [--cache-dir DIR] [--strict-optional]
18+
[-i] [--cache-dir DIR] [--strict-optional]
1919
[--strict-optional-whitelist [GLOB [GLOB ...]]] [--strict]
2020
[--junit-xml JUNIT_XML] [--pdb] [--show-traceback] [--stats]
2121
[--inferstats] [--custom-typing MODULE]
@@ -303,10 +303,6 @@ Here are some more useful flags:
303303
to speed up type checking. Incremental mode can help when most parts
304304
of your program haven't changed since the previous mypy run.
305305

306-
- ``--fast-parser`` enables an experimental parser implemented in C that
307-
is faster than the default parser and supports multi-line comment
308-
function annotations (see :ref:`multi_line_annotation` for the details).
309-
310306
- ``--python-version X.Y`` will make mypy typecheck your code as if it were
311307
run under Python version X.Y. Without this option, mypy will default to using
312308
whatever version of Python is running mypy. Note that the ``-2`` and

docs/source/config_file.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ The following global flags may only be set in the global section
9393
- ``dump_inference_stats`` (Boolean, default False) dumps stats about
9494
type inference.
9595

96-
- ``fast_parser`` (Boolean, default False) enables the experimental
97-
fast parser.
98-
9996
- ``incremental`` (Boolean, default False) enables the experimental
10097
module cache.
10198

docs/source/kinds_of_types.rst

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -691,12 +691,6 @@ Mypy supports it already:
691691
692692
p = Point(x=1, y='x') # Argument has incompatible type "str"; expected "int"
693693
694-
.. note::
695-
696-
The Python 3.6 syntax requires the ``--fast-parser`` flag. You must also have the
697-
`typed_ast <https://pypi.python.org/pypi/typed-ast>`_ package
698-
installed and have at least version 0.6.1. Use ``pip3 install -U typed_ast``.
699-
700694
.. _type-of-class:
701695

702696
The type of class objects
@@ -872,15 +866,6 @@ annotated the first example as the following:
872866
Typing async/await
873867
******************
874868

875-
.. note::
876-
877-
Currently, you must pass in the ``--fast-parser`` flag if you want to run
878-
mypy against code containing the ``async/await`` keywords. The fast parser
879-
will be enabled by default in a future version of mypy.
880-
881-
Note that mypy will understand coroutines created using the ``@asyncio.coroutine``
882-
decorator both with and without the fast parser enabled.
883-
884869
Mypy supports the ability to type coroutines that use the ``async/await``
885870
syntax introduced in Python 3.5. For more information regarding coroutines and
886871
this new syntax, see `PEP 492 <https://www.python.org/dev/peps/pep-0492/>`_.

docs/source/python2.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ overly long type comments and it's often tricky to see which argument
6666
type corresponds to which argument. The alternative, multi-line
6767
annotation syntax makes long annotations easier to read and write.
6868

69-
.. note::
70-
71-
Multi-line comment annotations currently only work when using the
72-
``--fast-parser`` command line option. This is not enabled by
73-
default because the option isn’t supported on Windows yet.
74-
7569
Here is an example (from PEP 484):
7670

7771
.. code-block:: python

mypy/checker.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,9 +1836,8 @@ def visit_assert_stmt(self, s: AssertStmt) -> None:
18361836
if s.msg is not None:
18371837
self.expr_checker.accept(s.msg)
18381838

1839-
if self.options.fast_parser:
1840-
if isinstance(s.expr, TupleExpr) and len(s.expr.items) > 0:
1841-
self.warn(messages.MALFORMED_ASSERT, s)
1839+
if isinstance(s.expr, TupleExpr) and len(s.expr.items) > 0:
1840+
self.warn(messages.MALFORMED_ASSERT, s)
18421841

18431842
# If this is asserting some isinstance check, bind that type in the following code
18441843
true_map, _ = self.find_isinstance_check(s.expr)

mypy/main.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,6 @@ def add_invertible_flag(flag: str,
236236
add_invertible_flag('--show-error-context', default=False,
237237
dest='show_error_context',
238238
help='Precede errors with "note:" messages explaining context')
239-
add_invertible_flag('--no-fast-parser', default=True, dest='fast_parser',
240-
help="disable the fast parser (not recommended)")
241239
parser.add_argument('-i', '--incremental', action='store_true',
242240
help="enable module cache")
243241
parser.add_argument('--quick-and-dirty', action='store_true',
@@ -306,6 +304,11 @@ def add_invertible_flag(flag: str,
306304
parser.add_argument('--almost-silent', action='store_true',
307305
dest='special-opts:almost_silent',
308306
help=argparse.SUPPRESS)
307+
parser.add_argument('--fast-parser', action='store_true', dest='special-opts:fast_parser',
308+
help=argparse.SUPPRESS)
309+
parser.add_argument('--no-fast-parser', action='store_true',
310+
dest='special-opts:no_fast_parser',
311+
help=argparse.SUPPRESS)
309312

310313
report_group = parser.add_argument_group(
311314
title='report generation',
@@ -376,6 +379,11 @@ def add_invertible_flag(flag: str,
376379
print("Warning: -f/--dirty-stubs is deprecated and no longer necessary. Mypy no longer "
377380
"checks the git status of stubs.",
378381
file=sys.stderr)
382+
if special_opts.fast_parser:
383+
print("Warning: --fast-parser is now the default (and only) parser.")
384+
if special_opts.no_fast_parser:
385+
print("Warning: --no-fast-parser no longer has any effect. The fast parser "
386+
"is now mypy's default and only parser.")
379387

380388
# Check for invalid argument combinations.
381389
if require_targets:

mypy/options.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ def __init__(self) -> None:
101101
# Write junit.xml to given file
102102
self.junit_xml = None # type: Optional[str]
103103

104-
# Fast parser is on by default
105-
self.fast_parser = True
106-
107104
# Caching options
108105
self.incremental = False
109106
self.cache_dir = defaults.CACHE_DIR

mypy/stubgen.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,13 @@
7373
('modules', List[str]),
7474
('ignore_errors', bool),
7575
('recursive', bool),
76-
('fast_parser', bool),
7776
])
7877

7978

8079
def generate_stub_for_module(module: str, output_dir: str, quiet: bool = False,
8180
add_header: bool = False, sigs: Dict[str, str] = {},
8281
class_sigs: Dict[str, str] = {},
8382
pyversion: Tuple[int, int] = defaults.PYTHON3_VERSION,
84-
fast_parser: bool = False,
8583
no_import: bool = False,
8684
search_path: List[str] = [],
8785
interpreter: str = sys.executable) -> None:
@@ -109,7 +107,7 @@ def generate_stub_for_module(module: str, output_dir: str, quiet: bool = False,
109107
target = os.path.join(output_dir, target)
110108
generate_stub(module_path, output_dir, module_all,
111109
target=target, add_header=add_header, module=module,
112-
pyversion=pyversion, fast_parser=fast_parser)
110+
pyversion=pyversion)
113111
if not quiet:
114112
print('Created %s' % target)
115113

@@ -174,13 +172,12 @@ def load_python_module_info(module: str, interpreter: str) -> Tuple[str, Optiona
174172

175173
def generate_stub(path: str, output_dir: str, _all_: Optional[List[str]] = None,
176174
target: str = None, add_header: bool = False, module: str = None,
177-
pyversion: Tuple[int, int] = defaults.PYTHON3_VERSION,
178-
fast_parser: bool = False) -> None:
175+
pyversion: Tuple[int, int] = defaults.PYTHON3_VERSION
176+
) -> None:
179177
with open(path, 'rb') as f:
180178
source = f.read()
181179
options = MypyOptions()
182180
options.python_version = pyversion
183-
options.fast_parser = fast_parser
184181
try:
185182
ast = mypy.parse.parse(source, fnam=path, errors=None, options=options)
186183
except mypy.errors.CompileError as e:
@@ -623,7 +620,6 @@ def main() -> None:
623620
sigs=sigs,
624621
class_sigs=class_sigs,
625622
pyversion=options.pyversion,
626-
fast_parser=options.fast_parser,
627623
no_import=options.no_import,
628624
search_path=options.search_path,
629625
interpreter=options.interpreter)
@@ -643,7 +639,6 @@ def parse_options() -> Options:
643639
doc_dir = ''
644640
search_path = [] # type: List[str]
645641
interpreter = ''
646-
fast_parser = False
647642
while args and args[0].startswith('-'):
648643
if args[0] == '--doc-dir':
649644
doc_dir = args[1]
@@ -658,8 +653,6 @@ def parse_options() -> Options:
658653
args = args[1:]
659654
elif args[0] == '--recursive':
660655
recursive = True
661-
elif args[0] == '--fast-parser':
662-
fast_parser = True
663656
elif args[0] == '--ignore-errors':
664657
ignore_errors = True
665658
elif args[0] == '--py2':
@@ -682,8 +675,7 @@ def parse_options() -> Options:
682675
interpreter=interpreter,
683676
modules=args,
684677
ignore_errors=ignore_errors,
685-
recursive=recursive,
686-
fast_parser=fast_parser)
678+
recursive=recursive)
687679

688680

689681
def default_python2_interpreter() -> str:
@@ -711,7 +703,6 @@ def usage() -> None:
711703
Options:
712704
--py2 run in Python 2 mode (default: Python 3 mode)
713705
--recursive traverse listed modules to generate inner package modules as well
714-
--fast-parser enable experimental fast parser
715706
--ignore-errors ignore errors when trying to generate stubs for modules
716707
--no-import don't import the modules, just parse and analyze them
717708
(doesn't work with C extension modules and doesn't

mypy/test/testcheck.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
# List of files that contain test case descriptions.
2828
files = [
29-
]
30-
fast_parser_files = [
3129
'check-basic.test',
3230
'check-callable.test',
3331
'check-classes.test',
@@ -77,8 +75,6 @@
7775
'check-classvar.test',
7876
]
7977

80-
files.extend(fast_parser_files)
81-
8278

8379
class TypeCheckSuite(DataSuite):
8480
def __init__(self, *, update_data: bool = False) -> None:
@@ -157,8 +153,6 @@ def run_case_once(self, testcase: DataDrivenTestCase, incremental: int = 0) -> N
157153
options.strict_optional = True
158154
if incremental:
159155
options.incremental = True
160-
if os.path.split(testcase.file)[1] in fast_parser_files:
161-
options.fast_parser = True
162156

163157
sources = []
164158
for module_name, program_path, program_text in module_data:

0 commit comments

Comments
 (0)