jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1195402?usp=email )

Change subject: IMPR: Follow-up for Citoid Query interface implementation
......................................................................

IMPR: Follow-up for Citoid Query interface implementation

- use dataclass for CitoidClient
- update type hints
- move mypy tests for citoid from tox-typing to pre-commit
- add Python script entry point idiom for citoid_tests to allow running
  it as a standalone script
- add citoid module to documentation
- update CONTENT.rst

Bug: T401690
Change-Id: I02b9214dc87e630323a61e9f6055ab7b0aeb5f59
---
M .pre-commit-config.yaml
M conftest.py
M docs/api_ref/pywikibot.data.rst
M pywikibot/CONTENT.rst
M pywikibot/data/citoid.py
M pywikibot/site/_upload.py
M tests/citoid_tests.py
7 files changed, 39 insertions(+), 11 deletions(-)

Approvals:
  Strainu: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index f934067..8201cd3 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -129,7 +129,7 @@
             
(__metadata__|backports|config|cosmetic_changes|daemonize|diff|echo|exceptions|fixes|logging|plural|time|titletranslate)|
             (comms|data|families|specialbots)/__init__|
             comms/eventstreams|
-            data/(api/(__init__|_optionset)|memento|wikistats)|
+            data/(api/(__init__|_optionset)|citoid|memento|wikistats)|
             families/[a-z][a-z\d]+_family|
             page/(__init__|_decorators|_page|_revision)|
             pagegenerators/(__init__|_filters)|
diff --git a/conftest.py b/conftest.py
index a314ee8..2f93dee 100644
--- a/conftest.py
+++ b/conftest.py
@@ -20,7 +20,7 @@
     r'exceptions|fixes|logging|plural|time|titletranslate)|'
     r'(comms|data|families|specialbots)/__init__|'
     r'comms/eventstreams|'
-    r'data/(api/(__init__|_optionset)|memento|wikistats)|'
+    r'data/(api/(__init__|_optionset)|citoid|memento|wikistats)|'
     r'families/[a-z][a-z\d]+_family|'
     r'page/(__init__|_decorators|_page|_revision)|'
     r'pagegenerators/(__init__|_filters)|'
diff --git a/docs/api_ref/pywikibot.data.rst b/docs/api_ref/pywikibot.data.rst
index 0caf1b9..e6612b6 100644
--- a/docs/api_ref/pywikibot.data.rst
+++ b/docs/api_ref/pywikibot.data.rst
@@ -11,6 +11,12 @@
 .. automodule:: data.api
    :synopsis: Module providing several layers of data access to the wiki

+:mod:`data.citoid` --- Citoid Requests
+======================================
+
+.. automodule:: data.citoid
+   :synopsis: Citoid Query interface
+
 :mod:`data.memento` --- Memento Requests
 ========================================

diff --git a/pywikibot/CONTENT.rst b/pywikibot/CONTENT.rst
index 2ff8924..8fc54f8 100644
--- a/pywikibot/CONTENT.rst
+++ b/pywikibot/CONTENT.rst
@@ -87,7 +87,9 @@
     
+----------------------------+------------------------------------------------------+
     | data                       | Module providing layers of data access to 
wiki       |
     
+============================+======================================================+
-    | api.py                     | Interface Module to MediaWiki's api         
         |
+    | __init__.py                | WaitingMixin: A mixin to implement wait 
cycles       |
+    
+----------------------------+------------------------------------------------------+
+    | api (folder)               | Interface Module to MediaWiki's api         
         |
     |                            
+----------------+-------------------------------------+
     |                            | __init__.py    | Interface to MediaWiki's 
api.php    |
     |                            
+----------------+-------------------------------------+
@@ -99,12 +101,16 @@
     |                            
+----------------+-------------------------------------+
     |                            | _requests.py   | API Requests interface     
         |
     
+----------------------------+----------------+-------------------------------------+
+    | citoid.py                  | Citoid Query interface                      
         |
+    
+----------------------------+------------------------------------------------------+
     | memento.py                 | memento_client 0.6.1 package fix            
         |
     
+----------------------------+------------------------------------------------------+
     | mysql.py                   | Miscellaneous helper functions for mysql 
queries     |
     
+----------------------------+------------------------------------------------------+
     | sparql.py                  | Objects representing SPARQL query API       
         |
     
