Skip to content

click.secho is improperly typed #2174

@Jonxslays

Description

@Jonxslays

The file argument for click.secho is missing part of its typehint causing the entire secho function to be untyped.
This is not flagged by mypy strict mode, but does in pyright strict mode.


Install pyright and click

python -m venv .venv && source .venv/bin/activate
pip install click pyright

Create a py file

# main.py

import click

click.secho("hello")

Set pyright to strict mode

# pyproject.toml

[tool.pyright]
typeCheckingMode = "strict"

Run pyright

pyright main.py

Result:

error: Type of "secho" is partially unknown
    Type of "secho" is "(message: Any | None = None, file: IO[Unknown] | None = None, nl: bool = True, err: bool = False, color: bool | None = None, **styles: Any) -> None" (reportUnknownMemberType)

The function should not produce a typing error. I will PR a fix for this momentarily.


Environment:

  • Python version: 3.10.1
  • Click version: 8.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions