Source code for nv_dfm_core.api._if

# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Returns a value (usually the output of an Operation) to the client.
"""

from typing import Any, Literal

from pydantic import ConfigDict
from typing_extensions import override

from ._block import Block
from ._bool_expressions import BooleanExpression
from ._statement import Statement


[docs] class If(Statement, Block): """IfTrue is a statement that executes the body if the condition is true. Usage: cond = ... with If(cond=cond) as test: # body """ model_config: ConfigDict = ConfigDict(extra="forbid", frozen=True) dfm_class_name: Literal["nv_dfm_core.api.If"] = "nv_dfm_core.api.If" cond: BooleanExpression @override def accept(self, visitor: Any) -> None: visitor.visit_if(self)