Skip to content

Instantly share code, notes, and snippets.

View dmytrostriletskyi's full-sized avatar

Dmytro Striletskyi dmytrostriletskyi

View GitHub Profile
class FileStorage:
def create_with_name(self, name):
...
if __name__ == '__main__':
if settings.config.storage = FileStorage:
storage = FileStorage()
if settings.config.storage = DatabaseStorage:
storage = DatabaseStorage()
user = User(storage=storage)
user.create_with_name(name=...)
from accessify import implements
class HumanInterface:
@staticmethod
def eat(food, *args, allergy=None, **kwargs):
pass
Traceback (most recent call last):
File "examples/interfaces/single.py", line 18, in <module>
@implements(HumanInterface)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/accessify/interfaces.py", line 66, in decorator
interface_method_arguments=interface_method.arguments_as_string,
accessify.errors.InterfaceMemberHasNotBeenImplementedException: class Human
does not implement interface member HumanInterface.eat(food, args, allergy, kwargs)
from accessify import implements
class HumanInterface:
@staticmethod
def eat(food, *args, allergy=None, **kwargs):
pass
Traceback (most recent call last):
File "examples/interfaces/single_arguments.py", line 16, in <module>
@implements(HumanInterface)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/accessify/interfaces.py", line 87, in decorator
interface_method_arguments=interface_method.arguments_as_string,
accessify.errors.InterfaceMemberHasNotBeenImplementedWithMismatchedArgumentsException:
class Human implements interface member HumanInterface.eat(food, args, allergy, kwargs)
with mismatched arguments
from accessify import implements, private
class HumanInterface:
@private
@staticmethod
def eat(food, *args, allergy=None, **kwargs):
pass
Traceback (most recent call last):
File "examples/interfaces/single_access.py", line 18, in <module>
@implements(HumanInterface)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/accessify/interfaces.py", line 77, in decorator
interface_method_name=interface_method.name,
accessify.errors.ImplementedInterfaceMemberHasIncorrectAccessModifierException:
Human.eat(food, args, allergy, kwargs) mismatches
HumanInterface.eat() member access modifier.
from accessify import implements
class HumanSoulInterface:
def love(self, who, *args, **kwargs):
pass
class HumanBasicsInterface:
Traceback (most recent call last):
File "examples/interfaces/multiple.py", line 19, in <module>
@implements(HumanSoulInterface, HumanBasicsInterface)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/accessify/interfaces.py", line 66, in decorator
interface_method_arguments=interface_method.arguments_as_string,
accessify.errors.InterfaceMemberHasNotBeenImplementedException:
class Human does not implement interface member
HumanBasicsInterface.eat(food, args, allergy, kwargs)