Skip to content

pyclbr not recursively showing classes in packages #68862

Open

Description

@worenklein
BPO 24674
Files
  • pyclbr.patch: Patch to pyclbr.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2015-07-20.13:26:41.246>
    labels = []
    title = 'pyclbr not recursively showing classes in packages'
    updated_at = <Date 2015-07-20.13:29:27.928>
    user = 'https://bugs.python.org/worenklein'

    bugs.python.org fields:

    activity = <Date 2015-07-20.13:29:27.928>
    actor = 'worenklein'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = []
    creation = <Date 2015-07-20.13:26:41.246>
    creator = 'worenklein'
    dependencies = []
    files = ['39961']
    hgrepos = []
    issue_num = 24674
    keywords = ['patch']
    message_count = 2.0
    messages = ['246990', '246991']
    nosy_count = 1.0
    nosy_names = ['worenklein']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue24674'
    versions = ['Python 2.7']

    Activity

    1. worenklein commented on Jul 20, 2015

      worenkleinmannequin
      MannequinAuthor

      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.

    2. worenklein commented on Jul 20, 2015

      worenkleinmannequin
      MannequinAuthor

      P.S. Here are the results after the patch:
      C => ['foo.module.B', 'foo.module.A', 'object']

    3. transferred this issue fromon Apr 10, 2022
    4. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Nov 27, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directory

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions