Skip to content

Commit

Permalink
Removed attribute check for decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
micahhausler committed Apr 1, 2015
1 parent 70a0bf3 commit e0b5bf3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
Release Notes
=============

v0.3
----
* ``compare_on_attr`` decorator no longer checks that class has attribute

v0.2
----
Fixed tests for Python 2
* Fixed tests for Python 2

v0.1
----

* This is the initial release of python3-utils.
9 changes: 7 additions & 2 deletions python3_utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ class compare_on_attr(object):
"""
A decorator for comparing class attributes. By default, the decorator
searches for an 'id' attribute on your class, but other attributes can be
specified.
specified. The original use for this decorator is to compare Django models
in Pandas DataFrames.
This decorator assumes the class you are decorating has the appropriate
attribute, and will raise an error when comparing a class without the
correct attribute.
Usage:
Expand Down Expand Up @@ -40,7 +45,7 @@ def __call__(self, func):
return self.decorate_class(func)

def decorate_class(self, cls):
if hasattr(cls, self.attr) and six.PY3:
if six.PY3:
def lt(this, other):
return getattr(this, self.attr) < getattr(other, self.attr)
cls.__lt__ = lt
Expand Down
2 changes: 1 addition & 1 deletion python3_utils/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2'
__version__ = '0.3'

0 comments on commit e0b5bf3

Please sign in to comment.