twilio / twilio-python

A Python module for communicating with the Twilio API and generating TwiML.
MIT License
1.83k stars 699 forks source link

Repeated code #776

Open DLJ7666 opened 5 months ago

DLJ7666 commented 5 months ago

Issue Summary

There are some classes in the twilio/base folder which are basically a copy-paste between each other. Couldn't just they be implemented in the way TwilioException is, as an abstract interface, which then each of these classes implementing such interface? I think this would be a better code practice than the currently version is,

tiwarishubham635 commented 5 months ago

Hi @DLJ7666! Will definitely take a look. Thanks!

miniluz commented 5 months ago

The classes I assume you are referring to (InstanceContext, InstanceResource, ListResource) are only identical because they are empty. They serve as abstract classes to be expanded upon. As a sample:

class ListResource(object):
    def __init__(self, version: Version):
        self._version = version

Since every class is only 3 lines long, two of them boilerplate, there really is no need to make an interface for them.