jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/620057 )

Change subject: [cleanup] Desupport tools.signature in favour of 
inspect.signature
......................................................................

[cleanup] Desupport tools.signature in favour of inspect.signature

Change-Id: I4587ca270869219a8803c173f19ccbc453daae1b
---
M pywikibot/tools/__init__.py
1 file changed, 4 insertions(+), 21 deletions(-)

Approvals:
  Matěj Suchánek: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 958a55c..0fe224e 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -1080,24 +1080,6 @@
 # a deprecator without any arguments.


-def signature(obj):
-    """
-    Safely return function Signature object (PEP 362).
-
-    inspect.signature was introduced in 3.3, however backports are available.
-
-    Any exception calling inspect.signature is ignored and None is returned.
-
-    @param obj: Function to inspect
-    @type obj: callable
-    @rtype: inpect.Signature or None
-    """
-    try:
-        return inspect.signature(obj)
-    except (AttributeError, ValueError):
-        return None
-
-
 def add_decorated_full_name(obj, stacklevel=1):
     """Extract full object name, including class, and store in __full_name__.

@@ -1129,7 +1111,7 @@
     wrapper.__doc__ = obj.__doc__
     wrapper.__name__ = obj.__name__
     wrapper.__module__ = obj.__module__
-    wrapper.__signature__ = signature(obj)
+    wrapper.__signature__ = inspect.signature(obj)

     if not hasattr(obj, '__full_name__'):
         add_decorated_full_name(obj, 2)
@@ -1197,7 +1179,7 @@
         inner_wrapper.__doc__ = obj.__doc__
         inner_wrapper.__name__ = obj.__name__
         inner_wrapper.__module__ = obj.__module__
-        inner_wrapper.__signature__ = signature(obj)
+        inner_wrapper.__signature__ = inspect.signature(obj)

         # The decorator being decorated may have args, so both
         # syntax need to be supported.
@@ -1473,7 +1455,6 @@

         if wrapper.__signature__:
             # Build a new signature with deprecated args added.
-            # __signature__ is only available in Python 3 which has OrderedDict
             params = collections.OrderedDict()
             for param in wrapper.__signature__.parameters.values():
                 params[param.name] = param.replace()
@@ -1859,3 +1840,5 @@
                              since='20200712', future_warning=True)
 wrapper._add_deprecated_attr('UnicodeType', str,
                              since='20200813', future_warning=True)
+wrapper._add_deprecated_attr('signature', inspect.signature,
+                             since='20200813', future_warning=True)

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/620057
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: I4587ca270869219a8803c173f19ccbc453daae1b
Gerrit-Change-Number: 620057
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to