GithubHelp home page GithubHelp logo

purepy's People

Contributors

mccartnm avatar

Watchers

 avatar  avatar

purepy's Issues

Bug with properties

Because getattr() will follow through with the get on a property, we can have objects in a bad state.

from purepy import PureVirtualMeta, pure_virtual
class Foo(metaclass=PureVirtualMeta):
    def __init__(self):
        self._thing = 10

    @property
    def get_thing_math(self):
        return self.some_func(self._thing)

    @pure_virtual
    def some_func(self):
        raise NotImplementedError()

    def overload_me_to_not_pv(self, thing):
        raise NotImplementedError()

class Bar(Foo):
    def some_func(self, thing):
        self.overload_me_to_not_pv(thing)

# We don't have to overload overload_me_to_not_pv(), but when we make a Bar() object:
b = Bar()
# ...
# File "C:\virtualenv\pgfun\lib\site-packages\purepy\__init__.py", line 80, in __call__
#     functions = PureVirtualMeta.pure_virtual_functions(inst)
# File "C:\virtualenv\pgfun\lib\site-packages\purepy\__init__.py", line 154, in pure_virtual_functions
#    for name, call in inspect.getmembers(instance, predicate=PureVirtualMeta._predicate):
#  File "C:\Users\Michael McCartney\AppData\Local\Programs\Python\Python37\lib\inspect.py", line 341, in getmembers
#    value = getattr(object, key)
...
# raise NotImplementedError()

This is wrong because we don't want to evaluate the property. We just want to find the virtual functions. May have to rethink the design slightly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.