AdvancedClimateSystems / uModbus

Python implementation of the Modbus protocol.
Mozilla Public License 2.0
211 stars 81 forks source link

Change factory methods to class methods #103

Closed rgov closed 4 years ago

rgov commented 4 years ago

Instead of declaring the create_from_request_pdu and create_from_response_pdu factory methods as @staticmethod, use @classmethod. Then the class is passed to the method as the cls parameter, which can be used to instantiate an instance, rather than hardcoding the class name.

This allows the function classes to be subclassed without having to reimplement the factory methods just to change the class name.

Also fixes up some comments that were incorrect.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 95.824% when pulling ba7c73b0e5a3de18cd235a9b6998e11f3abffe53 on rgov:rzg/fix_factory_methods into 0faaf904f67327ebdff89b936d5c06a801ad7da7 on AdvancedClimateSystems:master.