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

Make provider resources more general #667

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/codemodder/providers.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
from abc import ABCMeta, abstractmethod
from collections import UserDict
from importlib.metadata import entry_points
from typing import Any

from codemodder.logging import logger


class BaseProvider(metaclass=ABCMeta):
name: str
_resource: str | None
_resource: Any | None

def __init__(self, name):
self.name = name
self._resource = self.load()

@abstractmethod
def load(self) -> str | None:
def load(self) -> Any | None:
pass

@property
def is_available(self) -> bool:
return self.resource is not None

@property
def resource(self) -> str:
def resource(self) -> Any:
if self._resource is None:
raise ValueError(f"Resource for provider {self.name} is not available")
return self._resource
Expand Down
Loading