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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

(馃悶) No error when assigning non-concrete type object to variable of type bound with a union (Protocol, abstract) #13172

Open
KotlinIsland opened this issue Jul 18, 2022 · 2 comments
Labels
bug mypy got something wrong topic-join-v-union Using join vs. using unions

Comments

@KotlinIsland
Copy link
Contributor

from typing import Protocol, Callable
from abc import ABC, abstractmethod

class A(ABC):
    @abstractmethod
    def f(self) -> None: ...
    
class P(Protocol):
    a: int

ta1: type[A] = A   # error

ta2: type[A | P] = A  # no error

playground

@KotlinIsland KotlinIsland added the bug mypy got something wrong label Jul 18, 2022
@AlexWaygood AlexWaygood added the topic-join-v-union Using join vs. using unions label Jul 18, 2022
@AlexWaygood
Copy link
Member

This looks like it might be the inverse to #3115 ("join of two abstract classes being considered concrete", rather than "join of two concrete classes being considered abstract "). Not 100% sure about that diagnosis, though.

@KotlinIsland
Copy link
Contributor Author

Yeah, I found it in that exact case when I was implementing Unions at joins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-join-v-union Using join vs. using unions
Projects
None yet
Development

No branches or pull requests

2 participants