Date: Thursday, May 13, 2021 @ 10:36:29
  Author: anthraxx
Revision: 933005

upgpkg: python-click-threading 0.4.4-10: click 8.0 compat

https://github.com/click-contrib/click-threading/pull/5

Added:
  python-click-threading/trunk/fix-click-8.0-compat.patch
Modified:
  python-click-threading/trunk/PKGBUILD

----------------------------+
 PKGBUILD                   |   15 +++++++++++----
 fix-click-8.0-compat.patch |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 4 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD    2021-05-13 10:17:04 UTC (rev 933004)
+++ PKGBUILD    2021-05-13 10:36:29 UTC (rev 933005)
@@ -4,18 +4,25 @@
 _name=click-threading
 pkgname=python-click-threading
 pkgver=0.4.4
-pkgrel=9
+pkgrel=10
 pkgdesc="Multithreaded Click apps made easy"
 arch=("any")
 url="https://pypi.python.org/pypi/click-threading";
 license=("MIT")
 depends=("python-click")
-makedepends=("python-setuptools" "python2-setuptools")
+makedepends=("python-setuptools")
 checkdepends=("python-pytest" "python-click")
-source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz";)
+source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz";
+        fix-click-8.0-compat.patch)
 
#source=("${_name}-${pkgver}.tar.gz::https://github.com/click-contrib/${_name}/archive/${pkgver}.tar.gz";)
-sha512sums=('7fd17ad04065160a3278eab4e2c070424d9d69de145e88a8dc2ad9a3064162d91ad5c46b8d30e19640b2c4b420c0bb801ff6fd6dd9985f34ce2ede35cf8373f1')
+sha512sums=('7fd17ad04065160a3278eab4e2c070424d9d69de145e88a8dc2ad9a3064162d91ad5c46b8d30e19640b2c4b420c0bb801ff6fd6dd9985f34ce2ede35cf8373f1'
+            
'712726854065215ebaddd62e589ec64b5b056a090bcd8fc2bc5e2c784831f48d205b700e04662d653f87306faa02972f9c7d5b55958c552156346b180c99b1f7')
 
+prepare() {
+  cd "${_name}-${pkgver}"
+  patch -Np1 < ../fix-click-8.0-compat.patch
+}
+
 build() {
   cd "${_name}-${pkgver}"
   python setup.py build

Added: fix-click-8.0-compat.patch
===================================================================
--- fix-click-8.0-compat.patch                          (rev 0)
+++ fix-click-8.0-compat.patch  2021-05-13 10:36:29 UTC (rev 933005)
@@ -0,0 +1,42 @@
+From 7194508dfedb1a29709927de6e8d9f8480a0017a Mon Sep 17 00:00:00 2001
+From: Jim Turner <g...@turner.link>
+Date: Wed, 12 May 2021 19:07:41 -0400
+Subject: [PATCH] Fix monkey-patching of functions with annotations
+
+click 8.0.0 [added type annotations][1] which broke click-threading's
+monkey patching of these functions. This commit is a small change to
+fix the issue. Note that this commit uses the `inspect.Signature`
+type, which was added in Python 3.3.
+
+[1]: 
https://github.com/pallets/click/commit/0103c9570650daa59560baf42ad0a27e57b3157f
+---
+ click_threading/monkey.py | 16 ++++++++++------
+ 1 file changed, 10 insertions(+), 6 deletions(-)
+
+diff --git a/click_threading/monkey.py b/click_threading/monkey.py
+index 1c16cd6..20361ff 100644
+--- a/click_threading/monkey.py
++++ b/click_threading/monkey.py
+@@ -40,12 +40,16 @@ def patch_ui_functions(wrapper):
+ 
+         new_f = wrapper(_copy_fn(f), info)
+ 
+-        argspec = getargspec(f)
+-        signature = inspect.formatargspec(*argspec) \
+-            .lstrip('(') \
+-            .rstrip(')')
+-        args = ', '.join(arg.split('=')[0].split(':')[0].strip()
+-                         for arg in signature.split(','))
++        orig_sig_obj = inspect.signature(f)
++        sig_obj = orig_sig_obj.replace(
++            parameters=[
++                p.replace(annotation=inspect.Parameter.empty)
++                for p in orig_sig_obj.parameters.values()
++            ],
++            return_annotation=inspect.Signature.empty,
++        )
++        signature = str(sig_obj).lstrip('(').rstrip(')')
++        args = ', '.join(p for p in sig_obj.parameters.keys())
+ 
+         stub_f = eval('lambda {s}: {n}._real_click_fn({a})'
+                       .format(n=f.__name__, s=signature, a=args))

Reply via email to