jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/623009 )
Change subject: [IMPR] Prevent huge traceback from underlying python libraries
......................................................................
[IMPR] Prevent huge traceback from underlying python libraries
Bug: T253236
Change-Id: I4f8fdb82d538e467ea0e32a83dfb4108f771cc20
---
M pywikibot/comms/http.py
1 file changed, 12 insertions(+), 24 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 848a0b1..165d4c8 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -23,6 +23,7 @@
from http import cookiejar
from string import Formatter
+from typing import Optional, Tuple, Union
from urllib.parse import quote, urlparse
from warnings import warn
@@ -132,7 +133,7 @@
return username
-def user_agent(site=None, format_string=None):
+def user_agent(site=None, format_string: str = None) -> str:
"""
Generate the user agent string for a given site and format.
@@ -140,9 +141,7 @@
@type site: BaseSite
@param format_string: The string to which the values will be added using
str.format. Is using config.user_agent_format when it is None.
- @type format_string: basestring
@return: The formatted user agent
- @rtype: str
"""
values = USER_AGENT_PRODUCTS.copy()
@@ -201,12 +200,8 @@
return fake_user_agent()
-def fake_user_agent():
- """
- Return a fake user agent.
-
- @rtype: str
- """
+def fake_user_agent() -> str:
+ """Return a fake user agent."""
try:
from fake_useragent import UserAgent
except ImportError:
@@ -216,8 +211,8 @@
@deprecate_arg('ssl', None)
-def request(site=None, uri=None, method='GET', params=None, body=None,
- headers=None, data=None, **kwargs):
+def request(site=None, uri: Optional[str] = None, method='GET', params=None,
+ body=None, headers=None, data=None, **kwargs) -> str:
"""
Request to Site with default error handling and response decoding.
@@ -231,13 +226,11 @@
@param site: The Site to connect to
@type site: L{pywikibot.site.BaseSite}
@param uri: the URI to retrieve
- @type uri: str
@keyword charset: Either a valid charset (usable for str.decode()) or None
to automatically chose the charset from the returned header (defaults
to latin-1)
@type charset: CodecInfo, str, None
@return: The received data
- @rtype: a unicode string
"""
# body and data parameters both map to the data parameter of
# requests.Session.request.
@@ -269,14 +262,12 @@
return r.text
-def get_authentication(uri):
+def get_authentication(uri: str) -> Optional[Tuple[str, str]]:
"""
Retrieve authentication token.
@param uri: the URI to access
- @type uri: str
@return: authentication token
- @rtype: None or tuple of two str
"""
parsed_uri = requests.utils.urlparse(uri)
netloc_parts = parsed_uri.netloc.split('.')
@@ -294,7 +285,7 @@
return None
-def _http_process(session, http_request):
+def _http_process(session, http_request) -> None:
"""
Process an `threadedhttp.HttpRequest` instance.
@@ -302,8 +293,6 @@
@type session: L{requests.Session}
@param http_request: Request that will be processed.
@type http_request: L{threadedhttp.HttpRequest}
- @return: None
- @rtype: None
"""
method = http_request.method
uri = http_request.uri
@@ -356,7 +345,7 @@
if isinstance(request.data, Exception):
error('An error occurred for uri ' + request.uri)
- raise request.data
+ raise request.data from None
# HTTP status 207 is also a success status for Webdav FINDPROP,
# used by the version module.
@@ -420,8 +409,9 @@
def fetch(uri, method='GET', params=None, body=None, headers=None,
- default_error_handling=True, use_fake_user_agent=False, data=None,
- **kwargs):
+ default_error_handling: bool = True,
+ use_fake_user_agent: Union[bool, str] = False,
+ data=None, **kwargs):
"""
Blocking HTTP request.
@@ -431,8 +421,6 @@
See L{requests.Session.request} for parameters.
@param default_error_handling: Use default error handling
- @type default_error_handling: bool
- @type use_fake_user_agent: bool, str
@param use_fake_user_agent: Set to True to use fake UA, False to use
pywikibot's UA, str to specify own UA. This behaviour might be
overridden by domain in config.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/623009
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I4f8fdb82d538e467ea0e32a83dfb4108f771cc20
Gerrit-Change-Number: 623009
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/611706 )
Change subject: [tests] exclude setup.py code parts from coverage
......................................................................
[tests] exclude setup.py code parts from coverage
Change-Id: I47d386d05eb1a9341ecbf5371fb1616201191e11
---
M setup.py
1 file changed, 7 insertions(+), 7 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/setup.py b/setup.py
index 242ff93..d96f2f2 100644
--- a/setup.py
+++ b/setup.py
@@ -49,7 +49,7 @@
return PYTHON_VERSION >= (3, 5, 0)
-if not python_is_supported():
+if not python_is_supported(): # pragma: no cover
# pwb.py checks this exception
raise RuntimeError(VERSIONS_REQUIRED_MESSAGE.format(version=sys.version))
@@ -111,7 +111,7 @@
try:
import bz2
-except ImportError:
+except ImportError: # pragma: no cover
# Use bz2file if the python is not compiled with bz2 support.
dependencies.append('bz2file')
else:
@@ -134,7 +134,7 @@
# Add all dependencies as test dependencies,
# so all scripts can be compiled for script_tests, etc.
-if 'PYSETUP_TEST_EXTRAS' in os.environ:
+if 'PYSETUP_TEST_EXTRAS' in os.environ: # pragma: no cover
test_deps += [i for k, v in extra_deps.items() if k != 'flake8' for i in v]
# These extra dependencies are needed other unittest fails to load tests.
@@ -154,7 +154,7 @@
assert metadata.__name__ == name
-def get_validated_version():
+def get_validated_version(): # pragma: no cover
"""Get a validated pywikibot module version string.
The version number from pywikibot.__metadata__.__version__ is used.
@@ -213,7 +213,7 @@
return version
-def read_desc(filename):
+def read_desc(filename): # pragma: no cover
"""Read long description.
Combine included restructured text files which must be done before
@@ -234,7 +234,7 @@
return ''.join(desc)
-def get_packages(name):
+def get_packages(name): # pragma: no cover
"""Find framework packages."""
from setuptools import find_namespace_packages
packages = find_namespace_packages(include=[name + '.*'])
@@ -287,5 +287,5 @@
print('\nDistribution package created for version {}'.format(version))
-if __name__ == '__main__':
+if __name__ == '__main__': # pragma: no cover
main()
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/611706
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I47d386d05eb1a9341ecbf5371fb1616201191e11
Gerrit-Change-Number: 611706
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/622990 )
Change subject: [4.2.1] Prepare next release
......................................................................
[4.2.1] Prepare next release
Change-Id: I2f2cf6685f3c930dd7baa25d83a0ee4dfa558f73
---
M HISTORY.rst
M ROADMAP.rst
M pywikibot/__metadata__.py
3 files changed, 17 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst
index 6808467..fef1f28 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -1,6 +1,21 @@
Release history
===============
+4.2.0
+-----
+
+*28 August 2020*
+
+* Add support for ja.wikivoyage (T261450)
+* Only run cosmetic changes on wikitext pages (T260489)
+* Leave a script gracefully for wrong -lang and -family option (T259756)
+* Change meaning of BasePage.text (T260472)
+* site/family methods code2encodings() and code2encoding() has been removed in favour of encoding()/endcodings() methods
+* Site.getExpandedString() method was removed in favour of expand_text
+* Site.Family() function was removed in favour of Family.load() method
+* Add wikispore family (T260049)
+
+
4.1.1
-----
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 8663a2d..9561aaa 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,14 +1,7 @@
Current release changes
~~~~~~~~~~~~~~~~~~~~~~~
-* Add support for ja.wikivoyage (T261450)
-* Only run cosmetic changes on wikitext pages (T260489)
-* Leave a script gracefully for wrong -lang and -family option (T259756)
-* Change meaning of BasePage.text (T260472)
-* site/family methods code2encodings() and code2encoding() has been removed in favour of encoding()/endcodings() methods
-* Site.getExpandedString() method was removed in favour of expand_text
-* Site.Family() function was removed in favour of Family.load() method
-* Add wikispore family (T260049)
+* (no changes yet)
Future release notes
diff --git a/pywikibot/__metadata__.py b/pywikibot/__metadata__.py
index e00441c..6eb790e 100644
--- a/pywikibot/__metadata__.py
+++ b/pywikibot/__metadata__.py
@@ -6,7 +6,7 @@
# Distributed under the terms of the MIT license.
#
__name__ = 'pywikibot'
-__version__ = '4.2.0'
+__version__ = '4.2.1.dev0'
__description__ = 'Python MediaWiki Bot Framework'
__maintainer__ = 'The Pywikibot team'
__maintainer_email__ = 'pywikibot(a)lists.wikimedia.org'
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/622990
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I2f2cf6685f3c930dd7baa25d83a0ee4dfa558f73
Gerrit-Change-Number: 622990
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged