twilio / twilio-python

A Python module for communicating with the Twilio API and generating TwiML.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Repeated code

DLJ7666 opened this issue · comments

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,

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

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.