Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc58be0

Browse files
authored
Enable new semantic analyzer by default (#7174)
The old semantic analyzer is still there and can be used with `--no-new-semantic-analyzer`. For running tests one can use `NEWSEMANAL=0`.
1 parent e7ddba1 commit dc58be0

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ jobs:
2222
python: 3.6 # 3.6.3 pip 9.0.1
2323
- name: "run test suite with python 3.7"
2424
python: 3.7 # 3.7.0 pip 10.0.1
25-
- name: "run test suite with python 3.5.1 (new semantic analyzer)"
25+
- name: "run test suite with python 3.5.1 (old semantic analyzer)"
2626
python: 3.5.1
2727
dist: trusty
2828
env:
2929
- TOXENV=py
3030
- EXTRA_ARGS="-n 12"
31-
- NEWSEMANAL=1
32-
- name: "run test suite with python 3.7 (new semantic analyzer)"
31+
- NEWSEMANAL=0
32+
- name: "run test suite with python 3.7 (old semantic analyzer)"
3333
python: 3.7
3434
env:
3535
- TOXENV=py
3636
- EXTRA_ARGS="-n 12"
37-
- NEWSEMANAL=1
37+
- NEWSEMANAL=0
3838
- name: "run test suite with python 3.7 (compiled with mypyc)"
3939
python: 3.7
4040
env:

docs/source/command_line.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -659,18 +659,17 @@ Miscellaneous
659659
have many scripts that import a large package, the behavior enabled
660660
by this flag is often more convenient.)
661661

662-
``--new-semantic-analyzer``
663-
This flag switches to an improved, experimental implementation of
662+
``--no-new-semantic-analyzer``
663+
This flag disables the improved implementation of
664664
the *semantic analyzer* (the part of mypy that binds Python
665665
names to definitions). The old and the new semantic analyzers
666666
mostly behave identically. The new semantic analyzer is better at
667667
handling import cycles and forward references to definitions. It
668668
also fixes inconsistencies between the daemon and non-daemon modes,
669669
and it detects additional error conditions.
670670

671-
Likely, the next mypy release will use the new semantic analyzer by
672-
default, and the old semantic analyzer will be removed in the next
673-
release after that.
671+
Likely, the old semantic analyzer will be removed in the next
672+
release.
674673

675674
.. _PEP 420: https://www.python.org/dev/peps/pep-0420/
676675

docs/source/config_file.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,6 @@ Miscellaneous
470470
``verbosity`` (integer, default 0)
471471
Controls how much debug output will be generated. Higher numbers are more verbose.
472472

473-
``new_semantic_analyzer`` (bool, default False)
474-
Enables the experimental new semantic analyzer.
473+
``new_semantic_analyzer`` (bool, default True)
474+
Enables the new, improved, semantic analyzer.
475475
(See :ref:`The mypy command line <command-line>` for more information.)

mypy/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ def add_invertible_flag(flag: str,
554554
"the contents of SHADOW_FILE instead.")
555555
add_invertible_flag('--fast-exit', default=False, help=argparse.SUPPRESS,
556556
group=internals_group)
557-
add_invertible_flag('--new-semantic-analyzer', default=False, help=argparse.SUPPRESS,
557+
add_invertible_flag('--no-new-semantic-analyzer', dest='new_semantic_analyzer',
558+
default=True, help=argparse.SUPPRESS,
558559
group=internals_group)
559560

560561
error_group = parser.add_argument_group(

mypy/options.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ def __init__(self) -> None:
8787
self.namespace_packages = False
8888

8989
# Use the new semantic analyzer
90-
self.new_semantic_analyzer = bool(os.getenv('NEWSEMANAL'))
90+
new_analyzer = os.getenv('NEWSEMANAL')
91+
if new_analyzer:
92+
# Use NEWSEMANAL=0 to change the default (for tests).
93+
self.new_semantic_analyzer = bool(int(new_analyzer))
94+
else:
95+
self.new_semantic_analyzer = True
9196

9297
# disallow_any options
9398
self.disallow_any_generics = False

0 commit comments

Comments
 (0)