Skip to content

understand implicit generic context of a Callable annotation #1136

@RubenVanEldik

Description

@RubenVanEldik

Summary

I am not completely sure if this is an issue with ty or Streamlit, but the maintainers of Streamlit think that this might be an issue with ty.

ty raises an error for st.stop() as it does not understand that st.stop() will never return. Even though st.stop() has NoReturn as return type.

As far as I understand the issue, this is not related to #180.

import typing

import streamlit as st

def my_func() -> typing.NoReturn:
    st.write("Hello world")
    st.stop()

my_func()
error[invalid-return-type]: Function always implicitly returns `None`, which is not assignable to return type `Never`
 --> main.py:5:18
  |
3 | import streamlit as st
4 |
5 | def my_func() -> typing.NoReturn:
  |                  ^^^^^^^^^^^^^^^
6 |     st.write("Hello world")
7 |     st.stop()
  |
info: Consider changing the return annotation to `-> None` or adding a `return` statement
info: rule `invalid-return-type` is enabled by default

Found 1 diagnostic

I used ty 0.0.1-alpha.20 here

Version

No response

Metadata

Metadata

Assignees

Labels

genericsBugs or features relating to ty's generics implementation

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions