--- a/src/eric7/UI/BrowserModel.py Tue Jan 02 14:06:09 2024 +0100 +++ b/src/eric7/UI/BrowserModel.py Tue Jan 02 16:08:13 2024 +0100 @@ -691,26 +691,30 @@ except ImportError: return - keys = list(dictionary) - if len(keys) > 0: + if bool(dictionary): if repopulate: - last = len(keys) - 1 - if "@@Coding@@" in keys and not Preferences.getUI("BrowserShowCoding"): + last = len(dictionary) - 1 + if "@@Coding@@" in dictionary and not Preferences.getUI( + "BrowserShowCoding" + ): last -= 1 self.beginInsertRows( self.createIndex(parentItem.row(), 0, parentItem), 0, last ) - for key in keys: + for key in dictionary: if key.startswith("@@"): # special treatment done later continue cl = dictionary[key] with contextlib.suppress(AttributeError): if cl.module == moduleName: - node = BrowserClassItem(parentItem, cl, fileName) + if isinstance(cl, ClbrBaseClasses.Class): + node = BrowserClassItem(parentItem, cl, fileName) + elif isinstance(cl, ClbrBaseClasses.Function): + node = BrowserMethodItem(parentItem, cl, fileName) self._addItem(node, parentItem) - if "@@Coding@@" in keys and Preferences.getUI("BrowserShowCoding"): + if "@@Coding@@" in dictionary and Preferences.getUI("BrowserShowCoding"): node = BrowserCodingItem( parentItem, QCoreApplication.translate("BrowserModel", "Coding: {0}").format( @@ -719,19 +723,19 @@ dictionary["@@Coding@@"].linenumber, ) self._addItem(node, parentItem) - if "@@Globals@@" in keys: + if "@@Globals@@" in dictionary: node = BrowserGlobalsItem( parentItem, dictionary["@@Globals@@"].globals, QCoreApplication.translate("BrowserModel", "Globals"), ) self._addItem(node, parentItem) - if "@@Import@@" in keys or "@@ImportFrom@@" in keys: + if "@@Import@@" in dictionary or "@@ImportFrom@@" in dictionary: node = BrowserImportsItem( parentItem, QCoreApplication.translate("BrowserModel", "Imports") ) self._addItem(node, parentItem) - if "@@Import@@" in keys: + if "@@Import@@" in dictionary: for importedModule in ( dictionary["@@Import@@"].getImports().values() ): @@ -882,6 +886,8 @@ keys.append((name, "c")) for name in fn.methods: keys.append((name, "m")) + for name in fn.attributes: + keys.append((name, "a")) if len(keys) > 0: if repopulate: @@ -893,6 +899,8 @@ node = BrowserClassItem(parentItem, fn.classes[key], file_) elif kind == "m": node = BrowserMethodItem(parentItem, fn.methods[key], file_) + elif kind == "a": + node = BrowserClassAttributeItem(parentItem, fn.attributes[key]) self._addItem(node, parentItem) if repopulate: self.endInsertRows() @@ -1841,7 +1849,9 @@ # ", ".join([e.split('=')[0].strip() # for e in self._functionObject.parameters])) if self._functionObject and ( - self._functionObject.methods or self._functionObject.classes + self._functionObject.methods + or self._functionObject.classes + or self._functionObject.attributes ): self._populated = False self._lazyPopulation = True