View>Function List python functions showing up outside of tree

  • Hello, I’m on NPP 7.8.1 and writing Python code. I’m having a problem when using View>Function List. When adding functions to a class in files I’ve been working on over a period of days and weeks, the functions are showing up outside of the class tree instead of in the class. At first I thought it was indentation issues, but that wasn’t the case. How can I figure out what the problem is and fix this?
    Thank you!

  • @MegMM

    Perhaps showing some examples of the abnormal behavior would be a great place to start?

  • Hi, hope the img below is what you mean. Every function between the Catalog class and main() should be showing up as a method in the Catalog class.

    Annotation 2019-12-19 134605.png

    If you’re asking for code, here’s a snippet of where the functions suddenly show outside of the Class. Thanks for any ideas!

        def convert_raw_title_to_standard(self, raw_title: str) -> str:
            tt = self.cleanup_raw_title(raw_title)
            tt = uutil.change_chars_to_space(tt, '-')
            tt = tt.title()
            return tt
        def make_links_from_soup(self, src_url: str, soup: BeautifulSoup) -> list:
            stories = []
            story = {}
            if bool(soup.find_all('div', class_='ftr')):
                div_rows = soup.find_all('div', class_='ftr')
                return stories
            for row in div_rows:
                self.entries_count = self.entries_count + 1
                if 'dir' in row.find('div').text.lower():
                    dir_type = 'dir'
                    story_dir = row.a['href']+'/'
                    story_dir = story_dir.replace(r'//', r'/')           
                    dir_type = 'text'
                    story_dir = row.a['href']
                story_dir = Path(self.src_url).joinpath(story_dir)
                title = self.convert_raw_title_to_standard(\
                story = CatEntry(**{
                    'id': str(self.entries_count),
                    'title': title,
                    'dir_type': dir_type,
                    'dir_name': Path(row.a['href']),
                    'url': story_dir, # local or web
            return stories                
        ### KEEP        
        def save_catalog_to_file(self, stories: list, file=WindowsPath):
            if not file.exists():
            with open(file, 'w+', encoding='utf-8') as cat:
                for story in stories:
                    cat.write('{0}, {1}, {2}, {3}, {4}\n'.format(
                        str(, story.title, story.dir_type, story.dir_name, story.url))

  • Wow, so I just tried deleting all the comments that were left and when I deleted

    ### Keep

    and saved, it repositioned the methods correctly. So I’m not sure if that’s a bug or intentional. Can anyone explain? Thank you!

Log in to reply