jenkins-bot merged this change.

View Change

Approvals: Matěj Suchánek: Looks good to me, approved jenkins-bot: Verified
[cleanup] Remove deprecated ip submodule

ipaddress module is mandatory for Python 2 and pwb.py verifies
whether it is installed. For this reason this tools part is no
longer used. The old deprecated ipregex was already removed.
Now remove the depreprecated submodule too.

Update docs

Bug: T243171
Change-Id: Iaf372d14d4557505c0baa691aa82ab9520f44093
---
M ROADMAP.rst
M docs/api_ref/pywikibot.tools.rst
M pywikibot/CONTENT.rst
M pywikibot/tools/__init__.py
D pywikibot/tools/ip.py
5 files changed, 3 insertions(+), 87 deletions(-)

diff --git a/ROADMAP.rst b/ROADMAP.rst
index b47d6c2..f6a6e38 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -3,6 +3,7 @@

**Note: This is the last release supporting Python 2 and Python 3.4**

+* tools.ip submodule has been removed (T243171)
* Wait in BaseBot.exit() until asynchronous saving pages are completed
* Solve IndexError when showing an empty diff with a non-zero context (T252724)
* linktrails were added or updated for a lot of sites
@@ -21,6 +22,5 @@
* 3.0.20200405: Site and Page methods deprecated for 10 years or longer will be removed
* 3.0.20200326: Functions dealing with stars list will be removed
* 3.0.20200306: Support of MediaWiki releases below 1.19 will be dropped (T245350)
-* 3.0.20200306: tools.ip will be dropped in favour of tools.is_IP (T243171)
* 3.0.20200111: Support for Python 3.4 will be dropped shortly (T239542)
* 3.0.20190722: Support for Python 2 will be dropped shortly (T213287)
diff --git a/docs/api_ref/pywikibot.tools.rst b/docs/api_ref/pywikibot.tools.rst
index abc5aa8..6161292 100644
--- a/docs/api_ref/pywikibot.tools.rst
+++ b/docs/api_ref/pywikibot.tools.rst
@@ -20,10 +20,3 @@
--------------------------------

.. automodule:: pywikibot.tools.formatter
-
-pywikibot.tools.ip module
--------------------------
-
-.. automodule:: pywikibot.tools.ip
-
-
diff --git a/pywikibot/CONTENT.rst b/pywikibot/CONTENT.rst
index e84c039..883d6e3 100644
--- a/pywikibot/CONTENT.rst
+++ b/pywikibot/CONTENT.rst
@@ -136,8 +136,6 @@
+----------------------------+------------------------------------------------------+
| formatter.py | Various formatting related utilities |
+----------------------------+------------------------------------------------------+
- | ip.py | IP address tools module |
- +----------------------------+------------------------------------------------------+


+-----------------------------------------------------------------------------------+
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index b3913b2..de90aec 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -30,6 +30,7 @@
from datetime import datetime
from distutils.version import Version
from functools import wraps
+from ipaddress import ip_address
from warnings import catch_warnings, showwarning, warn

from pywikibot.logging import debug
@@ -42,16 +43,11 @@
import queue
StringTypes = (str, bytes)
UnicodeType = str
- from ipaddress import ip_address
else:
from itertools import izip_longest as zip_longest
import Queue as queue # noqa: N813
StringTypes = types.StringTypes
UnicodeType = types.UnicodeType
- try:
- from ipaddress import ip_address
- except ImportError:
- ip_address = None

try:
import bz2
@@ -387,17 +383,8 @@
@type IP: str
@rtype: bool
"""
- method = ip_address
- if not ip_address: # Python 2 needs ipaddress to be installed
- issue_deprecation_warning(
- 'ipaddr module', 'ipaddress module',
- warning_class=FutureWarning, since='20200120')
- from pywikibot.tools import ip
- with suppress_warnings('pywikibot.tools.ip.is_IP is deprecated'):
- method = ip.is_IP
-
try:
- method(IP)
+ ip_address(IP)
except ValueError:
pass
else:
diff --git a/pywikibot/tools/ip.py b/pywikibot/tools/ip.py
deleted file mode 100644
index e935796..0000000
--- a/pywikibot/tools/ip.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# -*- coding: utf-8 -*-
-"""IP address tools module."""
-#
-# (C) Pywikibot team, 2014-2020
-#
-# Distributed under the terms of the MIT license.
-#
-from __future__ import absolute_import, division, unicode_literals
-
-from distutils.version import StrictVersion
-
-from pywikibot.tools import ModuleDeprecationWrapper
-
-_ipaddress_e = _ipaddr_e = _ipaddr_version = None
-
-try:
- from ipaddress import ip_address
-except ImportError as e:
- _ipaddress_e = e
- ip_address = None
-
-if not ip_address:
- try:
- from ipaddr import __version__ as _ipaddr_version
- except ImportError as e:
- _ipaddr_e = e
- else:
- _ipaddr_version = StrictVersion(_ipaddr_version)
- if _ipaddr_version >= StrictVersion('2.1.10'):
- from ipaddr import IPAddress as ip_address # noqa: N813
- else:
- _ipaddr_e = ImportError('ipaddr %s is broken.' % _ipaddr_version)
-
-if not ip_address:
- raise ImportError('Importing ipaddr.IPAddress failed: {}\n'
- 'Importing ipaddress.ip_address failed: {}\n'
- 'Please install ipaddress.'
- .format(_ipaddr_e, _ipaddress_e))
-
-
-def is_IP(IP):
- """
- Verify the IP address provided is valid.
-
- No logging is performed. Use ip_address instead to catch errors.
-
- @param IP: IP address
- @type IP: str
- @rtype: bool
- """
- try:
- ip_address(IP)
- return True
- except ValueError:
- return False
-
-
-wrapper = ModuleDeprecationWrapper(__name__)
-wrapper._add_deprecated_attr('is_IP',
- replacement_name='tools.is_IP',
- future_warning=True,
- since='20200120')

To view, visit change 595213. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaf372d14d4557505c0baa691aa82ab9520f44093
Gerrit-Change-Number: 595213
Gerrit-PatchSet: 13
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)