From 40517cd97911053576d5a7c238090623036e4c29db0dfc3ff921ccda8607e222 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 13 Sep 2024 19:07:55 +0000 Subject: [PATCH] - Add remove-six.patch (gh#gruns/furl#175) removing the dependency on six. - Add fix-test_odd_urls.patch fixing the failure of tests/test_furl.py::TestFurl::test_odd_urls test with the recent Python interpreters (gh#gruns/furl#176). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-furl?expand=0&rev=24 --- fix-test_odd_urls.patch | 15 +++ python-furl.changes | 9 ++ python-furl.spec | 8 +- remove-six.patch | 210 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 240 insertions(+), 2 deletions(-) create mode 100644 fix-test_odd_urls.patch create mode 100644 remove-six.patch diff --git a/fix-test_odd_urls.patch b/fix-test_odd_urls.patch new file mode 100644 index 0000000..6d644b6 --- /dev/null +++ b/fix-test_odd_urls.patch @@ -0,0 +1,15 @@ +--- + tests/test_furl.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/tests/test_furl.py ++++ b/tests/test_furl.py +@@ -1637,7 +1637,7 @@ class TestFurl(unittest.TestCase): + # of a netloc, even if the netloc is empty. + f = furl.furl('////path') + assert f.netloc == '' and str(f.path) == '//path' +- assert f.url == '////path' ++ assert f.url in ('//////path', '////path') + + # TODO(grun): Test more odd URLs. + diff --git a/python-furl.changes b/python-furl.changes index 09156dc..e36ac6a 100644 --- a/python-furl.changes +++ b/python-furl.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Fri Sep 13 18:56:20 UTC 2024 - Matej Cepl + +- Add remove-six.patch (gh#gruns/furl#175) removing the + dependency on six. +- Add fix-test_odd_urls.patch fixing the failure of + tests/test_furl.py::TestFurl::test_odd_urls test with the + recent Python interpreters (gh#gruns/furl#176). + ------------------------------------------------------------------- Tue Jul 2 20:29:03 UTC 2024 - Dirk Müller diff --git a/python-furl.spec b/python-furl.spec index 538601f..7543d37 100644 --- a/python-furl.spec +++ b/python-furl.spec @@ -30,17 +30,21 @@ Source: https://files.pythonhosted.org/packages/source/f/furl/furl-%{ver # use ipaddress to parse IP addresses Patch0: 165-use-ipaddress-library.patch Patch1: netloc-tests.patch +# PATCH-FEATURE-UPSTREAM remove-six.patch gh#gruns/furl#175 mcepl@suse.com +# remove the need of using six +Patch2: remove-six.patch +# PATCH-FIX-UPSTREAM fix-test_odd_urls.patch gh#gruns/furl#176 mcepl@suse.com +# Python currently parses '////path' URL in a different way +Patch3: fix-test_odd_urls.patch BuildRequires: %{python_module pip} BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-orderedmultidict >= 1.0.1 -Requires: python-six >= 1.8.0 BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module orderedmultidict >= 1.0.1} BuildRequires: %{python_module pytest} -BuildRequires: %{python_module six >= 1.8.0} # /SECTION %python_subpackages diff --git a/remove-six.patch b/remove-six.patch new file mode 100644 index 0000000..9cfae7b --- /dev/null +++ b/remove-six.patch @@ -0,0 +1,210 @@ +--- + furl.egg-info/requires.txt | 1 - + furl/furl.py | 34 ++++++++++++++-------------------- + setup.py | 2 -- + tests/test_furl.py | 7 ++----- + tests/test_omdict1D.py | 7 +++---- + 5 files changed, 19 insertions(+), 32 deletions(-) + +--- a/furl.egg-info/requires.txt ++++ b/furl.egg-info/requires.txt +@@ -1,2 +1 @@ +-six>=1.8.0 + orderedmultidict>=1.0.1 +--- a/furl/furl.py ++++ b/furl/furl.py +@@ -17,9 +17,8 @@ import warnings + from copy import deepcopy + from posixpath import normpath + +-import six +-from six.moves import urllib +-from six.moves.urllib.parse import quote, unquote ++import urllib ++from urllib.parse import quote, unquote + try: + from icecream import ic + except ImportError: # Graceful fallback if IceCream isn't installed. +@@ -138,7 +137,7 @@ def is_valid_port(port): + + def static_vars(**kwargs): + def decorator(func): +- for key, value in six.iteritems(kwargs): ++ for key, value in kwargs.items(): + setattr(func, key, value) + return func + return decorator +@@ -243,7 +242,7 @@ def is_valid_host(hostname): + + + def is_valid_ipv4(ip): +- if isinstance(ip, six.binary_type): ++ if isinstance(ip, bytes): + ip = ip.decode() + + try: +@@ -254,7 +253,7 @@ def is_valid_ipv4(ip): + + + def is_valid_ipv6(ip): +- if isinstance(ip, six.binary_type): ++ if isinstance(ip, bytes): + ip = ip.decode() + + # ipaddress handle IPs without brackets +@@ -733,8 +732,7 @@ class Path(object): + return '/'.join(segments) + + +-@six.add_metaclass(abc.ABCMeta) +-class PathCompositionInterface(object): ++class PathCompositionInterface(object, metaclass=abc.ABCMeta): + + """ + Abstract class interface for a parent class that contains a Path. +@@ -784,8 +782,7 @@ class PathCompositionInterface(object): + return False + + +-@six.add_metaclass(abc.ABCMeta) +-class URLPathCompositionInterface(PathCompositionInterface): ++class URLPathCompositionInterface(PathCompositionInterface, metaclass=abc.ABCMeta): + + """ + Abstract class interface for a parent class that contains a URL +@@ -812,8 +809,7 @@ class URLPathCompositionInterface(PathCo + return bool(path) and self.netloc + + +-@six.add_metaclass(abc.ABCMeta) +-class FragmentPathCompositionInterface(PathCompositionInterface): ++class FragmentPathCompositionInterface(PathCompositionInterface, metaclass=abc.ABCMeta): + + """ + Abstract class interface for a parent class that contains a Fragment +@@ -1125,7 +1121,7 @@ class Query(object): + elif callable_attr(items, 'iteritems'): + items = list(items.iteritems()) + # Encoded query string. e.g. 'a=1&b=2&c=3' +- elif isinstance(items, six.string_types): ++ elif isinstance(items, str): + items = self._extract_items_from_querystr(items) + # Default to list of key:value items interface. e.g. [('a','1'), + # ('b','2')] +@@ -1141,7 +1137,7 @@ class Query(object): + pairs = [item.split('=', 1) for item in pairstrs] + pairs = [(p[0], lget(p, 1, '')) for p in pairs] # Pad with value ''. + +- for pairstr, (key, value) in six.moves.zip(pairstrs, pairs): ++ for pairstr, (key, value) in zip(pairstrs, pairs): + valid_key = is_valid_encoded_query_key(key) + valid_value = is_valid_encoded_query_value(value) + if self.strict and (not valid_key or not valid_value): +@@ -1163,8 +1159,7 @@ class Query(object): + return items + + +-@six.add_metaclass(abc.ABCMeta) +-class QueryCompositionInterface(object): ++class QueryCompositionInterface(object, metaclass=abc.ABCMeta): + + """ + Abstract class interface for a parent class that contains a Query. +@@ -1331,8 +1326,7 @@ class Fragment(FragmentPathCompositionIn + return "%s('%s')" % (self.__class__.__name__, str(self)) + + +-@six.add_metaclass(abc.ABCMeta) +-class FragmentCompositionInterface(object): ++class FragmentCompositionInterface(object, metaclass=abc.ABCMeta): + + """ + Abstract class interface for a parent class that contains a +@@ -1430,7 +1424,7 @@ class furl(URLPathCompositionInterface, + + if url is None: + url = '' +- if not isinstance(url, six.string_types): ++ if not isinstance(url, str): + url = str(url) + + # urlsplit() raises a ValueError on malformed IPv6 addresses in +@@ -1874,7 +1868,7 @@ class furl(URLPathCompositionInterface, + + def join(self, *urls): + for url in urls: +- if not isinstance(url, six.string_types): ++ if not isinstance(url, str): + url = str(url) + newurl = urljoin(self.url, url) + self.load(newurl) +--- a/setup.py ++++ b/setup.py +@@ -104,10 +104,8 @@ setup( + ], + tests_require=[ + 'flake8', +- 'six>=1.8.0', + ], + install_requires=[ +- 'six>=1.8.0', + 'orderedmultidict>=1.0.1', + 'ipaddress>=1.0.23; python_version < "3.3"', + ], +--- a/tests/test_furl.py ++++ b/tests/test_furl.py +@@ -16,9 +16,7 @@ import warnings + from abc import ABCMeta, abstractmethod + import sys + +-import six +-from six.moves import zip +-from six.moves.urllib.parse import ( ++from urllib.parse import ( + quote, quote_plus, parse_qsl, urlsplit, SplitResult) + + import furl +@@ -35,8 +33,7 @@ import unittest + # + + +-@six.add_metaclass(ABCMeta) +-class itemcontainer(object): ++class itemcontainer(object, metaclass=ABCMeta): + + """ + Utility list subclasses to expose allitems() and iterallitems() +--- a/tests/test_omdict1D.py ++++ b/tests/test_omdict1D.py +@@ -13,7 +13,6 @@ + import unittest + from itertools import chain, product, permutations + +-import six + from furl.omdict1D import omdict1D + from orderedmultidict import omdict + +@@ -48,12 +47,12 @@ class TestOmdict1D(unittest.TestCase): + data.update(update) + omd1.update(update) + omd2.updateall(update) +- for key in six.iterkeys(omd1): ++ for key in omd1.keys(): + if isinstance(data[key], list): + assert omd1[key] == data[key][-1] + else: + assert omd1[key] == data[key] +- for key in six.iterkeys(omd2): ++ for key in omd2.keys(): + data_values_unpacked = [] + for value in data.getlist(key): + if isinstance(value, list): +@@ -149,7 +148,7 @@ class TestOmdict1D(unittest.TestCase): + + def test_setitem(self): + omd = omdict1D() +- for value, valuelist in six.moves.zip(self.values, self.valuelists): ++ for value, valuelist in zip(self.values, self.valuelists): + if valuelist: + omd[self.key] = valuelist + assert omd[self.key] == omd.get(self.key) == valuelist[0]