diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e4bb1f5..88898ca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,11 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.2 + rev: v0.6.8 hooks: - id: ruff args: [--fix] - id: ruff-format - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.377 + rev: v1.1.383 hooks: - id: pyright diff --git a/pyproject.toml b/pyproject.toml index 0365991..e34ed43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,6 @@ target-version = "py311" [tool.ruff.lint] select = ["E4", "E7", "E9", "F", "I", "UP"] -ignore = ["F403"] [tool.ruff.lint.isort] known-first-party = ["conftest"] diff --git a/src/earwigbot/wiki/__init__.py b/src/earwigbot/wiki/__init__.py index 4c86bf5..3b5ecce 100644 --- a/src/earwigbot/wiki/__init__.py +++ b/src/earwigbot/wiki/__init__.py @@ -41,9 +41,20 @@ of your :py:class:`~earwigbot.wiki.site.Site` (and thus, :py:class:`~earwigbot.wiki.user.User`) needs. """ -from earwigbot.wiki.category import * -from earwigbot.wiki.constants import * -from earwigbot.wiki.page import * -from earwigbot.wiki.site import * -from earwigbot.wiki.sitesdb import * -from earwigbot.wiki.user import * +__all__ = [ + "Category", + "Page", + "Site", + "SitesDB", + "User", +] + +from earwigbot.wiki import constants +from earwigbot.wiki.category import Category +from earwigbot.wiki.constants import * # noqa: F403 +from earwigbot.wiki.page import Page +from earwigbot.wiki.site import Site +from earwigbot.wiki.sitesdb import SitesDB +from earwigbot.wiki.user import User + +__all__ += constants.__all__ diff --git a/src/earwigbot/wiki/constants.py b/src/earwigbot/wiki/constants.py index 481f0cd..3aa891b 100644 --- a/src/earwigbot/wiki/constants.py +++ b/src/earwigbot/wiki/constants.py @@ -57,6 +57,7 @@ __all__ = [ "NS_USER_TALK", "NS_USER", "USER_AGENT", + "Service", ] import platform diff --git a/src/earwigbot/wiki/copyvios/__init__.py b/src/earwigbot/wiki/copyvios/__init__.py index 40f3f27..e21fe36 100644 --- a/src/earwigbot/wiki/copyvios/__init__.py +++ b/src/earwigbot/wiki/copyvios/__init__.py @@ -90,6 +90,10 @@ class CopyvioChecker: def _exclusions_db(self) -> ExclusionsDB | None: return self._config.get("exclusions_db") + @property + def article_chain(self) -> MarkovChain: + return self._article + def _get_exclusion_callback(self) -> Callable[[str], bool] | None: if not self._exclusions_db: return None diff --git a/src/earwigbot/wiki/copyvios/result.py b/src/earwigbot/wiki/copyvios/result.py index 075e2f0..7c62d30 100644 --- a/src/earwigbot/wiki/copyvios/result.py +++ b/src/earwigbot/wiki/copyvios/result.py @@ -139,6 +139,20 @@ class CopyvioSource: event.wait() +class CheckResultMetadata: + def __getattr__(self, key: str) -> Any: + try: + return self.__dict__[key] + except KeyError: + raise AttributeError(key) from None + + def __setattr__(self, key: str, val: Any) -> None: + self.__dict__[key] = val + + def __delattr__(self, key: str) -> None: + del self.__dict__[key] + + class CopyvioCheckResult: """ **EarwigBot: Wiki Toolset: Copyvio Check Result** @@ -177,6 +191,7 @@ class CopyvioCheckResult: self.possible_miss = possible_miss self.included_sources = included_sources if included_sources else [] self.unified_confidence = unified_confidence + self.metadata = CheckResultMetadata() # Additional metadata for web tool def __repr__(self) -> str: """Return the canonical string representation of the result."""