From d3b4eaa0a338495a9d083d515f9d31987c351854 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Tue, 16 Jul 2024 17:26:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20Fix=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lnschema_core/models.py | 45 +++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/lnschema_core/models.py b/lnschema_core/models.py index 9c079370..a37f49b8 100644 --- a/lnschema_core/models.py +++ b/lnschema_core/models.py @@ -489,26 +489,31 @@ def __new__(cls, name, bases, attrs, **kwargs): new_class = super().__new__(cls, name, bases, attrs, **kwargs) return new_class - def __dir__(cls): - # this is needed to bring auto-complete on the class-level back - # https://laminlabs.slack.com/archives/C04FPE8V01W/p1717535625268849 - # Filter class attributes, excluding instance methods - result = [ - attr - for attr in cls.__dict__.keys() - if not attr.startswith("__") - and not ( - callable(cls.__dict__[attr]) - and not isinstance( - cls.__dict__[attr], (classmethod, staticmethod, type) - ) - ) - ] - # Add non-dunder attributes from RegistryMeta - for attr in dir(RegistryMeta): - if not attr.startswith("__") and attr not in result: - result.append(attr) - return result + # this breaks the method documentation in the docs silently + # it also doesn't have any effect for static type analyzer like pylance + # used in VSCode + # this only solves the problem for Jupyter Editors + # + # def __dir__(cls): + # # this is needed to bring auto-complete on the class-level back + # # https://laminlabs.slack.com/archives/C04FPE8V01W/p1717535625268849 + # # Filter class attributes, excluding instance methods + # result = [ + # attr + # for attr in cls.__dict__.keys() + # if not attr.startswith("__") + # and not ( + # callable(cls.__dict__[attr]) + # and not isinstance( + # cls.__dict__[attr], (classmethod, staticmethod, type) + # ) + # ) + # ] + # # Add non-dunder attributes from RegistryMeta + # for attr in dir(RegistryMeta): + # if not attr.startswith("__") and attr not in result: + # result.append(attr) + # return result def from_values( cls,