jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/964180 )
Change subject: [9.0] Drop support for Python 3.6 ......................................................................
[9.0] Drop support for Python 3.6
- drop Python 3.6 support - add __future__.annotation to enable forward references of type hints
Bug: T347026 Change-Id: I7ccd63e41fb8448c724803ef2583844c35a13000 --- M scripts/redirect.py M tests/collections_tests.py M tests/generate_user_files_tests.py M pywikibot/daemonize.py M pywikibot/families/incubator_family.py M pywikibot/site/_datasite.py M tests/datasite_tests.py M tests/replacebot_tests.py M pywikibot/site/_interwikimap.py M pywikibot/config.py M pywikibot/families/meta_family.py M pywikibot/page/_page.py M pywikibot/scripts/shell.py M pywikibot/page/_collections.py M tests/oauth_tests.py M scripts/watchlist.py M tests/namespace_tests.py M tests/basesite_tests.py M scripts/image.py M scripts/dataextend.py M scripts/newitem.py M pywikibot/pagegenerators/__init__.py M scripts/replace.py M tests/cache_tests.py M scripts/claimit.py M tests/noreferences_tests.py M pywikibot/page/_user.py M pywikibot/families/wikiquote_family.py M tests/logentries_tests.py M tests/__init__.py M pywikibot/userinterfaces/_interface_base.py M pywikibot/data/memento.py M pwb.py M tests/l10n_tests.py M scripts/commons_information.py M tests/redirect_bot_tests.py M pywikibot/page/_category.py M tests/harvest_template_tests.py M pywikibot/specialbots/_unlink.py M tests/data_ingestion_tests.py M scripts/interwiki.py M tests/plural_tests.py M pywikibot/data/__init__.py M requirements.txt M tests/user_tests.py M pywikibot/page/_filepage.py M tests/pwb_tests.py M pywikibot/site/_upload.py M tests/http_tests.py M tests/eventstreams_tests.py M scripts/welcome.py M tests/wikiblame_tests.py M pywikibot/tools/__init__.py M pywikibot/__init__.py M tests/site_detect_tests.py M scripts/data_ingestion.py M scripts/djvutext.py M scripts/coordinate_import.py M scripts/replicate_wiki.py M tests/interwiki_link_tests.py M tests/fixes_tests.py M pywikibot/pagegenerators/_factory.py M pywikibot/tools/_deprecate.py M tests/upload_tests.py M tests/flow_thanks_tests.py M pywikibot/families/wikiversity_family.py M pywikibot/families/wiktionary_family.py M scripts/delinker.py M tests/tools_formatter_tests.py M scripts/patrol.py M pywikibot/families/wikisource_family.py M tests/protectbot_tests.py M tests/flow_tests.py M tests/uploadscript_tests.py M setup.py M pywikibot/families/wowwiki_family.py M pywikibot/data/mysql.py M pywikibot/userinterfaces/buffer_interface.py M scripts/weblinkchecker.py M pywikibot/families/wikispore_family.py M pywikibot/comms/eventstreams.py M pywikibot/page/_links.py M pywikibot/scripts/generate_family_file.py M tests/make_dist_tests.py M tests/ui_tests.py M pywikibot/tools/collections.py M scripts/speedy_delete.py M pywikibot/families/wikipedia_family.py M tests/deletionbot_tests.py M pywikibot/families/wikibooks_family.py M pywikibot/tools/_logging.py M pywikibot/version.py M scripts/nowcommons.py M pywikibot/site/_tokenwallet.py M pywikibot/plural.py M tests/thanks_tests.py M tests/mysql_tests.py M tests/interwikimap_tests.py M pywikibot/scripts/preload_sites.py M tests/wikibase_edit_tests.py M pywikibot/page/_decorators.py M scripts/maintenance/wikimedia_sites.py M pywikibot/data/wikistats.py M pywikibot/families/wikimania_family.py M pywikibot/userinterfaces/gui.py M tests/site_login_logout_tests.py M pywikibot/specialbots/_upload.py M pywikibot/site/_obsoletesites.py M tests/proofreadpage_tests.py M tests/generate_family_file_tests.py M tests/textlib_tests.py M scripts/touch.py M tests/titletranslate_tests.py M pywikibot/site_detect.py M scripts/unusedfiles.py M tests/paraminfo_tests.py M tests/bot_tests.py M tests/sparql_tests.py M pywikibot/families/lingualibre_family.py M scripts/download_dump.py M scripts/solve_disambiguation.py M scripts/parser_function_count.py M tests/fixing_redirects_tests.py M tests/template_bot_tests.py M pywikibot/data/api/__init__.py M tests/tools_threading_tests.py M pywikibot/site/__init__.py M tests/wikistats_tests.py M scripts/delete.py M scripts/templatecount.py M pywikibot/diff.py M pywikibot/logging.py M scripts/archivebot.py M tests/data/set-fixes.py M tests/basepage.py M tests/patrolbot_tests.py M tests/dry_api_tests.py M pywikibot/userinterfaces/transliteration.py M pywikibot/data/api/_requests.py M pywikibot/site/_basesite.py M tests/site_decorators_tests.py M pywikibot/logentries.py M pywikibot/pagegenerators/_filters.py M scripts/harvest_template.py M tests/interwiki_graph_tests.py M pywikibot/page/_wikibase.py M scripts/category_redirect.py M pywikibot/site/_siteinfo.py M scripts/clean_sandbox.py M tests/data/fixes.py M tests/page_tests.py M pywikibot/families/osm_family.py M tests/interwikidata_tests.py M pywikibot/data/api/_paraminfo.py M pywikibot/echo.py M pywikibot/scripts/version.py M scripts/transwikiimport.py M tests/mediawikiversion_tests.py M pywikibot/families/wikidata_family.py M scripts/protect.py M scripts/maintenance/unidata.py M tests/script_tests.py M pywikibot/textlib.py M scripts/commonscat.py M scripts/noreferences.py M pywikibot/families/wikihow_family.py M pywikibot/families/wikinews_family.py M tests/reflinks_tests.py M tests/utils.py M pywikibot/families/wikifunctions_family.py M tests/memento_tests.py M tests/site_generators_tests.py M scripts/create_isbn_edition.py M pywikibot/site/_generators.py M make_dist.py M pywikibot/site/_decorators.py M pywikibot/_wbtypes.py M pywikibot/families/mediawiki_family.py M pywikibot/tools/formatter.py M tests/cosmetic_changes_tests.py M pywikibot/scripts/__init__.py M pywikibot/families/commons_family.py M pywikibot/login.py M scripts/transferbot.py M pywikibot/families/wikivoyage_family.py M scripts/illustrate_wikidata.py M docs/index.rst M pywikibot/tools/_unidata.py M tests/category_tests.py M tests/linter_tests.py M pywikibot/page/_basepage.py M pywikibot/userinterfaces/terminal_interface_win32.py M pywikibot/families/species_family.py M pywikibot/site/_extensions.py M tests/gui_tests.py M pywikibot/userinterfaces/terminal_interface_base.py M pywikibot/i18n.py M pywikibot/families/vikidia_family.py M pywikibot/tools/threading.py M scripts/fixing_redirects.py M pywikibot/page/_revision.py M tests/i18n_tests.py M pywikibot/flow.py M tests/date_tests.py M pywikibot/README.rst M tests/site_tests.py M scripts/interwikidata.py M pywikibot/interwiki_graph.py M tests/token_tests.py M scripts/maintenance/make_i18n_dict.py M pywikibot/page/_toolforge.py M scripts/revertbot.py M pywikibot/site/_namespace.py M tests/pwb/print_argv.py M tests/site_obsoletesites_tests.py M tests/pwb/print_env.py M pywikibot/data/api/_generators.py M pywikibot/proofreadpage.py M scripts/category.py M tests/djvu_tests.py M tests/xmlreader_tests.py M pywikibot/exceptions.py M pywikibot/specialbots/__init__.py M pywikibot/data/sparql.py M pywikibot/pagegenerators/_generators.py M scripts/upload.py M tests/link_tests.py M tests/pwb/print_unicode.py M tests/aspects.py M pywikibot/data/api/_optionset.py M tests/uploadbot_tests.py M scripts/listpages.py M tests/login_tests.py M scripts/imagetransfer.py M pywikibot/page/__init__.py M tests/category_bot_tests.py M scripts/basic.py M scripts/maintenance/cache.py M tests/pwb/print_locals.py M .appveyor.yml M pywikibot/editor.py M pywikibot/families/wikitech_family.py M tests/time_tests.py M scripts/checkimages.py M scripts/template.py M tests/edit_tests.py M pywikibot/__metadata__.py M scripts/pagefromfile.py M pywikibot/cosmetic_changes.py M pywikibot/families/outreach_family.py M tests/ui_options_tests.py M pywikibot/date.py M pywikibot/families/wikimediachapter_family.py M pywikibot/site/_apisite.py M tests/dry_site_tests.py M tox.ini M tests/checkimages_tests.py M scripts/add_text.py M scripts/cosmetic_changes.py M tests/add_text_tests.py M pywikibot/scripts/login.py M pywikibot/tools/djvu.py M pywikibot/tools/chars.py M scripts/misspelling.py M scripts/blockpageschecker.py M pywikibot/family.py M pywikibot/throttle.py M tests/family_tests.py M pywikibot/userinterfaces/terminal_interface.py M tests/echo_tests.py M pywikibot/scripts/wrapper.py M pywikibot/tools/itertools.py M tests/wikibase_tests.py M tests/flow_edit_tests.py M pywikibot/families/foundation_family.py M tests/edit_failure_tests.py M scripts/maintenance/colors.py M pywikibot/scripts/generate_user_files.py M tests/siteinfo_tests.py M pywikibot/families/i18n_family.py M pywikibot/bot.py M scripts/reflinks.py M pywikibot/titletranslate.py M scripts/category_graph.py M pywikibot/bot_choice.py D appveyor_install.ps1 M pywikibot/time.py M scripts/change_pagelang.py M pywikibot/comms/http.py M pywikibot/xmlreader.py M tests/timestripper_tests.py M pywikibot/backports.py M tests/tools_deprecate_tests.py M tests/archivebot_tests.py M pywikibot/userinterfaces/terminal_interface_unix.py M tests/file_tests.py M scripts/movepages.py M tests/api_tests.py 298 files changed, 657 insertions(+), 232 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/.appveyor.yml b/.appveyor.yml index b53a31c..5b8c64e 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -14,9 +14,13 @@
matrix:
- # Test the lowest supported release of each major Python version - # TODO: Python 3.7.0 + # Test the lowest supported release + # Python 3.7.0 is provided by VS 2013
+ - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + PYTHON: "C:\Python37" + PYTHON_VERSION: "3.7.0" + PYTHON_ARCH: "32"
# AppVeyor pre-installs these versions onto build machines @@ -53,11 +57,11 @@ - "SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%"
install: + # ignore SSL error for old image + - if [%PYTHON_VERSION%]==[3.7.0] set GIT_SSL_NO_VERIFY=true - git submodule update --init # Download the AppVeyor Python build accessories into subdirectory .\appveyor - mkdir appveyor - # Download Python 3.7.0 which isn't pre-installed - # - ps: ./appveyor_install.ps1 - python --version - python -c "import platform; print(platform.machine())" - python -c "import struct; print('PYTHON_ARCH:', struct.calcsize('P') << 3)" diff --git a/appveyor_install.ps1 b/appveyor_install.ps1 deleted file mode 100644 index b86e63d..0000000 --- a/appveyor_install.ps1 +++ /dev/null @@ -1,133 +0,0 @@ -# Sample script to install Python and pip under Windows -# Authors: Olivier Grisel, Jonathan Helmus, Kyle Kastner, and Alex Willmer -# License: CC0 1.0 Universal: https://creativecommons.org/publicdomain/zero/1.0/ - -$BASE_URL = "https://www.python.org/ftp/python/" - -$PYTHON_PRERELEASE_REGEX = @" -(?x) -(?<major>\d+) -. -(?<minor>\d+) -. -(?<micro>\d+) -(?<prerelease>[a-z]{1,2}\d+) -"@ - - -function Download ($filename, $url) { - $webclient = New-Object System.Net.WebClient - - $basedir = $pwd.Path + "" - $filepath = $basedir + $filename - if (Test-Path $filename) { - Write-Host "Reusing" $filepath - return $filepath - } - - # Download and retry up to 3 times in case of network transient errors. - Write-Host "Downloading" $filename "from" $url - $retry_attempts = 2 - for ($i = 0; $i -lt $retry_attempts; $i++) { - try { - $webclient.DownloadFile($url, $filepath) - break - } - Catch [Exception]{ - Start-Sleep 1 - } - } - if (Test-Path $filepath) { - Write-Host "File saved at" $filepath - } else { - # Retry once to get the error message if any at the last try - $webclient.DownloadFile($url, $filepath) - } - return $filepath -} - - -function ParsePythonVersion ($python_version) { - if ($python_version -match $PYTHON_PRERELEASE_REGEX) { - return ([int]$matches.major, [int]$matches.minor, [int]$matches.micro, - $matches.prerelease) - } - $version_obj = [version]$python_version - return ($version_obj.major, $version_obj.minor, $version_obj.build, "") -} - - -function DownloadPython ($python_version, $platform_suffix) { - $major, $minor, $micro, $prerelease = ParsePythonVersion $python_version - - # Only Python 3.6.1+ is supported - $dir = "$major.$minor.$micro" - $ext = "exe" - if ($platform_suffix) { - $platform_suffix = "-$platform_suffix" - } - - $filename = "python-$python_version$platform_suffix.$ext" - $url = "$BASE_URL$dir/$filename" - $filepath = Download $filename $url - return $filepath -} - - -function InstallPython ($python_version, $architecture, $python_home) { - Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home - if (Test-Path $python_home) { - Write-Host $python_home "already exists, skipping." - return $false - } - - if ($architecture -eq "32") { - $platform_suffix = "" - } else { - $platform_suffix = "amd64" - } - - $installer_path = DownloadPython $python_version $platform_suffix - Write-Host "Installing $installer_path to $python_home" - - $installer_ext = [System.IO.Path]::GetExtension($installer_path) - $install_log = $python_home + ".log" - - if ($installer_ext -eq '.msi') { - Write-Host "MSI installer is not supported" - } else { - $uninstaller_path = DownloadPython 3.6.8 $platform_suffix - InstallPythonEXE $installer_path $python_home $install_log $uninstaller_path - } - - if (Test-Path $python_home) { - Write-Host "Python $python_version ($architecture) installation complete" - } else { - Write-Host "Failed to install Python in $python_home" - Get-Content -Path $install_log - Exit 1 - } -} - - -function InstallPythonEXE ($exepath, $python_home, $install_log, $unexepath) { - $uninstall_args = "/log C:\Python36-x64.log /quiet /uninstall InstallAllUsers=1 TargetDir=C:\Python36-x64" - RunCommand $unexepath $uninstall_args - $install_args = "/log $install_log /quiet InstallAllUsers=1 TargetDir=$python_home" - RunCommand $exepath $install_args -} - - -function RunCommand ($command, $command_args) { - Write-Host $command $command_args - Start-Process -FilePath $command -ArgumentList $command_args -Wait -Passthru -} - - -function main () { - if ($env:PYTHON_VERSION -eq "3.6.1") { - InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON - } -} - -main diff --git a/docs/index.rst b/docs/index.rst index f81d4a8..0586a69 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -21,11 +21,7 @@ whether you have Python installed and to find its version, just type ``python`` at the CMD or shell prompt.
-Python 3.6.1 or higher is currently required to run the bot, but Python 3.7 -or higher is recommended. Python 3.6 support will be dropped with Pywikibot 9. - -.. attention:: Due to a security vulnerability it is strictly recommended to - use Python 3.7 or higher. Python 3.6 support will be dropped soon. +Python 3.7 or higher is currently required to run the bot.
Pywikibot and this documentation are licensed under the :ref:`MIT license`; diff --git a/make_dist.py b/make_dist.py index 2f0fb95..9416a7b 100755 --- a/make_dist.py +++ b/make_dist.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""Script to create a new distribution. Requires Python 3.7+. +"""Script to create a new distribution.
The following options are supported:
@@ -50,6 +50,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import abc import shutil import sys diff --git a/pwb.py b/pwb.py index 50ec1e5..e62c0b8 100755 --- a/pwb.py +++ b/pwb.py @@ -15,13 +15,13 @@ Pywikibot is not available on: {version}
-This version of Pywikibot only supports Python 3.6.1+. +This version of Pywikibot only supports Python 3.7+. """
def python_is_supported(): """Check that Python is supported.""" - return sys.version_info[:3] >= (3, 6, 1) + return sys.version_info[:3] >= (3, 7)
if not python_is_supported(): # pragma: no cover diff --git a/pywikibot/README.rst b/pywikibot/README.rst index acf480b..4e90b04 100644 --- a/pywikibot/README.rst +++ b/pywikibot/README.rst @@ -27,7 +27,7 @@ * python-tkinter (optional, used by some experimental GUI stuff)
-You need to have at least Python version `3.6.1 https://www.python.org/downloads/`_ +You need to have at least Python version `3.7 https://www.python.org/downloads/`_ or newer installed on your computer to be able to run any of the code in this package. Please refer the manual at mediawiki for further details and restrictions. diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index 02e7e2f..ab8aa2f 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import atexit import datetime import re @@ -74,7 +76,7 @@ ) from pywikibot.time import Timestamp from pywikibot.site import APISite, BaseSite -from pywikibot.tools import PYTHON_VERSION, normalize_username +from pywikibot.tools import normalize_username
__all__ = ( @@ -100,16 +102,6 @@
_sites: Dict[str, APISite] = {}
-if PYTHON_VERSION < (3, 7): - warn(""" - - Python {version} will be dropped soon with Pywikibot 9.0 - due to vulnerability security alerts. - It is recommended to use Python 3.7 or above. - See T347026 for further information. -""".format(version=sys.version.split(maxsplit=1)[0]), - FutureWarning) # adjust this line no in utils.execute() -
@cache def _code_fam_from_url(url: str, name: Optional[str] = None diff --git a/pywikibot/__metadata__.py b/pywikibot/__metadata__.py index 2bd4393..6c5d383 100644 --- a/pywikibot/__metadata__.py +++ b/pywikibot/__metadata__.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from time import strftime
diff --git a/pywikibot/_wbtypes.py b/pywikibot/_wbtypes.py index a39565b..73fb2f3 100644 --- a/pywikibot/_wbtypes.py +++ b/pywikibot/_wbtypes.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import abc import datetime import json diff --git a/pywikibot/backports.py b/pywikibot/backports.py index a93a5e5..eeaedda 100644 --- a/pywikibot/backports.py +++ b/pywikibot/backports.py @@ -1,9 +1,16 @@ -"""This module contains backports to support older Python versions.""" +"""This module contains backports to support older Python versions. + +.. deprecated:: 9.0 + The *nullcontext* context manager; use ``contextlib.nullcontext`` + instead. The *SimpleQueue* queue; use ``queue.SimpleQueue`` instead. +""" # # (C) Pywikibot team, 2014-2023 # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import sys from typing import Any
@@ -19,37 +26,6 @@ cache = _lru_cache(None)
-# context -if PYTHON_VERSION < (3, 7) or SPHINX_RUNNING: - - class nullcontext: # noqa: N801 - - """Context manager that does no additional processing. - - .. seealso:: :python:`contextlib.nullcontext - <library/contextlib.html#contextlib.nullcontext>`, - backported from Python 3.7. - """ - - def __init__(self, enter_result: Any = None) -> None: # noqa: D107 - self.enter_result = enter_result - - def __enter__(self) -> Any: - return self.enter_result - - def __exit__(self, *excinfo: Any) -> None: - pass -else: - from contextlib import nullcontext # type: ignore[assignment] - - -# queue -if PYTHON_VERSION < (3, 7): - from queue import Queue as SimpleQueue -else: - from queue import SimpleQueue # type: ignore[assignment] - - # typing if PYTHON_VERSION < (3, 9): from typing import DefaultDict # type: ignore[misc] @@ -206,3 +182,14 @@ yield tuple(group) else: from itertools import batched # type: ignore[no-redef] + + +# import ModuleDeprecationWrapper here to prevent circular import +from pywikibot.tools import ModuleDeprecationWrapper # noqa: E402 +wrapper = ModuleDeprecationWrapper(__name__) +wrapper.add_deprecated_attr('nullcontext', + replacement_name='contextlib.nullcontext', + since='9.0.0') +wrapper.add_deprecated_attr('SimpleQueue', + replacement_name='queue.SimpleQueue', + since='9.0.0') diff --git a/pywikibot/bot.py b/pywikibot/bot.py index 2d73000..7f60d94 100644 --- a/pywikibot/bot.py +++ b/pywikibot/bot.py @@ -61,6 +61,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + __all__ = ( 'CRITICAL', 'ERROR', 'INFO', 'WARNING', 'DEBUG', 'INPUT', 'STDOUT', 'VERBOSE', 'critical', 'debug', 'error', 'exception', 'log', 'warning', diff --git a/pywikibot/bot_choice.py b/pywikibot/bot_choice.py index 18c00a5..6d523df 100644 --- a/pywikibot/bot_choice.py +++ b/pywikibot/bot_choice.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re from abc import ABC, abstractmethod from textwrap import fill diff --git a/pywikibot/comms/eventstreams.py b/pywikibot/comms/eventstreams.py index 676acbc..e5b8688 100644 --- a/pywikibot/comms/eventstreams.py +++ b/pywikibot/comms/eventstreams.py @@ -14,6 +14,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import json from functools import partial from typing import Optional diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py index f682298..03b7e18 100644 --- a/pywikibot/comms/http.py +++ b/pywikibot/comms/http.py @@ -30,6 +30,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import atexit import codecs import re diff --git a/pywikibot/config.py b/pywikibot/config.py index 58db8c9..a353b8d 100644 --- a/pywikibot/config.py +++ b/pywikibot/config.py @@ -38,6 +38,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import collections import copy import os diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py index 05d7209..b3b3e1e 100644 --- a/pywikibot/cosmetic_changes.py +++ b/pywikibot/cosmetic_changes.py @@ -55,6 +55,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re from contextlib import suppress from enum import IntEnum diff --git a/pywikibot/daemonize.py b/pywikibot/daemonize.py index 1ed97bc..b35eb1c 100644 --- a/pywikibot/daemonize.py +++ b/pywikibot/daemonize.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os import stat import sys diff --git a/pywikibot/data/__init__.py b/pywikibot/data/__init__.py index 53e3a1c..60e1ced 100644 --- a/pywikibot/data/__init__.py +++ b/pywikibot/data/__init__.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from typing import Optional
import pywikibot diff --git a/pywikibot/data/api/__init__.py b/pywikibot/data/api/__init__.py index 75e0351..530f15b 100644 --- a/pywikibot/data/api/__init__.py +++ b/pywikibot/data/api/__init__.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from email.generator import BytesGenerator from email.mime.multipart import MIMEMultipart as MIMEMultipartOrig from io import BytesIO diff --git a/pywikibot/data/api/_generators.py b/pywikibot/data/api/_generators.py index 45a1e57..8e4ab0d 100644 --- a/pywikibot/data/api/_generators.py +++ b/pywikibot/data/api/_generators.py @@ -10,6 +10,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from abc import ABC, abstractmethod from contextlib import suppress from typing import Optional, Union diff --git a/pywikibot/data/api/_optionset.py b/pywikibot/data/api/_optionset.py index 3b91d14..d901808 100644 --- a/pywikibot/data/api/_optionset.py +++ b/pywikibot/data/api/_optionset.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from collections.abc import MutableMapping from typing import Optional
diff --git a/pywikibot/data/api/_paraminfo.py b/pywikibot/data/api/_paraminfo.py index 35b8e1b..b3f14aa 100644 --- a/pywikibot/data/api/_paraminfo.py +++ b/pywikibot/data/api/_paraminfo.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from collections.abc import Container, Sized from typing import Any, Optional, Union
diff --git a/pywikibot/data/api/_requests.py b/pywikibot/data/api/_requests.py index e9b9bd7..1d4c294 100644 --- a/pywikibot/data/api/_requests.py +++ b/pywikibot/data/api/_requests.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import hashlib import inspect diff --git a/pywikibot/data/memento.py b/pywikibot/data/memento.py index ed770fe..7300245 100644 --- a/pywikibot/data/memento.py +++ b/pywikibot/data/memento.py @@ -13,6 +13,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from datetime import datetime from typing import Optional
diff --git a/pywikibot/data/mysql.py b/pywikibot/data/mysql.py index 4f85950..5d966a7 100644 --- a/pywikibot/data/mysql.py +++ b/pywikibot/data/mysql.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from typing import Optional
import pkg_resources diff --git a/pywikibot/data/sparql.py b/pywikibot/data/sparql.py index 85627aa..c8bbc8e 100644 --- a/pywikibot/data/sparql.py +++ b/pywikibot/data/sparql.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from textwrap import fill from typing import Optional from urllib.parse import quote diff --git a/pywikibot/data/wikistats.py b/pywikibot/data/wikistats.py index 0522b4d..2443713 100644 --- a/pywikibot/data/wikistats.py +++ b/pywikibot/data/wikistats.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from csv import DictReader from io import StringIO from typing import Optional diff --git a/pywikibot/date.py b/pywikibot/date.py index 38d9565..71e6bc4 100644 --- a/pywikibot/date.py +++ b/pywikibot/date.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import calendar import datetime import re diff --git a/pywikibot/diff.py b/pywikibot/diff.py index b80a1e3..caaf6d7 100644 --- a/pywikibot/diff.py +++ b/pywikibot/diff.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import difflib import math from collections import abc diff --git a/pywikibot/echo.py b/pywikibot/echo.py index 9d271ee..30c681a 100644 --- a/pywikibot/echo.py +++ b/pywikibot/echo.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from typing import Any, Optional, Type
import pywikibot diff --git a/pywikibot/editor.py b/pywikibot/editor.py index f3b47ee..df5f274 100644 --- a/pywikibot/editor.py +++ b/pywikibot/editor.py @@ -8,6 +8,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os import shlex import subprocess diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py index 9b90924..5d11f5b 100644 --- a/pywikibot/exceptions.py +++ b/pywikibot/exceptions.py @@ -174,6 +174,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re from typing import Any, Optional, Union
diff --git a/pywikibot/families/commons_family.py b/pywikibot/families/commons_family.py index 5545937..428dc16 100644 --- a/pywikibot/families/commons_family.py +++ b/pywikibot/families/commons_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/foundation_family.py b/pywikibot/families/foundation_family.py index 35e0d86..3e57da8 100644 --- a/pywikibot/families/foundation_family.py +++ b/pywikibot/families/foundation_family.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/i18n_family.py b/pywikibot/families/i18n_family.py index 93be54e..d76af73 100644 --- a/pywikibot/families/i18n_family.py +++ b/pywikibot/families/i18n_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/incubator_family.py b/pywikibot/families/incubator_family.py index 566d559..827793c 100644 --- a/pywikibot/families/incubator_family.py +++ b/pywikibot/families/incubator_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/lingualibre_family.py b/pywikibot/families/lingualibre_family.py index cdcc658..99a36ad 100644 --- a/pywikibot/families/lingualibre_family.py +++ b/pywikibot/families/lingualibre_family.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/mediawiki_family.py b/pywikibot/families/mediawiki_family.py index cd717d8..3d01ef1 100644 --- a/pywikibot/families/mediawiki_family.py +++ b/pywikibot/families/mediawiki_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/meta_family.py b/pywikibot/families/meta_family.py index 0412abb..67de0bf 100644 --- a/pywikibot/families/meta_family.py +++ b/pywikibot/families/meta_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/osm_family.py b/pywikibot/families/osm_family.py index 81b14cc..f68e767 100644 --- a/pywikibot/families/osm_family.py +++ b/pywikibot/families/osm_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/outreach_family.py b/pywikibot/families/outreach_family.py index 0ad5c35..faea98d 100644 --- a/pywikibot/families/outreach_family.py +++ b/pywikibot/families/outreach_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/species_family.py b/pywikibot/families/species_family.py index 8a76f7b..8d120e8 100644 --- a/pywikibot/families/species_family.py +++ b/pywikibot/families/species_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/vikidia_family.py b/pywikibot/families/vikidia_family.py index 3297f39..de74bfb 100644 --- a/pywikibot/families/vikidia_family.py +++ b/pywikibot/families/vikidia_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family from pywikibot.tools import classproperty
diff --git a/pywikibot/families/wikibooks_family.py b/pywikibot/families/wikibooks_family.py index 6db197c..6cf8e27 100644 --- a/pywikibot/families/wikibooks_family.py +++ b/pywikibot/families/wikibooks_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/wikidata_family.py b/pywikibot/families/wikidata_family.py index 780c482..89b79fa 100644 --- a/pywikibot/families/wikidata_family.py +++ b/pywikibot/families/wikidata_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import config, family
diff --git a/pywikibot/families/wikifunctions_family.py b/pywikibot/families/wikifunctions_family.py index 0810392..b240a1f 100644 --- a/pywikibot/families/wikifunctions_family.py +++ b/pywikibot/families/wikifunctions_family.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/wikihow_family.py b/pywikibot/families/wikihow_family.py index 2343870..3a183a7 100644 --- a/pywikibot/families/wikihow_family.py +++ b/pywikibot/families/wikihow_family.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family from pywikibot.tools import classproperty
diff --git a/pywikibot/families/wikimania_family.py b/pywikibot/families/wikimania_family.py index aa8c468..62877e5 100644 --- a/pywikibot/families/wikimania_family.py +++ b/pywikibot/families/wikimania_family.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family from pywikibot.tools import classproperty
diff --git a/pywikibot/families/wikimediachapter_family.py b/pywikibot/families/wikimediachapter_family.py index 6959b00..3590ec9 100644 --- a/pywikibot/families/wikimediachapter_family.py +++ b/pywikibot/families/wikimediachapter_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/wikinews_family.py b/pywikibot/families/wikinews_family.py index f296361..afd9caf 100644 --- a/pywikibot/families/wikinews_family.py +++ b/pywikibot/families/wikinews_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/wikipedia_family.py b/pywikibot/families/wikipedia_family.py index 0fa7395..83301f0 100644 --- a/pywikibot/families/wikipedia_family.py +++ b/pywikibot/families/wikipedia_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/wikiquote_family.py b/pywikibot/families/wikiquote_family.py index e6a8345..2fb64cf 100644 --- a/pywikibot/families/wikiquote_family.py +++ b/pywikibot/families/wikiquote_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/wikisource_family.py b/pywikibot/families/wikisource_family.py index 9361e6a..fc7a987 100644 --- a/pywikibot/families/wikisource_family.py +++ b/pywikibot/families/wikisource_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family from pywikibot.tools import classproperty
diff --git a/pywikibot/families/wikispore_family.py b/pywikibot/families/wikispore_family.py index a0deedb..f07a42b 100644 --- a/pywikibot/families/wikispore_family.py +++ b/pywikibot/families/wikispore_family.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/wikitech_family.py b/pywikibot/families/wikitech_family.py index 0428c26..4a10213 100644 --- a/pywikibot/families/wikitech_family.py +++ b/pywikibot/families/wikitech_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/wikiversity_family.py b/pywikibot/families/wikiversity_family.py index 21e8b18..38be891 100644 --- a/pywikibot/families/wikiversity_family.py +++ b/pywikibot/families/wikiversity_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family from pywikibot.tools import classproperty
diff --git a/pywikibot/families/wikivoyage_family.py b/pywikibot/families/wikivoyage_family.py index 2ab3580..b2d2949 100644 --- a/pywikibot/families/wikivoyage_family.py +++ b/pywikibot/families/wikivoyage_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + # The new Wikivoyage family that is hosted at Wikimedia from pywikibot import family
diff --git a/pywikibot/families/wiktionary_family.py b/pywikibot/families/wiktionary_family.py index 7c00c14..37b5a85 100644 --- a/pywikibot/families/wiktionary_family.py +++ b/pywikibot/families/wiktionary_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family
diff --git a/pywikibot/families/wowwiki_family.py b/pywikibot/families/wowwiki_family.py index fdb5871..8c2756f 100644 --- a/pywikibot/families/wowwiki_family.py +++ b/pywikibot/families/wowwiki_family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot import family from pywikibot.tools import classproperty
diff --git a/pywikibot/family.py b/pywikibot/family.py index ac9d478..192c303 100644 --- a/pywikibot/family.py +++ b/pywikibot/family.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import collections import inspect import logging diff --git a/pywikibot/flow.py b/pywikibot/flow.py index a6c9e0c..8ffd3c0 100644 --- a/pywikibot/flow.py +++ b/pywikibot/flow.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import abc import datetime from typing import Any, Optional, Type, Union diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py index 3f8205c..ef946f2 100644 --- a/pywikibot/i18n.py +++ b/pywikibot/i18n.py @@ -19,6 +19,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import json import os import pkgutil diff --git a/pywikibot/interwiki_graph.py b/pywikibot/interwiki_graph.py index 041e9d7..78a09b9 100644 --- a/pywikibot/interwiki_graph.py +++ b/pywikibot/interwiki_graph.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import itertools import threading from collections import Counter diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py index 33dcc3c..1b9f65b 100644 --- a/pywikibot/logentries.py +++ b/pywikibot/logentries.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime from collections import UserDict from typing import Any, Optional, Type, Union diff --git a/pywikibot/logging.py b/pywikibot/logging.py index d81d7f6..f943ab8 100644 --- a/pywikibot/logging.py +++ b/pywikibot/logging.py @@ -24,6 +24,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import logging import os import sys diff --git a/pywikibot/login.py b/pywikibot/login.py index b808ce1..97c30e5 100644 --- a/pywikibot/login.py +++ b/pywikibot/login.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import datetime import os diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py index 79297ba..33fe142c 100644 --- a/pywikibot/page/__init__.py +++ b/pywikibot/page/__init__.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from typing import Union
from pywikibot.page._basepage import BasePage diff --git a/pywikibot/page/_basepage.py b/pywikibot/page/_basepage.py index caef2f3..1123fc9 100644 --- a/pywikibot/page/_basepage.py +++ b/pywikibot/page/_basepage.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import itertools import re from collections import Counter diff --git a/pywikibot/page/_category.py b/pywikibot/page/_category.py index 87313a5..2628589 100644 --- a/pywikibot/page/_category.py +++ b/pywikibot/page/_category.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from collections import defaultdict from typing import Any, Optional, Union
diff --git a/pywikibot/page/_collections.py b/pywikibot/page/_collections.py index cea1f71..7bc77d0 100644 --- a/pywikibot/page/_collections.py +++ b/pywikibot/page/_collections.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from collections import defaultdict from collections.abc import MutableMapping, MutableSequence from typing import Optional diff --git a/pywikibot/page/_decorators.py b/pywikibot/page/_decorators.py index 2e90b5d..25911cd 100644 --- a/pywikibot/page/_decorators.py +++ b/pywikibot/page/_decorators.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations +
import pywikibot from pywikibot.exceptions import ( diff --git a/pywikibot/page/_filepage.py b/pywikibot/page/_filepage.py index 2064d98..deb0bf3 100644 --- a/pywikibot/page/_filepage.py +++ b/pywikibot/page/_filepage.py @@ -10,6 +10,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from http import HTTPStatus from os import PathLike from pathlib import Path diff --git a/pywikibot/page/_links.py b/pywikibot/page/_links.py index fb156b8..d043a8f 100644 --- a/pywikibot/page/_links.py +++ b/pywikibot/page/_links.py @@ -10,6 +10,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re import unicodedata from html.entities import name2codepoint diff --git a/pywikibot/page/_page.py b/pywikibot/page/_page.py index cbc4db7..4eed4c0 100644 --- a/pywikibot/page/_page.py +++ b/pywikibot/page/_page.py @@ -13,6 +13,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations +
import pywikibot from pywikibot import textlib diff --git a/pywikibot/page/_revision.py b/pywikibot/page/_revision.py index 0666348..27d077c 100644 --- a/pywikibot/page/_revision.py +++ b/pywikibot/page/_revision.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import hashlib from collections.abc import Mapping from contextlib import suppress diff --git a/pywikibot/page/_toolforge.py b/pywikibot/page/_toolforge.py index 85654cc..3f04cff 100644 --- a/pywikibot/page/_toolforge.py +++ b/pywikibot/page/_toolforge.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import collections import re from typing import Optional diff --git a/pywikibot/page/_user.py b/pywikibot/page/_user.py index 31c62d4..129db11 100644 --- a/pywikibot/page/_user.py +++ b/pywikibot/page/_user.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from typing import Optional
import pywikibot diff --git a/pywikibot/page/_wikibase.py b/pywikibot/page/_wikibase.py index e3da067..c4c467e 100644 --- a/pywikibot/page/_wikibase.py +++ b/pywikibot/page/_wikibase.py @@ -13,6 +13,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import json as jsonlib import re from collections import OrderedDict, defaultdict diff --git a/pywikibot/pagegenerators/__init__.py b/pywikibot/pagegenerators/__init__.py index a18aeb6..3b69598 100644 --- a/pywikibot/pagegenerators/__init__.py +++ b/pywikibot/pagegenerators/__init__.py @@ -17,6 +17,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from typing import Any, Optional
import pywikibot diff --git a/pywikibot/pagegenerators/_factory.py b/pywikibot/pagegenerators/_factory.py index 6c26176..bdde126 100644 --- a/pywikibot/pagegenerators/_factory.py +++ b/pywikibot/pagegenerators/_factory.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import itertools import re import sys diff --git a/pywikibot/pagegenerators/_filters.py b/pywikibot/pagegenerators/_filters.py index 57d720c..e9ef52f 100644 --- a/pywikibot/pagegenerators/_filters.py +++ b/pywikibot/pagegenerators/_filters.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import re from collections import namedtuple diff --git a/pywikibot/pagegenerators/_generators.py b/pywikibot/pagegenerators/_generators.py index d73f499..8b3e656 100644 --- a/pywikibot/pagegenerators/_generators.py +++ b/pywikibot/pagegenerators/_generators.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import calendar import codecs import io diff --git a/pywikibot/plural.py b/pywikibot/plural.py index ea6e5c1..d024886 100644 --- a/pywikibot/plural.py +++ b/pywikibot/plural.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from typing import Callable, Union
from pywikibot.backports import Dict diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py index 6b49b68..51a79b4 100644 --- a/pywikibot/proofreadpage.py +++ b/pywikibot/proofreadpage.py @@ -26,6 +26,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import collections.abc import json import re diff --git a/pywikibot/scripts/__init__.py b/pywikibot/scripts/__init__.py index f5c6223..5428813 100644 --- a/pywikibot/scripts/__init__.py +++ b/pywikibot/scripts/__init__.py @@ -8,8 +8,10 @@ # # (C) Pywikibot team, 2021-2022 # -# Distributed under the terms of the MIT license +# Distributed under the terms of the MIT license. # +from __future__ import annotations + from os import environ, getenv
diff --git a/pywikibot/scripts/generate_family_file.py b/pywikibot/scripts/generate_family_file.py index 5b48299..da41f66 100755 --- a/pywikibot/scripts/generate_family_file.py +++ b/pywikibot/scripts/generate_family_file.py @@ -34,8 +34,10 @@ # # (C) Pywikibot team, 2010-2023 # -# Distributed under the terms of the MIT license +# Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import os import re diff --git a/pywikibot/scripts/generate_user_files.py b/pywikibot/scripts/generate_user_files.py index 2e25b55..1375b4f 100755 --- a/pywikibot/scripts/generate_user_files.py +++ b/pywikibot/scripts/generate_user_files.py @@ -12,6 +12,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import os import re diff --git a/pywikibot/scripts/login.py b/pywikibot/scripts/login.py index 76fc653..536cb17 100755 --- a/pywikibot/scripts/login.py +++ b/pywikibot/scripts/login.py @@ -51,13 +51,15 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime from concurrent.futures import ThreadPoolExecutor -from contextlib import suppress +from contextlib import nullcontext, suppress
import pywikibot from pywikibot import config -from pywikibot.backports import Tuple, nullcontext +from pywikibot.backports import Tuple from pywikibot.exceptions import NoUsernameError, SiteDefinitionError from pywikibot.login import OauthLoginManager
diff --git a/pywikibot/scripts/preload_sites.py b/pywikibot/scripts/preload_sites.py index 1d1b775..543d22f 100755 --- a/pywikibot/scripts/preload_sites.py +++ b/pywikibot/scripts/preload_sites.py @@ -22,6 +22,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from concurrent.futures import ThreadPoolExecutor, wait from datetime import datetime from typing import Optional, Union diff --git a/pywikibot/scripts/shell.py b/pywikibot/scripts/shell.py index 1dafa12..28c4abe 100755 --- a/pywikibot/scripts/shell.py +++ b/pywikibot/scripts/shell.py @@ -20,6 +20,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import code import sys
diff --git a/pywikibot/scripts/version.py b/pywikibot/scripts/version.py index 7a83797..be51af8 100755 --- a/pywikibot/scripts/version.py +++ b/pywikibot/scripts/version.py @@ -9,6 +9,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import os import sys diff --git a/pywikibot/scripts/wrapper.py b/pywikibot/scripts/wrapper.py index cd22f39..ed4590c 100755 --- a/pywikibot/scripts/wrapper.py +++ b/pywikibot/scripts/wrapper.py @@ -42,6 +42,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + # import os import sys diff --git a/pywikibot/site/__init__.py b/pywikibot/site/__init__.py index c0caf25..146ee74 100644 --- a/pywikibot/site/__init__.py +++ b/pywikibot/site/__init__.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot.site._apisite import APISite from pywikibot.site._basesite import BaseSite from pywikibot.site._datasite import DataSite diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py index 381626c..68d1533 100644 --- a/pywikibot/site/_apisite.py +++ b/pywikibot/site/_apisite.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import re import time diff --git a/pywikibot/site/_basesite.py b/pywikibot/site/_basesite.py index 3bf8e06..47f65f6 100644 --- a/pywikibot/site/_basesite.py +++ b/pywikibot/site/_basesite.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import functools import re import threading diff --git a/pywikibot/site/_datasite.py b/pywikibot/site/_datasite.py index e14e4bb..23b37f4 100644 --- a/pywikibot/site/_datasite.py +++ b/pywikibot/site/_datasite.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import json import uuid diff --git a/pywikibot/site/_decorators.py b/pywikibot/site/_decorators.py index 975573b..a89b83e 100644 --- a/pywikibot/site/_decorators.py +++ b/pywikibot/site/_decorators.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from typing import Optional
from pywikibot.exceptions import UnknownExtensionError, UserRightsError diff --git a/pywikibot/site/_extensions.py b/pywikibot/site/_extensions.py index 4aacd21..fd44cb2 100644 --- a/pywikibot/site/_extensions.py +++ b/pywikibot/site/_extensions.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from typing import Any, Optional, Union
import pywikibot diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py index b9fa2b8..141fb69 100644 --- a/pywikibot/site/_generators.py +++ b/pywikibot/site/_generators.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import heapq import itertools import typing diff --git a/pywikibot/site/_interwikimap.py b/pywikibot/site/_interwikimap.py index 9669d22..8b1717b 100644 --- a/pywikibot/site/_interwikimap.py +++ b/pywikibot/site/_interwikimap.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from pywikibot.backports import Set
diff --git a/pywikibot/site/_namespace.py b/pywikibot/site/_namespace.py index dd4877e..223ce8f 100644 --- a/pywikibot/site/_namespace.py +++ b/pywikibot/site/_namespace.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from collections.abc import Iterable, Mapping from enum import IntEnum from typing import Optional, Union diff --git a/pywikibot/site/_obsoletesites.py b/pywikibot/site/_obsoletesites.py index b5c1223..d2467f1 100644 --- a/pywikibot/site/_obsoletesites.py +++ b/pywikibot/site/_obsoletesites.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from pywikibot.backports import Dict, Tuple from pywikibot.exceptions import NoPageError diff --git a/pywikibot/site/_siteinfo.py b/pywikibot/site/_siteinfo.py index 6585c3e..15beb3c 100644 --- a/pywikibot/site/_siteinfo.py +++ b/pywikibot/site/_siteinfo.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import copy import datetime import re diff --git a/pywikibot/site/_tokenwallet.py b/pywikibot/site/_tokenwallet.py index 0d7ec5a..55fb0df 100644 --- a/pywikibot/site/_tokenwallet.py +++ b/pywikibot/site/_tokenwallet.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from collections.abc import Container from typing import TYPE_CHECKING, Any, Optional
diff --git a/pywikibot/site/_upload.py b/pywikibot/site/_upload.py index 7cef645..24db079 100644 --- a/pywikibot/site/_upload.py +++ b/pywikibot/site/_upload.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import mimetypes import os from collections.abc import Iterable diff --git a/pywikibot/site_detect.py b/pywikibot/site_detect.py index 3d61a3f..bca225a 100644 --- a/pywikibot/site_detect.py +++ b/pywikibot/site_detect.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import json import re from contextlib import suppress diff --git a/pywikibot/specialbots/__init__.py b/pywikibot/specialbots/__init__.py index 125522a..4927604 100644 --- a/pywikibot/specialbots/__init__.py +++ b/pywikibot/specialbots/__init__.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot.specialbots._unlink import BaseUnlinkBot, InteractiveUnlink from pywikibot.specialbots._upload import UploadRobot
diff --git a/pywikibot/specialbots/_unlink.py b/pywikibot/specialbots/_unlink.py index 70fe226..96c6566 100644 --- a/pywikibot/specialbots/_unlink.py +++ b/pywikibot/specialbots/_unlink.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot.bot import ( AlwaysChoice, AutomaticTWSummaryBot, diff --git a/pywikibot/specialbots/_upload.py b/pywikibot/specialbots/_upload.py index 3fd8a76..bb6707f 100644 --- a/pywikibot/specialbots/_upload.py +++ b/pywikibot/specialbots/_upload.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os import tempfile from contextlib import suppress diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index ab1e416..d618e0e 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import itertools import re from collections import OrderedDict, namedtuple diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py index 348e751..66e8b57 100644 --- a/pywikibot/throttle.py +++ b/pywikibot/throttle.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import itertools import math import threading diff --git a/pywikibot/time.py b/pywikibot/time.py index 8b2a494..531f1f3 100644 --- a/pywikibot/time.py +++ b/pywikibot/time.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import math import re diff --git a/pywikibot/titletranslate.py b/pywikibot/titletranslate.py index 2a51b08..04c2293 100644 --- a/pywikibot/titletranslate.py +++ b/pywikibot/titletranslate.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from pywikibot import config, date from pywikibot.backports import List diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py index 0f07fc3..0856e6f 100644 --- a/pywikibot/tools/__init__.py +++ b/pywikibot/tools/__init__.py @@ -20,6 +20,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import abc import bz2 import gzip diff --git a/pywikibot/tools/_deprecate.py b/pywikibot/tools/_deprecate.py index 018e355..aa05e05 100644 --- a/pywikibot/tools/_deprecate.py +++ b/pywikibot/tools/_deprecate.py @@ -23,6 +23,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import collections import inspect import re @@ -556,17 +558,15 @@
"""A wrapper for a module to deprecate classes or variables of it."""
- def __init__(self, module) -> None: - """ - Initialise the wrapper. + def __init__(self, module: Union[types.ModuleType, str]) -> None: + """Initialise the wrapper.
It will automatically overwrite the module with this instance in ``sys.modules``.
:param module: The module name or instance - :type module: str or module """ - if isinstance(module, (str, bytes)): + if isinstance(module, str): module = sys.modules[module] super().__setattr__('_deprecated', {}) super().__setattr__('_module', module) diff --git a/pywikibot/tools/_logging.py b/pywikibot/tools/_logging.py index 42f9c7a..09387be 100644 --- a/pywikibot/tools/_logging.py +++ b/pywikibot/tools/_logging.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import logging
from pywikibot.userinterfaces.terminal_interface_base import new_colorTagR diff --git a/pywikibot/tools/_unidata.py b/pywikibot/tools/_unidata.py index f46bb42..438ba5c 100644 --- a/pywikibot/tools/_unidata.py +++ b/pywikibot/tools/_unidata.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations +
# A mapping of characters to their MediaWiki title-cased forms. Python, # depending on version, handles these characters differently, which causes diff --git a/pywikibot/tools/chars.py b/pywikibot/tools/chars.py index 47bfb5a..ee6f016 100644 --- a/pywikibot/tools/chars.py +++ b/pywikibot/tools/chars.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re import sys from contextlib import suppress diff --git a/pywikibot/tools/collections.py b/pywikibot/tools/collections.py index 8b217fa..d6cb156 100644 --- a/pywikibot/tools/collections.py +++ b/pywikibot/tools/collections.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import collections from abc import ABC, abstractmethod from collections.abc import Collection, Generator, Iterator, Mapping diff --git a/pywikibot/tools/djvu.py b/pywikibot/tools/djvu.py index 68d87e9..d2413ae 100644 --- a/pywikibot/tools/djvu.py +++ b/pywikibot/tools/djvu.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os import re import subprocess diff --git a/pywikibot/tools/formatter.py b/pywikibot/tools/formatter.py index ad38a9d..548d72e 100644 --- a/pywikibot/tools/formatter.py +++ b/pywikibot/tools/formatter.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import math import re
diff --git a/pywikibot/tools/itertools.py b/pywikibot/tools/itertools.py index 0c14c7e..ce9cef0 100644 --- a/pywikibot/tools/itertools.py +++ b/pywikibot/tools/itertools.py @@ -8,6 +8,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import collections import itertools from contextlib import suppress diff --git a/pywikibot/tools/threading.py b/pywikibot/tools/threading.py index 37635a8..7ea4590 100644 --- a/pywikibot/tools/threading.py +++ b/pywikibot/tools/threading.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import queue import re import threading diff --git a/pywikibot/userinterfaces/_interface_base.py b/pywikibot/userinterfaces/_interface_base.py index e2fef8f..670a106 100644 --- a/pywikibot/userinterfaces/_interface_base.py +++ b/pywikibot/userinterfaces/_interface_base.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import sys from abc import ABC, abstractmethod from typing import Any, Union diff --git a/pywikibot/userinterfaces/buffer_interface.py b/pywikibot/userinterfaces/buffer_interface.py index 3da1975..d59b4fd 100644 --- a/pywikibot/userinterfaces/buffer_interface.py +++ b/pywikibot/userinterfaces/buffer_interface.py @@ -7,6 +7,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import logging import queue from typing import Any, Sequence, Union diff --git a/pywikibot/userinterfaces/gui.py b/pywikibot/userinterfaces/gui.py index 1eff547..5f641bc 100644 --- a/pywikibot/userinterfaces/gui.py +++ b/pywikibot/userinterfaces/gui.py @@ -17,6 +17,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from typing import Optional
import pywikibot diff --git a/pywikibot/userinterfaces/terminal_interface.py b/pywikibot/userinterfaces/terminal_interface.py index b57c151..cee5dc7 100644 --- a/pywikibot/userinterfaces/terminal_interface.py +++ b/pywikibot/userinterfaces/terminal_interface.py @@ -8,6 +8,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import sys
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py index b58e9c0..67c8e1c 100644 --- a/pywikibot/userinterfaces/terminal_interface_base.py +++ b/pywikibot/userinterfaces/terminal_interface_base.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import getpass import logging import re diff --git a/pywikibot/userinterfaces/terminal_interface_unix.py b/pywikibot/userinterfaces/terminal_interface_unix.py index c5dc737..fc789e2 100644 --- a/pywikibot/userinterfaces/terminal_interface_unix.py +++ b/pywikibot/userinterfaces/terminal_interface_unix.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re
from pywikibot.userinterfaces import terminal_interface_base diff --git a/pywikibot/userinterfaces/terminal_interface_win32.py b/pywikibot/userinterfaces/terminal_interface_win32.py index 4b25740..c2039e2 100644 --- a/pywikibot/userinterfaces/terminal_interface_win32.py +++ b/pywikibot/userinterfaces/terminal_interface_win32.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import ctypes
from pywikibot.userinterfaces import terminal_interface_base diff --git a/pywikibot/userinterfaces/transliteration.py b/pywikibot/userinterfaces/transliteration.py index c0e65ca..395a7b8 100644 --- a/pywikibot/userinterfaces/transliteration.py +++ b/pywikibot/userinterfaces/transliteration.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + #: Non latin digits used by the framework NON_LATIN_DIGITS = { 'bn': '০১২৩৪৫৬à§à§®à§¯', diff --git a/pywikibot/version.py b/pywikibot/version.py index 5a05047..45e6761 100644 --- a/pywikibot/version.py +++ b/pywikibot/version.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import json import os diff --git a/pywikibot/xmlreader.py b/pywikibot/xmlreader.py index 1b4c92d..f2ff662 100644 --- a/pywikibot/xmlreader.py +++ b/pywikibot/xmlreader.py @@ -15,6 +15,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re from typing import Optional
diff --git a/requirements.txt b/requirements.txt index 379761c..f4095df 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,11 +19,9 @@
# mandatory dependencies, others are optional mwparserfromhell>=0.5.2 -requests>=2.21.0, < 2.28.0; python_version < '3.7' -requests>=2.21.0; python_version >= '3.7' +requests>=2.21.0 setuptools>=48.0.0 ; python_version >= '3.10' -setuptools>=40.8.0 ; python_version >= '3.7' and python_version < '3.10' -setuptools>=40.8.0, <59.7.0 ; python_version < '3.7' +setuptools>=40.8.0 ; python_version < '3.10'
# MediaWiki markup parser # mwparserfromhell is mandatory but wikitextparser can be used instead diff --git a/scripts/add_text.py b/scripts/add_text.py index 754e918..27e1d7a 100755 --- a/scripts/add_text.py +++ b/scripts/add_text.py @@ -60,6 +60,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import re from typing import Union diff --git a/scripts/archivebot.py b/scripts/archivebot.py index 466707c..ff45466 100755 --- a/scripts/archivebot.py +++ b/scripts/archivebot.py @@ -121,6 +121,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import locale import os @@ -130,6 +132,7 @@ import time from collections import OrderedDict, defaultdict from concurrent.futures import ThreadPoolExecutor +from contextlib import nullcontext from hashlib import md5 from math import ceil from textwrap import fill @@ -138,7 +141,7 @@
import pywikibot from pywikibot import i18n -from pywikibot.backports import List, Set, Tuple, nullcontext, pairwise +from pywikibot.backports import List, Set, Tuple, pairwise from pywikibot.exceptions import Error, NoPageError from pywikibot.textlib import ( TimeStripper, diff --git a/scripts/basic.py b/scripts/basic.py index 886ab81..5775b2b 100755 --- a/scripts/basic.py +++ b/scripts/basic.py @@ -48,6 +48,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from pywikibot import pagegenerators from pywikibot.bot import ( diff --git a/scripts/blockpageschecker.py b/scripts/blockpageschecker.py index e60ebd0..80834d9 100755 --- a/scripts/blockpageschecker.py +++ b/scripts/blockpageschecker.py @@ -48,6 +48,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re import webbrowser from collections import namedtuple diff --git a/scripts/category.py b/scripts/category.py index ab915dc..cf3f93e 100755 --- a/scripts/category.py +++ b/scripts/category.py @@ -147,6 +147,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import math import os diff --git a/scripts/category_graph.py b/scripts/category_graph.py index 58ae66d..baf552c 100755 --- a/scripts/category_graph.py +++ b/scripts/category_graph.py @@ -41,6 +41,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import argparse from collections import defaultdict
diff --git a/scripts/category_redirect.py b/scripts/category_redirect.py index 1b337c1..e0a3b36 100755 --- a/scripts/category_redirect.py +++ b/scripts/category_redirect.py @@ -34,6 +34,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pickle import re import time diff --git a/scripts/change_pagelang.py b/scripts/change_pagelang.py index d7db330..d977639 100755 --- a/scripts/change_pagelang.py +++ b/scripts/change_pagelang.py @@ -25,6 +25,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from pywikibot import pagegenerators from pywikibot.bot import ConfigParserBot, SingleSiteBot diff --git a/scripts/checkimages.py b/scripts/checkimages.py index 7058430..ced9c25 100755 --- a/scripts/checkimages.py +++ b/scripts/checkimages.py @@ -75,6 +75,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import collections import re import time diff --git a/scripts/claimit.py b/scripts/claimit.py index 72709dc..11ecb4c 100755 --- a/scripts/claimit.py +++ b/scripts/claimit.py @@ -50,6 +50,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from pywikibot import WikidataBot, pagegenerators from pywikibot.backports import batched, removeprefix diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py index 0ca49cb..602ee4f 100755 --- a/scripts/clean_sandbox.py +++ b/scripts/clean_sandbox.py @@ -47,6 +47,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import sys import time diff --git a/scripts/commons_information.py b/scripts/commons_information.py index c1a6bd3..8c2fe59 100755 --- a/scripts/commons_information.py +++ b/scripts/commons_information.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import copy
import mwparserfromhell diff --git a/scripts/commonscat.py b/scripts/commonscat.py index 6820d58..e1f3191 100755 --- a/scripts/commonscat.py +++ b/scripts/commonscat.py @@ -42,6 +42,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re
import pywikibot diff --git a/scripts/coordinate_import.py b/scripts/coordinate_import.py index 56df43c..66aa63e 100755 --- a/scripts/coordinate_import.py +++ b/scripts/coordinate_import.py @@ -46,8 +46,10 @@ # # (C) Pywikibot team, 2013-2023 # -# Distributed under the terms of MIT License. +# Distributed under the terms of MIT license. # +from __future__ import annotations + from typing import Optional
import pywikibot diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py index 72f57ad..2964c61 100755 --- a/scripts/cosmetic_changes.py +++ b/scripts/cosmetic_changes.py @@ -36,6 +36,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from pywikibot import config, pagegenerators from pywikibot.bot import AutomaticTWSummaryBot, ExistingPageBot diff --git a/scripts/create_isbn_edition.py b/scripts/create_isbn_edition.py index 8284dde..b6e41d6 100755 --- a/scripts/create_isbn_edition.py +++ b/scripts/create_isbn_edition.py @@ -228,6 +228,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os # Operating system import re # Regular expressions (very handy!) from itertools import islice diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py index 02b3111..1e4c209 100755 --- a/scripts/data_ingestion.py +++ b/scripts/data_ingestion.py @@ -95,6 +95,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import base64 import codecs import csv diff --git a/scripts/dataextend.py b/scripts/dataextend.py index 5a5eb97..41cdd3f 100755 --- a/scripts/dataextend.py +++ b/scripts/dataextend.py @@ -58,6 +58,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import datetime import re diff --git a/scripts/delete.py b/scripts/delete.py index e4938e4..9292852 100755 --- a/scripts/delete.py +++ b/scripts/delete.py @@ -55,6 +55,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import collections
import pywikibot diff --git a/scripts/delinker.py b/scripts/delinker.py index e17bdc5..d056e61 100755 --- a/scripts/delinker.py +++ b/scripts/delinker.py @@ -34,6 +34,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import configparser import heapq import re diff --git a/scripts/djvutext.py b/scripts/djvutext.py index 6b9a858..6119cee 100755 --- a/scripts/djvutext.py +++ b/scripts/djvutext.py @@ -36,6 +36,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os.path from typing import Optional
diff --git a/scripts/download_dump.py b/scripts/download_dump.py index 9993e4f..8fb42f7 100755 --- a/scripts/download_dump.py +++ b/scripts/download_dump.py @@ -20,6 +20,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import binascii import os.path from http import HTTPStatus diff --git a/scripts/fixing_redirects.py b/scripts/fixing_redirects.py index ab13424..9b52cd7 100755 --- a/scripts/fixing_redirects.py +++ b/scripts/fixing_redirects.py @@ -21,6 +21,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re from concurrent.futures import ThreadPoolExecutor, as_completed from contextlib import suppress diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py index c6e2104..19959d2 100755 --- a/scripts/harvest_template.py +++ b/scripts/harvest_template.py @@ -109,8 +109,10 @@ # # (C) Pywikibot team, 2013-2023 # -# Distributed under the terms of MIT License. +# Distributed under the terms of MIT license. # +from __future__ import annotations + import re import signal import sys diff --git a/scripts/illustrate_wikidata.py b/scripts/illustrate_wikidata.py index af8881d..220bd51 100755 --- a/scripts/illustrate_wikidata.py +++ b/scripts/illustrate_wikidata.py @@ -15,8 +15,10 @@ # # (C) Pywikibot team, 2013-2022 # -# Distributed under the terms of MIT License. +# Distributed under the terms of MIT license. # +from __future__ import annotations + import pywikibot from pywikibot import WikidataBot, pagegenerators
diff --git a/scripts/image.py b/scripts/image.py index 167fa78..328c22a 100755 --- a/scripts/image.py +++ b/scripts/image.py @@ -41,6 +41,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re
import pywikibot diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py index e0ceaf5..eb4bf8c 100755 --- a/scripts/imagetransfer.py +++ b/scripts/imagetransfer.py @@ -41,6 +41,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re import sys
diff --git a/scripts/interwiki.py b/scripts/interwiki.py index 879e4ca..3a5bf95 100755 --- a/scripts/interwiki.py +++ b/scripts/interwiki.py @@ -332,6 +332,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import os import re diff --git a/scripts/interwikidata.py b/scripts/interwikidata.py index 65c6280..0bd717e 100755 --- a/scripts/interwikidata.py +++ b/scripts/interwikidata.py @@ -33,6 +33,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from typing import Union
import pywikibot diff --git a/scripts/listpages.py b/scripts/listpages.py index 469d87f..3efeaf6 100755 --- a/scripts/listpages.py +++ b/scripts/listpages.py @@ -94,6 +94,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os
import pywikibot diff --git a/scripts/maintenance/cache.py b/scripts/maintenance/cache.py index 806d144..fb4abd7 100755 --- a/scripts/maintenance/cache.py +++ b/scripts/maintenance/cache.py @@ -68,6 +68,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import hashlib import os diff --git a/scripts/maintenance/colors.py b/scripts/maintenance/colors.py index fada5d7..bf73742 100755 --- a/scripts/maintenance/colors.py +++ b/scripts/maintenance/colors.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from pywikibot.backports import batched from pywikibot.userinterfaces.terminal_interface_base import colors diff --git a/scripts/maintenance/make_i18n_dict.py b/scripts/maintenance/make_i18n_dict.py index 869a757..577d088 100755 --- a/scripts/maintenance/make_i18n_dict.py +++ b/scripts/maintenance/make_i18n_dict.py @@ -32,6 +32,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import json import os diff --git a/scripts/maintenance/unidata.py b/scripts/maintenance/unidata.py index 29c3444..f2284c4 100755 --- a/scripts/maintenance/unidata.py +++ b/scripts/maintenance/unidata.py @@ -14,6 +14,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from json import dump, load from queue import Queue from re import findall diff --git a/scripts/maintenance/wikimedia_sites.py b/scripts/maintenance/wikimedia_sites.py index 835d410..dc256bb 100755 --- a/scripts/maintenance/wikimedia_sites.py +++ b/scripts/maintenance/wikimedia_sites.py @@ -11,6 +11,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re from pathlib import Path
diff --git a/scripts/misspelling.py b/scripts/misspelling.py index fba59c8..acaf624 100755 --- a/scripts/misspelling.py +++ b/scripts/misspelling.py @@ -25,6 +25,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from itertools import chain from typing import Generator
diff --git a/scripts/movepages.py b/scripts/movepages.py index 029ef2b..b73ce6e 100755 --- a/scripts/movepages.py +++ b/scripts/movepages.py @@ -37,6 +37,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re from functools import partial from itertools import zip_longest diff --git a/scripts/newitem.py b/scripts/newitem.py index 5671960..79f2e89 100755 --- a/scripts/newitem.py +++ b/scripts/newitem.py @@ -24,6 +24,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from datetime import timedelta from textwrap import fill
diff --git a/scripts/noreferences.py b/scripts/noreferences.py index 07a62e0..a0cc0e8 100755 --- a/scripts/noreferences.py +++ b/scripts/noreferences.py @@ -33,6 +33,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re from functools import partial
diff --git a/scripts/nowcommons.py b/scripts/nowcommons.py index 41e3fc8..bea7b45 100755 --- a/scripts/nowcommons.py +++ b/scripts/nowcommons.py @@ -47,6 +47,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import sys from itertools import chain
diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py index 1852105..e8692ff 100755 --- a/scripts/pagefromfile.py +++ b/scripts/pagefromfile.py @@ -64,6 +64,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import os import re diff --git a/scripts/parser_function_count.py b/scripts/parser_function_count.py index 2e12e9a..0eba188 100755 --- a/scripts/parser_function_count.py +++ b/scripts/parser_function_count.py @@ -48,6 +48,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + # Todo: # * Using xml and xmlstart # * Using categories diff --git a/scripts/patrol.py b/scripts/patrol.py index 502a984..cf3df12 100755 --- a/scripts/patrol.py +++ b/scripts/patrol.py @@ -46,6 +46,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import time from collections import defaultdict from contextlib import suppress diff --git a/scripts/protect.py b/scripts/protect.py index 3fb97c6..b9440d2 100755 --- a/scripts/protect.py +++ b/scripts/protect.py @@ -61,6 +61,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from pywikibot import i18n, pagegenerators from pywikibot.bot import ConfigParserBot, CurrentPageBot, SingleSiteBot diff --git a/scripts/redirect.py b/scripts/redirect.py index 28d85d9..6ccbd84 100755 --- a/scripts/redirect.py +++ b/scripts/redirect.py @@ -70,6 +70,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime from contextlib import suppress from textwrap import fill diff --git a/scripts/reflinks.py b/scripts/reflinks.py index fc12ffe..2eceb36 100755 --- a/scripts/reflinks.py +++ b/scripts/reflinks.py @@ -46,6 +46,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import http.client as httplib import itertools import os diff --git a/scripts/replace.py b/scripts/replace.py index e4feecb..cb26370 100755 --- a/scripts/replace.py +++ b/scripts/replace.py @@ -146,6 +146,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re from collections.abc import Sequence from contextlib import suppress diff --git a/scripts/replicate_wiki.py b/scripts/replicate_wiki.py index ace1c14..9c8a523 100755 --- a/scripts/replicate_wiki.py +++ b/scripts/replicate_wiki.py @@ -42,6 +42,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import sys from argparse import ArgumentParser from collections import defaultdict diff --git a/scripts/revertbot.py b/scripts/revertbot.py index 8c08503..9a674ad 100755 --- a/scripts/revertbot.py +++ b/scripts/revertbot.py @@ -39,6 +39,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from typing import Union
import pywikibot diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py index ee9544f..fda1c4a 100755 --- a/scripts/solve_disambiguation.py +++ b/scripts/solve_disambiguation.py @@ -79,6 +79,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import os import re diff --git a/scripts/speedy_delete.py b/scripts/speedy_delete.py index 8052635..76dab20 100755 --- a/scripts/speedy_delete.py +++ b/scripts/speedy_delete.py @@ -26,6 +26,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import time from textwrap import fill
diff --git a/scripts/template.py b/scripts/template.py index 94dccad..0cbc679 100755 --- a/scripts/template.py +++ b/scripts/template.py @@ -105,6 +105,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re
import pywikibot diff --git a/scripts/templatecount.py b/scripts/templatecount.py index a81d559..8eec7f6 100755 --- a/scripts/templatecount.py +++ b/scripts/templatecount.py @@ -37,6 +37,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime from typing import Generator
diff --git a/scripts/touch.py b/scripts/touch.py index 60174f6..3fdfbf5 100755 --- a/scripts/touch.py +++ b/scripts/touch.py @@ -27,6 +27,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from collections import defaultdict from contextlib import suppress
diff --git a/scripts/transferbot.py b/scripts/transferbot.py index 22a6a3e..99c87fb 100755 --- a/scripts/transferbot.py +++ b/scripts/transferbot.py @@ -49,6 +49,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from pywikibot import pagegenerators from pywikibot.bot import suggest_help diff --git a/scripts/transwikiimport.py b/scripts/transwikiimport.py index 3c16a09..eb27a4c 100755 --- a/scripts/transwikiimport.py +++ b/scripts/transwikiimport.py @@ -142,6 +142,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from pywikibot import pagegenerators from pywikibot.backports import Dict diff --git a/scripts/unusedfiles.py b/scripts/unusedfiles.py index 12257a1..5051bc0 100755 --- a/scripts/unusedfiles.py +++ b/scripts/unusedfiles.py @@ -22,6 +22,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re
import pywikibot diff --git a/scripts/upload.py b/scripts/upload.py index d8bdc9a..1fc092a 100755 --- a/scripts/upload.py +++ b/scripts/upload.py @@ -56,6 +56,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import math import os diff --git a/scripts/watchlist.py b/scripts/watchlist.py index 7aa0917..ecb0c66 100755 --- a/scripts/watchlist.py +++ b/scripts/watchlist.py @@ -27,6 +27,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import os from concurrent.futures import ThreadPoolExecutor, as_completed diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py index 02be28c..b5a4975 100755 --- a/scripts/weblinkchecker.py +++ b/scripts/weblinkchecker.py @@ -108,6 +108,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import pickle import re diff --git a/scripts/welcome.py b/scripts/welcome.py index e011f39..3a73095 100755 --- a/scripts/welcome.py +++ b/scripts/welcome.py @@ -160,6 +160,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import locale import pickle diff --git a/setup.py b/setup.py index 59050c1..eb49071 100755 --- a/setup.py +++ b/setup.py @@ -50,10 +50,7 @@ 'Pillow>=8.1.2; platform_machine != "AMD32"'], 'mwoauth': ['mwoauth!=0.3.1,>=0.2.4'], 'html': ['beautifulsoup4>=4.7.1'], - 'http': [ - 'fake-useragent<0.1.14; python_version < "3.7"', - 'fake-useragent>1.2.1; python_version >= "3.7"', - ], + 'http': ['fake-useragent>1.2.1'], 'flake8': [ # Due to incompatibilities between packages the order matters. 'flake8>=5.0.4', 'darglint', @@ -68,10 +65,14 @@ 'flake8-string-format', 'flake8-tuple>=0.4.1', 'flake8-no-u-prefixed-strings>=0.2', - 'pep8-naming>=0.12.1, <0.13.0; python_version < "3.7"', - 'pep8-naming>=0.13.3; python_version >= "3.7"', + 'pep8-naming>=0.13.3', ], - 'hacking': ['hacking'], + 'hacking': [ + 'hacking', + # importlib-metadata module is already installed with hacking 4.1.0 + # used by Python 3.7 but importlib-metadata >= 5 fails, so adjust it + 'importlib-metadata<5.0.0; python_version < "3.8"', + ], }
@@ -88,12 +89,10 @@ # packages which are mandatory dependencies = [ 'mwparserfromhell>=0.5.2', - 'requests>=2.21.0, <2.28.0; python_version < "3.7"', - 'requests>=2.21.0; python_version>="3.7"', + 'requests>=2.21.0', # PEP 440 'setuptools>=48.0.0 ; python_version >= "3.10"', - 'setuptools>=40.8.0 ; python_version >= "3.7" and python_version < "3.10"', - 'setuptools>=40.8.0, <59.7.0 ; python_version < "3.7"', + 'setuptools>=40.8.0 ; python_version < "3.10"', ]
# ------- setup tests_require ------- # @@ -249,7 +248,7 @@ # zip_safe install_requires=dependencies, extras_require=extra_deps, - python_requires='>=3.6.1', + python_requires='>=3.7.0', # namespace_packages test_suite='tests.collector', tests_require=test_deps, @@ -335,13 +334,13 @@ 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Wiki', diff --git a/tests/__init__.py b/tests/__init__.py index 8f10bc7..0cca04c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + __all__ = ( 'create_path_func', 'join_cache_path', 'join_data_path', 'join_html_data_path', 'join_images_path', 'join_pages_path', diff --git a/tests/add_text_tests.py b/tests/add_text_tests.py index 0e9b385..fec18cb 100755 --- a/tests/add_text_tests.py +++ b/tests/add_text_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from unittest.mock import ANY, MagicMock, Mock, mock_open, patch
diff --git a/tests/api_tests.py b/tests/api_tests.py index ea03a0e..1575274 100755 --- a/tests/api_tests.py +++ b/tests/api_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import types import unittest diff --git a/tests/archivebot_tests.py b/tests/archivebot_tests.py index 73283e6..e2c8eae 100755 --- a/tests/archivebot_tests.py +++ b/tests/archivebot_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress from datetime import datetime diff --git a/tests/aspects.py b/tests/aspects.py index 8bb0ec3..f8e1fbb 100644 --- a/tests/aspects.py +++ b/tests/aspects.py @@ -9,6 +9,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import inspect import itertools import os diff --git a/tests/basepage.py b/tests/basepage.py index fcd6bc8..5088097 100644 --- a/tests/basepage.py +++ b/tests/basepage.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot.page import BasePage from tests.aspects import TestCase
diff --git a/tests/basesite_tests.py b/tests/basesite_tests.py index aaab7cb..20cb979 100755 --- a/tests/basesite_tests.py +++ b/tests/basesite_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from contextlib import suppress
import pywikibot diff --git a/tests/bot_tests.py b/tests/bot_tests.py index b2a4c5b..e275ea4 100755 --- a/tests/bot_tests.py +++ b/tests/bot_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import sys from contextlib import suppress
diff --git a/tests/cache_tests.py b/tests/cache_tests.py index 5b57083..6314da5 100755 --- a/tests/cache_tests.py +++ b/tests/cache_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest
import scripts.maintenance.cache as cache diff --git a/tests/category_bot_tests.py b/tests/category_bot_tests.py index 2872cf0..8122c32 100755 --- a/tests/category_bot_tests.py +++ b/tests/category_bot_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress from unittest.mock import Mock, patch diff --git a/tests/category_tests.py b/tests/category_tests.py index 25d0030..ce8610b 100755 --- a/tests/category_tests.py +++ b/tests/category_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/checkimages_tests.py b/tests/checkimages_tests.py index 3e2d9a7..518c582 100755 --- a/tests/checkimages_tests.py +++ b/tests/checkimages_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest
from pywikibot import FilePage diff --git a/tests/collections_tests.py b/tests/collections_tests.py index 821a738..c20f811 100755 --- a/tests/collections_tests.py +++ b/tests/collections_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/cosmetic_changes_tests.py b/tests/cosmetic_changes_tests.py index 4c41716..ed86b5c 100755 --- a/tests/cosmetic_changes_tests.py +++ b/tests/cosmetic_changes_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/data/fixes.py b/tests/data/fixes.py index 178eb22..f1e0996 100644 --- a/tests/data/fixes.py +++ b/tests/data/fixes.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + # flake8 cannot detect that fixes is defined via pywikibot.fixes if 'fixes' not in globals(): fixes = {} diff --git a/tests/data/set-fixes.py b/tests/data/set-fixes.py index 1dee010..3a6be3b 100644 --- a/tests/data/set-fixes.py +++ b/tests/data/set-fixes.py @@ -4,5 +4,7 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + # Just kill the old value suffices fixes = {} diff --git a/tests/data_ingestion_tests.py b/tests/data_ingestion_tests.py index df851b0..3b1bb00 100755 --- a/tests/data_ingestion_tests.py +++ b/tests/data_ingestion_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest
from scripts import data_ingestion diff --git a/tests/datasite_tests.py b/tests/datasite_tests.py index d602374..69231b7 100755 --- a/tests/datasite_tests.py +++ b/tests/datasite_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/date_tests.py b/tests/date_tests.py index 03cbd37..3e5f58c 100755 --- a/tests/date_tests.py +++ b/tests/date_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress from datetime import datetime diff --git a/tests/deletionbot_tests.py b/tests/deletionbot_tests.py index 30de871..0b6382c 100755 --- a/tests/deletionbot_tests.py +++ b/tests/deletionbot_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/djvu_tests.py b/tests/djvu_tests.py index db008fa..17bd8de 100755 --- a/tests/djvu_tests.py +++ b/tests/djvu_tests.py @@ -6,6 +6,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os import subprocess import unittest diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py index ad43304..2870651 100755 --- a/tests/dry_api_tests.py +++ b/tests/dry_api_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime from pathlib import Path from unittest.mock import patch diff --git a/tests/dry_site_tests.py b/tests/dry_site_tests.py index 5b5c6e0..a13602d 100755 --- a/tests/dry_site_tests.py +++ b/tests/dry_site_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest
import pywikibot diff --git a/tests/echo_tests.py b/tests/echo_tests.py index 13cfd27..5d382fc 100755 --- a/tests/echo_tests.py +++ b/tests/echo_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/edit_failure_tests.py b/tests/edit_failure_tests.py index 8b1109c..c16fa02 100755 --- a/tests/edit_failure_tests.py +++ b/tests/edit_failure_tests.py @@ -12,6 +12,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress from unittest.mock import patch diff --git a/tests/edit_tests.py b/tests/edit_tests.py index cb212d9..2ad3b3c 100755 --- a/tests/edit_tests.py +++ b/tests/edit_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import time import unittest from contextlib import suppress diff --git a/tests/eventstreams_tests.py b/tests/eventstreams_tests.py index a5762ec..ef17dcc 100755 --- a/tests/eventstreams_tests.py +++ b/tests/eventstreams_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import json import unittest from contextlib import suppress diff --git a/tests/family_tests.py b/tests/family_tests.py index 3ca109e..02b3860 100755 --- a/tests/family_tests.py +++ b/tests/family_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from collections.abc import Mapping from contextlib import suppress
diff --git a/tests/file_tests.py b/tests/file_tests.py index 0457925..07868a9 100755 --- a/tests/file_tests.py +++ b/tests/file_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os import re import unittest diff --git a/tests/fixes_tests.py b/tests/fixes_tests.py index 67827cb..1bfdc80 100755 --- a/tests/fixes_tests.py +++ b/tests/fixes_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/fixing_redirects_tests.py b/tests/fixing_redirects_tests.py index 3245389..db397c5 100755 --- a/tests/fixing_redirects_tests.py +++ b/tests/fixing_redirects_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from scripts.fixing_redirects import FixingRedirectBot from tests.aspects import TestCase, unittest diff --git a/tests/flow_edit_tests.py b/tests/flow_edit_tests.py index 51bee7c..d1378a0 100755 --- a/tests/flow_edit_tests.py +++ b/tests/flow_edit_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import contextmanager, suppress
diff --git a/tests/flow_tests.py b/tests/flow_tests.py index 4a0ab8f..4056dab 100755 --- a/tests/flow_tests.py +++ b/tests/flow_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/flow_thanks_tests.py b/tests/flow_thanks_tests.py index 21d54db..3f4b293 100755 --- a/tests/flow_thanks_tests.py +++ b/tests/flow_thanks_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/generate_family_file_tests.py b/tests/generate_family_file_tests.py index e97f884..0f8f25c 100755 --- a/tests/generate_family_file_tests.py +++ b/tests/generate_family_file_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress from random import sample diff --git a/tests/generate_user_files_tests.py b/tests/generate_user_files_tests.py index 0034eb9..7bf11cd 100755 --- a/tests/generate_user_files_tests.py +++ b/tests/generate_user_files_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re import unittest from contextlib import suppress diff --git a/tests/gui_tests.py b/tests/gui_tests.py index b25c690..4c6be62 100755 --- a/tests/gui_tests.py +++ b/tests/gui_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os import unittest from contextlib import suppress diff --git a/tests/harvest_template_tests.py b/tests/harvest_template_tests.py index eca883c..9f7de17 100755 --- a/tests/harvest_template_tests.py +++ b/tests/harvest_template_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/http_tests.py b/tests/http_tests.py index eee230b..e3580c2 100755 --- a/tests/http_tests.py +++ b/tests/http_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re import warnings from contextlib import suppress diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py index b39ad00..f14639c 100755 --- a/tests/i18n_tests.py +++ b/tests/i18n_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from contextlib import suppress
import pywikibot diff --git a/tests/interwiki_graph_tests.py b/tests/interwiki_graph_tests.py index ec8ed08..02423dc 100755 --- a/tests/interwiki_graph_tests.py +++ b/tests/interwiki_graph_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/interwiki_link_tests.py b/tests/interwiki_link_tests.py index d7cf6fb..bb73305 100755 --- a/tests/interwiki_link_tests.py +++ b/tests/interwiki_link_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from contextlib import suppress
from pywikibot import config diff --git a/tests/interwikidata_tests.py b/tests/interwikidata_tests.py index 4e507ac..ea66071 100755 --- a/tests/interwikidata_tests.py +++ b/tests/interwikidata_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/interwikimap_tests.py b/tests/interwikimap_tests.py index d8673bb..54e075a 100755 --- a/tests/interwikimap_tests.py +++ b/tests/interwikimap_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/l10n_tests.py b/tests/l10n_tests.py index e4a0531..18a0b32 100755 --- a/tests/l10n_tests.py +++ b/tests/l10n_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress from itertools import chain diff --git a/tests/link_tests.py b/tests/link_tests.py index 32c7605..f2df2b6 100755 --- a/tests/link_tests.py +++ b/tests/link_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re from contextlib import suppress
diff --git a/tests/linter_tests.py b/tests/linter_tests.py index a0b01c8..602e24f 100755 --- a/tests/linter_tests.py +++ b/tests/linter_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/logentries_tests.py b/tests/logentries_tests.py index 1270738..b31f3d8 100755 --- a/tests/logentries_tests.py +++ b/tests/logentries_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import unittest from contextlib import suppress diff --git a/tests/login_tests.py b/tests/login_tests.py index 5b8069f..311f800 100755 --- a/tests/login_tests.py +++ b/tests/login_tests.py @@ -9,6 +9,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from collections import defaultdict from io import StringIO from unittest import mock diff --git a/tests/make_dist_tests.py b/tests/make_dist_tests.py index ef14c98..326f0b6 100755 --- a/tests/make_dist_tests.py +++ b/tests/make_dist_tests.py @@ -5,14 +5,15 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import sys import unittest
from pywikibot import __version__ -from tests.aspects import TestCase, require_modules +from tests.aspects import TestCase
-@require_modules('dataclasses') # Python 3.7+ class TestMakeDist(TestCase):
"""Test the make_dist script.""" diff --git a/tests/mediawikiversion_tests.py b/tests/mediawikiversion_tests.py index 8c1545d..8b9ffdb 100755 --- a/tests/mediawikiversion_tests.py +++ b/tests/mediawikiversion_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/memento_tests.py b/tests/memento_tests.py index b158913..329de2f 100755 --- a/tests/memento_tests.py +++ b/tests/memento_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress from datetime import datetime diff --git a/tests/mysql_tests.py b/tests/mysql_tests.py index 1d35320..821d872 100755 --- a/tests/mysql_tests.py +++ b/tests/mysql_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress from types import GeneratorType diff --git a/tests/namespace_tests.py b/tests/namespace_tests.py index 9906f1f..6b5044c 100755 --- a/tests/namespace_tests.py +++ b/tests/namespace_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from collections.abc import Iterable from contextlib import suppress
diff --git a/tests/noreferences_tests.py b/tests/noreferences_tests.py index bd69b2b..53513c5 100755 --- a/tests/noreferences_tests.py +++ b/tests/noreferences_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot from scripts.noreferences import NoReferencesBot from tests.aspects import TestCase, unittest diff --git a/tests/oauth_tests.py b/tests/oauth_tests.py index 4364367..f886526 100755 --- a/tests/oauth_tests.py +++ b/tests/oauth_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os from contextlib import suppress
diff --git a/tests/page_tests.py b/tests/page_tests.py index 123ea9d..075c79e 100755 --- a/tests/page_tests.py +++ b/tests/page_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pickle import re from contextlib import suppress diff --git a/tests/paraminfo_tests.py b/tests/paraminfo_tests.py index 608b2ec..f4218eb 100755 --- a/tests/paraminfo_tests.py +++ b/tests/paraminfo_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from pywikibot.family import WikimediaFamily from pywikibot.page import Claim, Property from pywikibot.site import DataSite diff --git a/tests/patrolbot_tests.py b/tests/patrolbot_tests.py index 04a0ecd..8d05b43 100755 --- a/tests/patrolbot_tests.py +++ b/tests/patrolbot_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from contextlib import suppress
from scripts.patrol import PatrolBot diff --git a/tests/plural_tests.py b/tests/plural_tests.py index cc5b5a2..51a5219 100755 --- a/tests/plural_tests.py +++ b/tests/plural_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/proofreadpage_tests.py b/tests/proofreadpage_tests.py index 13534e1..7af71e1 100755 --- a/tests/proofreadpage_tests.py +++ b/tests/proofreadpage_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import difflib import json import unittest diff --git a/tests/protectbot_tests.py b/tests/protectbot_tests.py index ec423ab..372cbf0 100755 --- a/tests/protectbot_tests.py +++ b/tests/protectbot_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/pwb/print_argv.py b/tests/pwb/print_argv.py index 2b52111..fd08973 100755 --- a/tests/pwb/print_argv.py +++ b/tests/pwb/print_argv.py @@ -8,6 +8,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot
diff --git a/tests/pwb/print_env.py b/tests/pwb/print_env.py index c015ff2..da2aedb 100755 --- a/tests/pwb/print_env.py +++ b/tests/pwb/print_env.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os import sys
diff --git a/tests/pwb/print_locals.py b/tests/pwb/print_locals.py index 76148f0..707bca7 100755 --- a/tests/pwb/print_locals.py +++ b/tests/pwb/print_locals.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os.path
diff --git a/tests/pwb/print_unicode.py b/tests/pwb/print_unicode.py index 0a753b1..e54fdd5 100755 --- a/tests/pwb/print_unicode.py +++ b/tests/pwb/print_unicode.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pywikibot
diff --git a/tests/pwb_tests.py b/tests/pwb_tests.py index 4fd6314..3684ae9 100755 --- a/tests/pwb_tests.py +++ b/tests/pwb_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import io import sys import unittest diff --git a/tests/redirect_bot_tests.py b/tests/redirect_bot_tests.py index 6f6226f..c3e225c 100755 --- a/tests/redirect_bot_tests.py +++ b/tests/redirect_bot_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress from unittest.mock import Mock, patch diff --git a/tests/reflinks_tests.py b/tests/reflinks_tests.py index 01cf181..633d828 100755 --- a/tests/reflinks_tests.py +++ b/tests/reflinks_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest
from scripts.reflinks import ReferencesRobot, XmlDumpPageGenerator, main diff --git a/tests/replacebot_tests.py b/tests/replacebot_tests.py index d678c0b..98e42b7 100755 --- a/tests/replacebot_tests.py +++ b/tests/replacebot_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/script_tests.py b/tests/script_tests.py index d60ce6c..d705e53 100755 --- a/tests/script_tests.py +++ b/tests/script_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os import sys import unittest diff --git a/tests/site_decorators_tests.py b/tests/site_decorators_tests.py index e556c45..f6e56ca 100755 --- a/tests/site_decorators_tests.py +++ b/tests/site_decorators_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest
from pywikibot.exceptions import UserRightsError diff --git a/tests/site_detect_tests.py b/tests/site_detect_tests.py index 3fc9ddc..189820a 100755 --- a/tests/site_detect_tests.py +++ b/tests/site_detect_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os import unittest from contextlib import suppress diff --git a/tests/site_generators_tests.py b/tests/site_generators_tests.py index fd22d31..f73189a 100755 --- a/tests/site_generators_tests.py +++ b/tests/site_generators_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress from unittest.mock import patch diff --git a/tests/site_login_logout_tests.py b/tests/site_login_logout_tests.py index 5fbdc6e..a095711 100755 --- a/tests/site_login_logout_tests.py +++ b/tests/site_login_logout_tests.py @@ -10,6 +10,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os import unittest from contextlib import suppress diff --git a/tests/site_obsoletesites_tests.py b/tests/site_obsoletesites_tests.py index 15468a7..885ba4c 100755 --- a/tests/site_obsoletesites_tests.py +++ b/tests/site_obsoletesites_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress from http import HTTPStatus diff --git a/tests/site_tests.py b/tests/site_tests.py index 5908217..d2a51cf 100755 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import pickle import random import threading diff --git a/tests/siteinfo_tests.py b/tests/siteinfo_tests.py index f39a6c5..16ea8f5 100755 --- a/tests/siteinfo_tests.py +++ b/tests/siteinfo_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import re import unittest from contextlib import suppress diff --git a/tests/sparql_tests.py b/tests/sparql_tests.py index 25f5aab..1e8a904 100755 --- a/tests/sparql_tests.py +++ b/tests/sparql_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import json import unittest from contextlib import suppress diff --git a/tests/template_bot_tests.py b/tests/template_bot_tests.py index 457760b..34c5fc0 100755 --- a/tests/template_bot_tests.py +++ b/tests/template_bot_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest
import pywikibot diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py index 142b474..76662ba 100755 --- a/tests/textlib_tests.py +++ b/tests/textlib_tests.py @@ -5,18 +5,19 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import codecs import functools import os import re import unittest from collections import OrderedDict -from contextlib import suppress +from contextlib import nullcontext, suppress from unittest import mock
import pywikibot from pywikibot import textlib -from pywikibot.backports import nullcontext from pywikibot.exceptions import UnknownSiteError from pywikibot.site._interwikimap import _IWEntry from pywikibot.textlib import MultiTemplateMatchBuilder, extract_sections diff --git a/tests/thanks_tests.py b/tests/thanks_tests.py index cdbfb72..5f137b6 100755 --- a/tests/thanks_tests.py +++ b/tests/thanks_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/time_tests.py b/tests/time_tests.py index 6e85f8e..57b8e0a 100755 --- a/tests/time_tests.py +++ b/tests/time_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import calendar import re import unittest diff --git a/tests/timestripper_tests.py b/tests/timestripper_tests.py index 2720a17..8556b5a 100755 --- a/tests/timestripper_tests.py +++ b/tests/timestripper_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import datetime import re from contextlib import suppress diff --git a/tests/titletranslate_tests.py b/tests/titletranslate_tests.py index c0fc2ab..faaaf8d 100755 --- a/tests/titletranslate_tests.py +++ b/tests/titletranslate_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest
from pywikibot.titletranslate import translate diff --git a/tests/token_tests.py b/tests/token_tests.py index e62875b..ac2b0f1 100755 --- a/tests/token_tests.py +++ b/tests/token_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/tools_deprecate_tests.py b/tests/tools_deprecate_tests.py index 7999d0f..f45a82e 100755 --- a/tests/tools_deprecate_tests.py +++ b/tests/tools_deprecate_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/tools_formatter_tests.py b/tests/tools_formatter_tests.py index bd62523..5c8cc61 100755 --- a/tests/tools_formatter_tests.py +++ b/tests/tools_formatter_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/tools_threading_tests.py b/tests/tools_threading_tests.py index a4e9f9e..ab19eb4 100755 --- a/tests/tools_threading_tests.py +++ b/tests/tools_threading_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/ui_options_tests.py b/tests/ui_options_tests.py index 1a7fb53..e05efa2 100755 --- a/tests/ui_options_tests.py +++ b/tests/ui_options_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/ui_tests.py b/tests/ui_tests.py index 709f304..2e86b28 100755 --- a/tests/ui_tests.py +++ b/tests/ui_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import io import logging import os diff --git a/tests/upload_tests.py b/tests/upload_tests.py index 3419138..99386ee 100755 --- a/tests/upload_tests.py +++ b/tests/upload_tests.py @@ -9,6 +9,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/uploadbot_tests.py b/tests/uploadbot_tests.py index 5220b8f..a1fe0ca 100755 --- a/tests/uploadbot_tests.py +++ b/tests/uploadbot_tests.py @@ -9,6 +9,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import os import unittest from contextlib import suppress diff --git a/tests/uploadscript_tests.py b/tests/uploadscript_tests.py index cb11feb..046bc0d 100755 --- a/tests/uploadscript_tests.py +++ b/tests/uploadscript_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/user_tests.py b/tests/user_tests.py index 1263d85..ac6d83e 100755 --- a/tests/user_tests.py +++ b/tests/user_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + from contextlib import suppress from unittest.mock import patch
diff --git a/tests/utils.py b/tests/utils.py index 2830ea4..4b287e2 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import inspect import os import sys @@ -21,7 +23,6 @@ from pywikibot.exceptions import APIError from pywikibot.login import LoginStatus from pywikibot.site import Namespace -from pywikibot.tools import PYTHON_VERSION from pywikibot.tools.collections import EMPTY_DEFAULT from tests import _pwb_py
@@ -474,9 +475,6 @@
:param command: executable to run and arguments to use """ - if PYTHON_VERSION < (3, 7): - command.insert(1, '-W ignore::FutureWarning:pywikibot:111') - env = os.environ.copy()
# Prevent output by test package; e.g. 'max_retries reduced from x to y' diff --git a/tests/wikibase_edit_tests.py b/tests/wikibase_edit_tests.py index 33d7dbb..a80eda8 100755 --- a/tests/wikibase_edit_tests.py +++ b/tests/wikibase_edit_tests.py @@ -10,6 +10,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import time import unittest from contextlib import suppress diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py index 549a49d..b8b2399 100755 --- a/tests/wikibase_tests.py +++ b/tests/wikibase_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import copy import datetime import json diff --git a/tests/wikiblame_tests.py b/tests/wikiblame_tests.py index c6b0054..1d6d16a 100644 --- a/tests/wikiblame_tests.py +++ b/tests/wikiblame_tests.py @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tests/wikistats_tests.py b/tests/wikistats_tests.py index 94e867e..238bd15 100755 --- a/tests/wikistats_tests.py +++ b/tests/wikistats_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import sys import unittest from contextlib import suppress diff --git a/tests/xmlreader_tests.py b/tests/xmlreader_tests.py index 0a1c7f0..d5864db 100755 --- a/tests/xmlreader_tests.py +++ b/tests/xmlreader_tests.py @@ -5,6 +5,8 @@ # # Distributed under the terms of the MIT license. # +from __future__ import annotations + import unittest from contextlib import suppress
diff --git a/tox.ini b/tox.ini index a564864..66c39d3 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,6 @@ [params] # Note: tox 4 does not support multiple lines when doing parameters # substitution. -exclude = --exclude make_dist.py,.tox,.git,./*.egg,build,./scripts/i18n/* generate_user_files = -W error::UserWarning -m pwb generate_user_files -family:wikipedia -lang:test -v
[testenv] @@ -28,12 +27,12 @@ commands = python --version flake8: flake8 --version - flake8-py37: flake8 --color always --doctests {posargs} {[params]exclude} - flake8-py38: flake8 --color always --doctests {posargs} - flake8-py39: flake8 --color always --doctests {posargs} + flake8: flake8 --color always --doctests {posargs}
hacking: flake8 --version - hacking: flake8 --format=default {posargs} + hacking-py37: flake8 --format=default {posargs} + hacking-py38: flake8 --color always {posargs} + hacking-py39: flake8 --color always {posargs}
deeptest: python {[params]generate_user_files} deeptest-py37: python -m unittest discover -vv -p "*_tests.py"