How to define a property as part of a Protocol

Viewed 245

Could somebody please clarify the generally accepted way of defining a property as part of a Protocol?

I've been doing it like so:

from typing import Protocol

class MyProtocol(Protocol):
    @property
    def my_property(self):
        """ Classes should have a my_property to conform to MyProtocol """

But Pycharm's built-in linter keeps complaining that a "Getter should return or yield something", hence my confusion. Raising a NotImplementedError makes the linter message go away, but doing that seems to fit more with an abstract class than with a Protocol.

0 Answers
Related