Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in Abstract class #767

Open
realxoman opened this issue Nov 3, 2023 · 1 comment
Open

Problem in Abstract class #767

realxoman opened this issue Nov 3, 2023 · 1 comment

Comments

@realxoman
Copy link

realxoman commented Nov 3, 2023

I have a strange problem with PyPika when I use abstract classes.

from abc import ABC

class Test(ABC):
   pass

class Message(Test):
   LIST_QUERY = Query.from_('messages')

a = Message()

TypeError: Can't instantiate abstract class Message with abstract method LIST_QUERY

When I remove Test from class args it work correctly.
What is the problem?

@wd60622
Copy link
Contributor

wd60622 commented Nov 5, 2023

Seems like the Message gets LIST_QUERY as an abstract method. i.e. Message.__abstractmethods__

This provides the same error. Might be related somehow

from abc import ABC, abstractmethod

class Test(ABC): 
    @abstractmethod
    def LIST_QUERY(self): 
        pass
        
class Message(Test):
    pass

a = Message()

Diving into the abc source code a bit: https://github.com/python/cpython/blob/main/Lib/abc.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants