Skip to content

Files

Latest commit

 

History

History
53 lines (36 loc) · 927 Bytes

README.md

File metadata and controls

53 lines (36 loc) · 927 Bytes

fuzzyattr

fuzzyattr matches the closest attribute name in python so you can make unlimited free typos.

usage

Decorate any class.

from fuzzyattr import fuzzyattr

@fuzzyattr
class Human:
    def __init__(self, name):
        self.name = name

    def eat(self, food):
        return f'{self.name} ate {food}'

Or wrap the class.

Human = fuzzyattr(Human)

Now you can make typos.

someone = Human('Someone')
someone.ate('poop')

ate doesn't exist. fuzzyattr matches eat. It logs a warning when this happens.

how is this useful?

Fix non-PEP8 code written by other morons. Make python standard library more pythonic.

BetterTestCase = fuzzyattr(unittest.TestCase)
    
class PythonicTest(BetterTestCase):
    def test_thing(self):
        self.assert_equal(True, False)
        # much better than assertEqual

install

pip install fuzzyattr