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

[ENHANCEMENT] Use modern abstract functionality #706

Open
oerc0122 opened this issue Mar 5, 2025 · 0 comments
Open

[ENHANCEMENT] Use modern abstract functionality #706

oerc0122 opened this issue Mar 5, 2025 · 0 comments
Labels
bug Something isn't working Technical Debt Legacy code which should be cleaned up.

Comments

@oerc0122
Copy link
Collaborator

oerc0122 commented Mar 5, 2025

Is your feature request related to a problem? Please describe.
Currently, several abstract classes do not use @abstractmethod to highlight these abstractions and thus cannot verify whether child classes correctly implement them.

Describe the solution you'd like
Implementation of abstract methods.

Describe alternatives you've considered
N/A

Additional context

Example code
from abc import ABC, ABCMeta, abstractmethod

class Geoff(metaclass=ABCMeta):
    def __init__(self):
        self.x = 7

    def calculate(self):
        raise NotImplementedError()

class SubGeoff(Geoff):
    ...

q = SubGeoff()

print(q.x)


class GeoffAbs(metaclass=ABCMeta):
    def __init__(self):
        self.x = 7

    @abstractmethod
    def calculate(self):
        raise NotImplementedError()

class SubGeoffAbs(GeoffAbs):
    ...

w = SubGeoffAbs()
print(w.x)
$ python tmp.py
7
Traceback (most recent call last):
  File "/home/jacob/tmp.py", line 29, in <module>
    w = SubGeoffAbs()
TypeError: Can't instantiate abstract class SubGeoffAbs with abstract method calculate
@oerc0122 oerc0122 added bug Something isn't working Technical Debt Legacy code which should be cleaned up. labels Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Technical Debt Legacy code which should be cleaned up.
Projects
None yet
Development

No branches or pull requests

1 participant