Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Union of T and Any doesn't conform to T (T is a type variable) #2054

Closed
Azureblade3808 opened this issue Nov 9, 2021 · 2 comments
Closed
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@Azureblade3808
Copy link

Azureblade3808 commented Nov 9, 2021

Environment data

  • Language Server version: 2021.11.1-pre.1
  • OS and version: Window 7 x64
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.12 Anaconda

Sample code

from __future__ import annotations

from typing import Callable, TypeVar

T = TypeVar("T")

def get_value(key: str, gen: Callable[[], T]) -> T:
    try:
        value = globals()[key]  # Any
    except KeyError:
        value = gen()  # T
    return value  # Any | T

Expected behavior

No warning.

Actual behavior

image

Additional info

There would be no warning if the type of value were either T or Any instead of a union.

@github-actions github-actions bot added the triage label Nov 9, 2021
@erictraut
Copy link
Contributor

Thanks for the bug report. This will be fixed in the next release.

@erictraut erictraut added bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed triage labels Nov 9, 2021
@heejaechang
Copy link
Contributor

fixed in 2021.11.1 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants