Skip to content

[tensorflow] Literal misspelled symmectric for pad function #13870

@julencw

Description

@julencw

Hi, there’s a mismatch in the TensorFlow stubs for tf.pad():

  • Location:

tensorflow-stubs/init.pyi (near the pad overload)

  • What is wrong:

The stub’s mode Literal includes a typo "symmectric" instead of "symmetric". That forces downstream code to adopt the typo in its own type annotations just to satisfy type checkers such as mypy:

def pad(
    tensor: TensorCompatible,
    paddings: Tensor | IntArray | Iterable[Iterable[int]],
    mode: Literal["CONSTANT", "constant", "REFLECT", "reflect", "SYMMETRIC", "symmectric"] = "CONSTANT",
    constant_values: ScalarTensorCompatible = 0,
    name: str | None = None,
) -> Tensor: ...

So any code calling tf.pad(..., mode="symmetric") or "SYMMETRIC" will type‐check fine, but if you annotate your wrapper’s mode: Literal[...] you must include "symmectric" to satisfy the stub, which is clearly wrong.

  • Quick repro:
from typing import Literal

import tensorflow as tf


def pad_tensor(
    pad_mode: Literal[
        "CONSTANT", "constant", "REFLECT", "reflect", "SYMMETRIC", "symmetric"
    ],
) -> None:
    x = tf.random.uniform((1, 4, 4, 3))
    x_padded = tf.pad(
        x,
        [[0, 0], [1, 1], [1, 1], [0, 0]],
        mode=pad_mode,
    )
    print(x_padded)

# mypy error: Argument "mode" to "pad" has incompatible type "Literal['CONSTANT', 'constant', 'REFLECT', 
# 'reflect', 'SYMMETRIC', 'symmetric']"; expected "Literal['CONSTANT', 'constant', 'REFLECT', 'reflect', 
# 'SYMMETRIC', 'symmectric']" Mypy[arg-type]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions