Skip to content

No autocompletion and syntax highlighting in callback for typer.Context but they work using click.Context #346

@Minipada

Description

@Minipada

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Typer documentation, with the integrated search.
  • I already searched in Google "How to X in Typer" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to Typer but to Click.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

import click
import typer

def validate_name_typer(ctx: typer.Context, param: typer.CallbackParam, value: str) -> str:
    params = ctx.command.params # Autocompletion and syntax highlighting don't work
    return value

def validate_name_click(ctx: click.Context, param: typer.CallbackParam, value: str) -> str:
    params = ctx.command.params # Autocompletion and syntax highlighting work
    return value

def main(name: str= typer.Option(...,callback=validate_name_typer)):
    typer.echo(f"Hello {name}")


if __name__ == "__main__":
    typer.run(main)

Description

On VSCode, I don't have autocompletion for the context in a callback. I am not sure where it comes from but this definitely seems a typer issue since it is working with Click.

image
image

I added both in the example.

EDIT: I am here trying to get other options from this callback.

Operating System

Linux

Operating System Details

$ cat /etc/os-release 

NAME="Manjaro Linux"
ID=manjaro
ID_LIKE=arch
BUILD_ID=rolling
PRETTY_NAME="Manjaro Linux"
ANSI_COLOR="32;1;24;144;200"
HOME_URL="https://manjaro.org/"
DOCUMENTATION_URL="https://wiki.manjaro.org/"
SUPPORT_URL="https://manjaro.org/"
BUG_REPORT_URL="https://bugs.manjaro.org/"
LOGO=manjarolinux

Typer Version

0.4.0

Python Version

3.9.9

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion or problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions