From d587e3351a5d93b6463f58ec5bab1fd16c11b7a9 Mon Sep 17 00:00:00 2001 From: Eric Wolf Date: Tue, 4 Oct 2022 18:21:00 +0200 Subject: [PATCH] mark DepthFirstVisitor as final and add slots --- lambda_calculus/visitors/walking.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lambda_calculus/visitors/walking.py b/lambda_calculus/visitors/walking.py index ac99738..90d164d 100644 --- a/lambda_calculus/visitors/walking.py +++ b/lambda_calculus/visitors/walking.py @@ -4,7 +4,7 @@ from __future__ import annotations from collections.abc import Iterator -from typing import TypeVar +from typing import TypeVar, final from .. import terms from . import BottomUpVisitor @@ -15,6 +15,7 @@ V = TypeVar("V") +@final class DepthFirstVisitor(BottomUpVisitor[Iterator["terms.Term[V]"], V]): """ Visitor yielding subterms depth first @@ -24,6 +25,8 @@ class DepthFirstVisitor(BottomUpVisitor[Iterator["terms.Term[V]"], V]): V: represents the type of variables used in terms """ + __slots__ = () + def visit_variable(self, variable: terms.Variable[V]) -> Iterator[terms.Term[V]]: """ Visit a Variable term.