vsergeev / python-periphery

A pure Python 2/3 library for peripheral I/O (GPIO, LED, PWM, SPI, I2C, MMIO, Serial) in Linux.
MIT License
529 stars 139 forks source link

__enter__() should return self #17

Closed dmitriykovalev closed 4 years ago

dmitriykovalev commented 6 years ago

Current implementation (e.g. in gpio.py):

def __enter__(self):
    pass

Ideally should be

def __enter__(self):
    return self

to make the following example working:

with GPIO(10, "out") as pin:
     pin.write(True)
ukleinek commented 4 years ago

This is fixed since a05c229d98ad0460ec2221f25832f3cccf489fc1. There is only one instance left in tests/ which shouldn't be relevant to users of periphery.

vsergeev commented 4 years ago

Thanks for pointing that out @ukleinek. I pushed a commit to fix that one as well. As @ukleinek said, these are now fixed in master and will be included in the next release.