-
| How to return an uninstantiated class? my exampleclass Main:
    @classmethod
    def foo(cls) -> bool:
        return True
class Base(metaclass=ABCMeta):
    @classmethod
    @abstractmethod
    def get_test(cls) -> Main:
        return ...
class TestMain(Main):
    ...
class TestBase(Base):
    @classmethod
    def get_test(cls) -> ???:   # <------ How to write here?
        return TestMain
    @classmethod
    def run(cls) -> bool:
        return cls.get_test().foo()Pycharm will throw a warning I want to solve this problem but I don't know how to do it, please help me. Thanks. | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            srittau
          
      
      
        Nov 14, 2022 
      
    
    Replies: 1 comment 1 reply
-
| The following should do the trick if a class is returned statically: def get_test(cls) -> type[TestMain]:
    return TestMain | 
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
      Answer selected by
        hgalytoby
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
The following should do the trick if a class is returned statically: