Skip to content

TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' #371

@wizard-28

Description

@wizard-28

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

from __future__ import annotations

import typer

app = typer.Typer()


def main():
    app()


@app.command()
def test(flag: bool | None = typer.Option(None, "--flag", "-f", help="A flag")):
    print(flag)


if __name__ == "__main__":
    main()

Description

  1. Run the example code
  2. See the error: https://sourceb.in/SxyHEeLZxf

Operating System

Linux

Operating System Details

No response

Typer Version

0.4.0

Python Version

Python 3.8.10

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions