Skip to content

Commit

Permalink
Clean up new_semantic_analyzer
Browse files Browse the repository at this point in the history
This has been very dead for years, no plugin I can tell is using it
  • Loading branch information
hauntsaninja committed Oct 30, 2024
1 parent 58f7628 commit 879b548
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 16 deletions.
7 changes: 1 addition & 6 deletions mypy/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,7 @@ def parse_section(
)
continue
else:
dv = None
# We have to keep new_semantic_analyzer in Options
# for plugin compatibility but it is not a valid option anymore.
assert hasattr(template, "new_semantic_analyzer")
if key != "new_semantic_analyzer":
dv = getattr(template, key, None)
dv = getattr(template, key, None)
if dv is None:
if key.endswith("_report"):
report_type = key[:-7].replace("_", "-")
Expand Down
7 changes: 1 addition & 6 deletions mypy/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,17 +400,12 @@ def use_or_syntax(self) -> bool:
def use_star_unpack(self) -> bool:
return self.python_version >= (3, 11)

# To avoid breaking plugin compatibility, keep providing new_semantic_analyzer
@property
def new_semantic_analyzer(self) -> bool:
return True

def snapshot(self) -> dict[str, object]:
"""Produce a comparable snapshot of this Option"""
# Under mypyc, we don't have a __dict__, so we need to do worse things.
d = dict(getattr(self, "__dict__", ()))
for k in get_class_descriptors(Options):
if hasattr(self, k) and k != "new_semantic_analyzer":
if hasattr(self, k):
d[k] = getattr(self, k)
# Remove private attributes from snapshot
d = {k: v for k, v in d.items() if not k.startswith("_")}
Expand Down
3 changes: 0 additions & 3 deletions mypy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ class C: pass
Note that a forward reference in a function signature won't trigger another
pass, since all functions are processed only after the top level has been fully
analyzed.
You can use `api.options.new_semantic_analyzer` to check whether the new
semantic analyzer is enabled (it's always true in mypy 0.730 and later).
"""

from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion mypyc/irbuild/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def get_assignment_target(
if isinstance(symbol, Decorator):
symbol = symbol.func
if symbol is None:
# New semantic analyzer doesn't create ad-hoc Vars for special forms.
# Semantic analyzer doesn't create ad-hoc Vars for special forms.
assert lvalue.is_special_form
symbol = Var(lvalue.name)
if not for_read and isinstance(symbol, Var) and symbol.is_cls:
Expand Down

0 comments on commit 879b548

Please sign in to comment.