Repository: davebshow/goblin

Issue:
Issues with Sphinx: `VertexProperty` Missing Attribute
Build failure in sphinx:

```
  File "/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 862, in filter_members
    not keep, self.options)
  File "/lib/python3.5/site-packages/sphinx/application.py", line 593, in emit_firstresult
    for result in self.emit(event, *args):
  File "/lib/python3.5/site-packages/sphinx/application.py", line 589, in emit
    results.append(callback(self, *args))
  File "/lib/python3.5/site-packages/sphinxcontrib/napoleon/__init__.py", line 428, in _skip_member
    qualname = getattr(obj, '__qualname__', '')
  File "/lib/python3.5/site-packages/goblin/element.py", line 211, in __repr__
    self._data_type, self.value)
  File "/lib/python3.5/site-packages/goblin/element.py", line 194, in getvalue
    return self._val
AttributeError: 'SubOption' object has no attribute '_val'
```

`SubOption` is a sub-class of `VertexProperty`:

```python
class SubOption(goblin.VertexProperty):
    a = goblin.Property(goblin.Boolean, default=True)
    b = goblin.Property(goblin.Boolean, default=True)
```

I hacked `element.py` to get my build to pass by adding `self._val = None` to the class initializer for `VertexProperty` (https://github.com/davebshow/goblin/blob/master/goblin/element.py#L183).

Discussion:

Patch:
diff --git a/goblin/element.py b/goblin/element.py
index a80d427..ff5e37b 100644
--- a/goblin/element.py
+++ b/goblin/element.py
@@ -178,6 +178,7 @@ class VertexProperty(Vertex, abc.BaseProperty):
         self._data_type = data_type
         self._default = default
         self._db_name = db_name
+        self._val = None
         if card is None:
             card = Cardinality.single
         self._cardinality = card


Test patch:
diff --git a/tests/test_properties.py b/tests/test_properties.py
index cff8ded..10d546a 100644
--- a/tests/test_properties.py
+++ b/tests/test_properties.py
@@ -76,6 +76,12 @@ def test_set_change_vertex_property(person):
     person.birthplace = 'U of I Hospital'
     assert person.birthplace.value == 'U of I Hospital'
 
+def test_vertex_property_default():
+    """Makes sure that a brand new VertexProperty (i.e., with no value set) is
+    still representable. Addresses issue #52.
+    """
+    vp = element.VertexProperty(int)
+    assert repr(vp) == "<VertexProperty(type=0, value=None)"
 
 def test_validate_vertex_prop(person):
     assert not person.birthplace