How to declare a Protocol with a field which is compatible with both a simple type and property?

152
July 08, 2021, at 12:20 PM

I want to create a Protocol, in which a field can be implemented by both a simple type and property. For example:

class P(Protocol):
    v: int

@dataclass
class Foo(P):
    v: int

class Bar(P):
    @property
    def v(self) -> int: # ERROR
        return 1

But the code above doesn't type check. How should I fix?

Note: I want to solve this issue without rewriting Foo and Bar, because Foo and Bar are not what I implemented.

READ ALSO
Converting PWA to native android webview app with notification

Converting PWA to native android webview app with notification

I have A PWA it has notification system, I want to convert it to native android webview appHow can i do it?

190
Src of an image with text + php variable

Src of an image with text + php variable

Hey i am having a hard time getting this to work I used this code

198
HI i like to spin this star i created and move it across canvas in javascript [closed]

HI i like to spin this star i created and move it across canvas in javascript [closed]

Want to improve this question? Update the question so it focuses on one problem only by editing this post

28