+----------------------------+------------------------------------------------------+
+    | superset.py                | Superset Query interface                    
         |
+    
+----------------------------+------------------------------------------------------+
     | wikistats.py               | Objects representing WikiStats API          
         |
     
+----------------------------+------------------------------------------------------+

@@ -140,6 +146,8 @@
     
+----------------------------+------------------------------------------------------+
     | pagegenerators             | Page generators module                      
         |
     
+============================+======================================================+
+    | __init__.py                | Page generators options and special page 
generators  |
+    
+----------------------------+------------------------------------------------------+
     | _factory.py                | Generator factory class to handle options   
         |
     
+----------------------------+------------------------------------------------------+
     | _filter.py                 | Filter functions                            
         |
@@ -196,6 +204,8 @@
     
+----------------------------+------------------------------------------------------+
     | _tokenwallet.py            | Objects representing api tokens             
         |
     
+----------------------------+------------------------------------------------------+
+    | _upload.py                 | Objects representing API upload to 
MediaWiki sites   |
+    
+----------------------------+------------------------------------------------------+


     
+----------------------------+------------------------------------------------------+
@@ -236,10 +246,12 @@


     
+----------------------------+------------------------------------------------------+
-    | User Interface                                                           
         |
+    | userinterfaces             | User Interfaces                             
         |
     
+============================+======================================================+
     | _interface_base.py         | Abstract base user interface module         
         |
     
+----------------------------+------------------------------------------------------+
+    | buffer_interface.py        | Non-interactive interface that stores 
output         |
+    
+----------------------------+------------------------------------------------------+
     | gui.py                     | GUI with a Unicode textfield where the user 
can edit |
     
+----------------------------+------------------------------------------------------+
     | terminal_interface.py      | Platform independent terminal interface 
module       |
diff --git a/pywikibot/data/citoid.py b/pywikibot/data/citoid.py
index ee4a930..96a4326 100644
--- a/pywikibot/data/citoid.py
+++ b/pywikibot/data/citoid.py
@@ -1,4 +1,4 @@
-"""Superset Query interface.
+"""Citoid Query interface.

 .. versionadded:: 10.6
 """
@@ -10,6 +10,8 @@
 from __future__ import annotations

 import urllib.parse
+from dataclasses import dataclass
+from typing import Any

 import pywikibot
 from pywikibot.comms import http
@@ -22,6 +24,7 @@
 ]


+@dataclass(eq=False)
 class CitoidClient:

     """Citoid client class.
@@ -29,11 +32,13 @@
     This class allows to call the Citoid API used in production.
     """

-    def __init__(self, site: BaseSite):
-        """Initialize the CitoidClient."""
-        self.site = site
+    site: BaseSite

-    def get_citation(self, response_format: str, ref_url: str) -> dict:
+    def get_citation(
+        self,
+        response_format: str,
+        ref_url: str
+    ) -> dict[str, Any]:
         """Get a citation from the citoid service.

         :param response_format: Return format, e.g. 'bibtex', 'wikibase', etc.
diff --git a/pywikibot/site/_upload.py b/pywikibot/site/_upload.py
index 2477d3f..9ce19a1 100644
--- a/pywikibot/site/_upload.py
+++ b/pywikibot/site/_upload.py
@@ -1,6 +1,6 @@
-"""Objects representing API upload to MediaWiki site."""
+"""Objects representing API upload to MediaWiki sites."""
 #
-# (C) Pywikibot team, 2009-2024
+# (C) Pywikibot team, 2009-2025
 #
 # Distributed under the terms of the MIT license.
 #
diff --git a/tests/citoid_tests.py b/tests/citoid_tests.py
index b4a6c96..ce1fff5 100755
--- a/tests/citoid_tests.py
+++ b/tests/citoid_tests.py
@@ -8,6 +8,7 @@
 from __future__ import annotations

 import datetime
+import unittest

 import pywikibot
 from pywikibot.data import citoid
@@ -59,3 +60,7 @@
                 'mediawiki2',
                 'https://ro.wikipedia.org/wiki/România'
             )
+
+
+if __name__ == '__main__':
+    unittest.main()

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1195402?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I02b9214dc87e630323a61e9f6055ab7b0aeb5f59
Gerrit-Change-Number: 1195402
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Strainu <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to