This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pyclbr not recursively showing classes in packages
Type: Stage:
Components: Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: worenklein
Priority: normal Keywords: patch

Created on 2015-07-20 13:26 by worenklein, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
pyclbr.patch worenklein, 2015-07-20 13:26 Patch to pyclbr.py
Messages (2)
msg246990 - (view) Author: David Worenklein (worenklein) * Date: 2015-07-20 13:26
In the following example, pyclbr does not report that foo.module.A is a superclass of C:

__module2.py__
import foo.module
class C(foo.module.B):
    pass

__foo/module.py__
class A(object):
    def foo(self):
        print "bar"

class B(A):
    pass

__test.py__
import pyclbr

def superclasses_of(class_data):
    classes = [ class_data ]
    super_classes = []
    while classes:
        class_data = classes.pop()
        if isinstance(class_data, basestring):
            super_classes.append(class_data)
        else:
            super_classes.append( class_data.module+'.'+class_data.name )
            for c in class_data.super:
                classes.append( c )
    return super_classes

module = pyclbr.readmodule('module2',['.','./foo'])
for class_name, class_data in module.items():
    print "%s => %s" % (class_name, superclasses_of(class_data))

__results__
C => ['foo.module.B']

I've attached a patch to pyclbr.py to fix this.
msg246991 - (view) Author: David Worenklein (worenklein) * Date: 2015-07-20 13:29
P.S. Here are the results after the patch:
C => ['foo.module.B', 'foo.module.A', 'object']
History
Date User Action Args
2022-04-11 14:58:19adminsetgithub: 68862
2015-07-20 13:29:27worenkleinsetmessages: + msg246991
2015-07-20 13:26:41worenkleincreate