Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1168202?usp=email )

Change subject: tests: Ignore code parts from coverage
......................................................................

tests: Ignore code parts from coverage

Change-Id: I236eff331b5bbc48034b57288a0d488775fed9bb
---
M conftest.py
M make_dist.py
M pyproject.toml
M pywikibot/scripts/__init__.py
M pywikibot/scripts/generate_family_file.py
M pywikibot/scripts/generate_user_files.py
M pywikibot/scripts/shell.py
7 files changed, 17 insertions(+), 15 deletions(-)

Approvals:
  Xqt: Verified; Looks good to me, approved




diff --git a/conftest.py b/conftest.py
index 787b6c5..1448717 100644
--- a/conftest.py
+++ b/conftest.py
@@ -37,6 +37,7 @@
     if not any('mypy' in name for name in plugin_names):
         return None

+    # no cover: start
     project_root = Path(__file__).parent / 'pywikibot'
     try:
         rel_path = collection_path.relative_to(project_root)
@@ -50,3 +51,4 @@
         return True

     return None
+    # no cover: stop
diff --git a/make_dist.py b/make_dist.py
index 72dfea6..c2a519e 100755
--- a/make_dist.py
+++ b/make_dist.py
@@ -52,7 +52,7 @@
    The pywikibot-scripts distribution can be created.
 """
 #
-# (C) Pywikibot team, 2022-2024
+# (C) Pywikibot team, 2022-2025
 #
 # Distributed under the terms of the MIT license.
 #
@@ -228,7 +228,7 @@
     package = 'pywikibot_scripts'
     replace = 'MANIFEST.in', 'pyproject.toml', 'setup.py'

-    def copy_files(self) -> None:
+    def copy_files(self) -> None:  # pragma: no cover
         """Ignore copy files yet."""
         info('<<lightyellow>>Copy files ...', newline=False)
         for filename in self.replace:
@@ -238,7 +238,7 @@
                 shutil.copy(self.folder / 'scripts' / filename, self.folder)
         info('<<lightyellow>>done')

-    def cleanup(self) -> None:
+    def cleanup(self) -> None:  # pragma: no cover
         """Ignore cleanup yet."""
         info('<<lightyellow>>Copy files ...', newline=False)
         for filename in self.replace:
@@ -253,7 +253,7 @@
     :return: Return whether dist is to be installed locally or to be
         uploaded
     """
-    if '-help' in sys.argv:
+    if '-help' in sys.argv:  # pragma: no cover
         import re

         import setup
diff --git a/pyproject.toml b/pyproject.toml
index 8ff8cc9..4520211 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -123,9 +123,8 @@
 ignore_errors = true
 skip_empty = true

-exclude_lines = [
+exclude_other = [
     # Have to re-enable the standard pragma
-    "pragma: no cover",
     "except ImportError",
     "except KeyboardInterrupt",
     "except OSError",
@@ -135,13 +134,13 @@
     "raise NotImplementedError",
     "raise unittest\\.SkipTest",
     "self\\.skipTest",
-    "if __name__ == '__main__':",
+    "if __name__ == .__main__.:",
     "if .+PYWIKIBOT_TEST_\\w+.+:",
     "if self\\.mw_version < .+:",
-    "if TYPE_CHECKING:",
     "@(abc\\.)?abstractmethod",
     "@deprecated\\([^\\)]+\\)",
     "@unittest\\.skip",
+    "no cover: start(?s:.)*?no cover: stop",
 ]

 exclude_also = [
diff --git a/pywikibot/scripts/__init__.py b/pywikibot/scripts/__init__.py
index 73a1e55..8767657 100644
--- a/pywikibot/scripts/__init__.py
+++ b/pywikibot/scripts/__init__.py
@@ -5,7 +5,7 @@
    ``preload_sites`` script was removed (:phab:`T348925`).
 """
 #
-# (C) Pywikibot team, 2021-2022
+# (C) Pywikibot team, 2021-2025
 #
 # Distributed under the terms of the MIT license.
 #
@@ -27,6 +27,6 @@
     # Reset this flag
     if not orig_no_user_config:
         del environ['PYWIKIBOT_NO_USER_CONFIG']
-    else:
+    else:  # pragma: no cover
         environ['PYWIKIBOT_NO_USER_CONFIG'] = orig_no_user_config
     return result
diff --git a/pywikibot/scripts/generate_family_file.py 
b/pywikibot/scripts/generate_family_file.py
index 3c97c3d..4e3bde0 100755
--- a/pywikibot/scripts/generate_family_file.py
+++ b/pywikibot/scripts/generate_family_file.py
@@ -253,7 +253,7 @@
         for lang in remove:
             self.langs.remove(lang)

-    def writefile(self, verify) -> None:
+    def writefile(self, verify) -> None:  # pragma: no cover
         """Write the family file."""
         fp = Path(self.base_dir, 'families', f'{self.name}_family.py')
         print(f'Writing {fp}... ')
diff --git a/pywikibot/scripts/generate_user_files.py 
b/pywikibot/scripts/generate_user_files.py
index f4d1612..9d96aef 100755
--- a/pywikibot/scripts/generate_user_files.py
+++ b/pywikibot/scripts/generate_user_files.py
@@ -350,7 +350,7 @@
     main_code: str,
     main_username: str,
     force: bool = False
-) -> None:
+) -> None:  # pragma: no cover
     """Create a user-config.py in base_dir.
 
     Create a user-password.py if necessary.
@@ -439,7 +439,8 @@
     save_botpasswords(botpasswords, f_pass)


-def save_botpasswords(botpasswords: str, path: Path) -> None:
+def save_botpasswords(botpasswords: str,
+                      path: Path) -> None:  # pragma: no cover
     """Write botpasswords to file.

     :param botpasswords: botpasswords for password file
diff --git a/pywikibot/scripts/shell.py b/pywikibot/scripts/shell.py
index 2751e3a..b5e8331 100755
--- a/pywikibot/scripts/shell.py
+++ b/pywikibot/scripts/shell.py
@@ -16,7 +16,7 @@
 .. versionchanged:: 7.0
    moved to pywikibot.scripts
 """
-# (C) Pywikibot team, 2014-2024
+# (C) Pywikibot team, 2014-2025
 #
 # Distributed under the terms of the MIT license.
 #
@@ -26,7 +26,7 @@
 import sys


-def main(*args: str) -> None:
+def main(*args: str) -> None:  # pragma: no cover
     """Script entry point.

     .. versionchanged:: 8.2

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1168202?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: I236eff331b5bbc48034b57288a0d488775fed9bb
Gerrit-Change-Number: 1168202
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to