Skip to content

Commit

Permalink
Remove some unused functions. (#18049)
Browse files Browse the repository at this point in the history
This PR just removes some functions that are unused (from what I can
tell).
  • Loading branch information
johndoknjas authored Oct 25, 2024
1 parent 55b5aed commit afdafb6
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 66 deletions.
6 changes: 0 additions & 6 deletions mypy/traverser.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,9 +958,3 @@ def visit_assignment_stmt(self, stmt: AssignmentStmt) -> None:

def visit_yield_from_expr(self, expr: YieldFromExpr) -> None:
self.yield_from_expressions.append((expr, self.in_assignment))


def all_yield_from_expressions(node: Node) -> list[tuple[YieldFromExpr, bool]]:
v = YieldFromCollector()
node.accept(v)
return v.yield_from_expressions
9 changes: 0 additions & 9 deletions mypy/typeanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2276,15 +2276,6 @@ def set_any_tvars(
return t


def flatten_tvars(lists: list[list[T]]) -> list[T]:
result: list[T] = []
for lst in lists:
for item in lst:
if item not in result:
result.append(item)
return result


class DivergingAliasDetector(TrivialSyntheticTypeTranslator):
"""See docstring of detect_diverging_alias() for details."""

Expand Down
10 changes: 0 additions & 10 deletions mypy/typevartuples.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
from mypy.types import (
AnyType,
Instance,
ProperType,
Type,
TypeVarLikeType,
TypeVarTupleType,
UnpackType,
get_proper_type,
split_with_prefix_and_suffix,
)

Expand All @@ -27,14 +25,6 @@ def split_with_instance(
)


def extract_unpack(types: Sequence[Type]) -> ProperType | None:
"""Given a list of types, extracts either a single type from an unpack, or returns None."""
if len(types) == 1:
if isinstance(types[0], UnpackType):
return get_proper_type(types[0].type)
return None


def erased_vars(type_vars: Sequence[TypeVarLikeType], type_of_any: int) -> list[Type]:
args: list[Type] = []
for tv in type_vars:
Expand Down
22 changes: 0 additions & 22 deletions mypyc/analysis/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from abc import abstractmethod
from typing import Dict, Generic, Iterable, Iterator, Set, Tuple, TypeVar

from mypyc.ir.func_ir import all_values
from mypyc.ir.ops import (
Assign,
AssignMulti,
Expand Down Expand Up @@ -437,27 +436,6 @@ def visit_set_mem(self, op: SetMem) -> GenAndKill[Value]:
return set(), set()


def analyze_undefined_regs(
blocks: list[BasicBlock], cfg: CFG, initial_defined: set[Value]
) -> AnalysisResult[Value]:
"""Calculate potentially undefined registers at each CFG location.
A register is undefined if there is some path from initial block
where it has an undefined value.
Function arguments are assumed to be always defined.
"""
initial_undefined = set(all_values([], blocks)) - initial_defined
return run_analysis(
blocks=blocks,
cfg=cfg,
gen_and_kill=UndefinedVisitor(),
initial=initial_undefined,
backward=False,
kind=MAYBE_ANALYSIS,
)


def non_trivial_sources(op: Op) -> set[Value]:
result = set()
for source in op.sources():
Expand Down
15 changes: 0 additions & 15 deletions mypyc/codegen/emitmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
use_vectorcall,
)
from mypyc.errors import Errors
from mypyc.ir.class_ir import ClassIR
from mypyc.ir.func_ir import FuncIR
from mypyc.ir.module_ir import ModuleIR, ModuleIRs, deserialize_modules
from mypyc.ir.ops import DeserMaps, LoadLiteral
Expand Down Expand Up @@ -1075,20 +1074,6 @@ def declare_type_vars(self, module: str, type_var_names: list[str], emitter: Emi
)


def sort_classes(classes: list[tuple[str, ClassIR]]) -> list[tuple[str, ClassIR]]:
mod_name = {ir: name for name, ir in classes}
irs = [ir for _, ir in classes]
deps: dict[ClassIR, set[ClassIR]] = {}
for ir in irs:
if ir not in deps:
deps[ir] = set()
if ir.base:
deps[ir].add(ir.base)
deps[ir].update(ir.traits)
sorted_irs = toposort(deps)
return [(mod_name[ir], ir) for ir in sorted_irs]


T = TypeVar("T")


Expand Down
4 changes: 0 additions & 4 deletions mypyc/irbuild/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,10 +990,6 @@ def singledispatch_main_func_name(orig_name: str) -> str:
return f"__mypyc_singledispatch_main_function_{orig_name}__"


def get_registry_identifier(fitem: FuncDef) -> str:
return f"__mypyc_singledispatch_registry_{fitem.fullname}__"


def maybe_insert_into_registry_dict(builder: IRBuilder, fitem: FuncDef) -> None:
line = fitem.line
is_singledispatch_main_func = fitem in builder.singledispatch_impls
Expand Down

0 comments on commit afdafb6

Please sign in to comment.