question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Type hint must be an 'Annotated' type.

See original GitHub issue

Hello,

I’m trying to run a simple example like:

from napari.layers import Image
import numpy as np

@magicgui
def my_widget(ny: int=64, nx: int=64) -> Image:
    return Image(np.random.rand(ny, nx), name='my Image')

And I get this error always. Also with others examples.

TypeError: Type hint must be an 'Annotated' type.

Maybe I’m missing something. Sorry if the question is too basic, I’m new on this.

Thanks

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tlambert03commented, Jun 10, 2021

Interesting… Thanks for the environment and traceback! I’ll try to dig a little deeper to see what might have caused it

0reactions
malj390commented, Jun 10, 2021

Not sure how but now it is working. I had some issues with Ipywidgets, so installed them again and now…it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

typing — Support for type hints — Python 3.11.1 documentation
The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers,...
Read more >
Type hints cheat sheet - mypy 0.991 documentation
Type hints cheat sheet#. This document is a quick cheat sheet showing how to use type annotations for various common types in Python....
Read more >
Why PyPy fails when I try to define type annotated class ...
Using list[str] with a __future__ import breaks typing.get_type_hints , though. Pretty much anything that wants to access the type at runtime ...
Read more >
Understanding type annotation in Python - LogRocket Blog
With type hints, you can annotate variables and functions with datatypes. Tools like mypy, pyright, pytypes, or pyre perform the functions of ...
Read more >
25.1. typing — Support for type hints — Python 3.6.1 ...
This module supports type hints as specified by PEP 484 and PEP 526. The most fundamental support consists of the types Any ,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found