internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: rucio/rucio

Issue:
Poller is too chatty
Motivation
----------
Dumps internal dictionaries into logfile, blowing up the logfile size on the nodes.



Discussion:

Resolving patch:
diff --git a/lib/rucio/daemons/conveyor/poller.py b/lib/rucio/daemons/conveyor/poller.py
--- a/lib/rucio/daemons/conveyor/poller.py
+++ b/lib/rucio/daemons/conveyor/poller.py
@@ -1,4 +1,4 @@
-# Copyright 2013-2018 CERN for the benefit of the ATLAS collaboration.
+# Copyright 2013-2020 CERN for the benefit of the ATLAS collaboration.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
 # limitations under the License.
 #
 # Authors:
-# - Mario Lassnig <mario.lassnig@cern.ch>, 2013-2015
+# - Mario Lassnig <mario.lassnig@cern.ch>, 2013-2020
 # - Cedric Serfon <cedric.serfon@cern.ch>, 2013-2018
 # - Vincent Garonne <vgaronne@gmail.com>, 2014-2018
 # - Wen Guan <wguan.icedew@gmail.com>, 2014-2016
@@ -248,7 +248,6 @@ def poll_transfers(external_host, xfers, prepend_str='', request_ids=None, timeo
                 try:
                     logging.debug(prepend_str + 'Checking %s on %s' % (xfer, external_host))
                     status = transfer_core.bulk_query_transfers(external_host, [xfer, ], TRANSFER_TOOL, timeout)
-                    logging.debug(prepend_str + str(status))
                     if xfer in status and isinstance(status[xfer], Exception):
                         logging.error(prepend_str + 'Problem querying %s on %s . Error returned : %s' % (xfer, external_host, str(status[xfer])))
                 except Exception as err:


Test patch:
Repository: rucio/rucio

Issue:
Improvements in meta CLI tools
Motivation
----------
```
$ rucio get-did-meta test:mc_v9-8GeV-1e-ecal-photonuclear_t1587142184.root
IsSimulation: True
Geant4BiasParticle: gamma
```
The output should be tabulated like `rucio get-metadata`.

```
$ rucio list-dids-by-meta --scope test Geant4BiasFactor=550.0
2020-04-24 11:27:39,085	INFO	test:mc_v9-8GeV-1e-ecal-photonuclear_t1586373478.root
2020-04-24 11:27:39,085	INFO	test:mc_v9-8GeV-1e-ecal-photonuclear_t1586434315.root
```
The output should be a simple print and not a log message.



Discussion:
You can assign to me.

Resolving patch:
diff --git a/lib/rucio/common/dumper/consistency.py b/lib/rucio/common/dumper/consistency.py
--- a/lib/rucio/common/dumper/consistency.py
+++ b/lib/rucio/common/dumper/consistency.py
@@ -17,6 +17,7 @@
 # - Joaquin Bogado <jbogado@linti.unlp.edu.ar>, 2018
 # - Hannes Hansen <hannes.jakob.hansen@cern.ch>, 2018-2019
 # - Mario Lassnig <mario.lassnig@cern.ch>, 2019
+# - Dimitrios Christidis <dimitrios.christidis@cern.ch>, 2020
 #
 # PY3K COMPATIBLE
 
@@ -42,7 +43,7 @@ class Consistency(data_models.DataModel):
 
     @classmethod
     def dump(cls, subcommand, ddm_endpoint, storage_dump, prev_date_fname=None, next_date_fname=None,
-             prev_date=None, next_date=None, sort_rucio_replica_dumps=False, date=None,
+             prev_date=None, next_date=None, sort_rucio_replica_dumps=True, date=None,
              cache_dir=DUMPS_CACHE_DIR):
         logger = logging.getLogger('auditor.consistency')
         if subcommand == 'consistency':
diff --git a/lib/rucio/daemons/auditor/hdfs.py b/lib/rucio/daemons/auditor/hdfs.py
--- a/lib/rucio/daemons/auditor/hdfs.py
+++ b/lib/rucio/daemons/auditor/hdfs.py
@@ -7,6 +7,7 @@
 
  Authors:
  - Fernando Lopez, <felopez@cern.ch>, 2015
+ - Dimitrios Christidis, <dimitrios.christidis@cern.ch>, 2020
 
  PY3K COMPATIBLE
 '''
@@ -39,7 +40,7 @@ def _hdfs_get(src_url, dst_path):
 
 
 class ReplicaFromHDFS(Replica):
-    BASE_URL = '/user/rucio01/reports/{0}/replicas_per_rse/{1}.bz2/*'
+    BASE_URL = '/user/rucio01/reports/{0}/replicas_per_rse/{1}/*'
 
     @classmethod
     def download(cls, rse, date, cache_dir=DUMPS_CACHE_DIR, buffer_size=65536):
diff --git a/lib/rucio/web/ui/common/utils.py b/lib/rucio/web/ui/common/utils.py
--- a/lib/rucio/web/ui/common/utils.py
+++ b/lib/rucio/web/ui/common/utils.py
@@ -6,7 +6,7 @@
 # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 #
 # Authors:
-# - Thomas Beermann, <thomas.beermann@cern.ch>, 2014-2019
+# - Thomas Beermann, <thomas.beermann@cern.ch>, 2014-2020
 # - Ruturaj Gujar, <ruturaj.gujar23@gmail.com>, 2019
 # - Jaroslav Guenther, <jaroslav.guenther@cern.ch>, 2019-2020
 #
@@ -157,6 +157,8 @@ def get_token(token_method, acc=None, idt=None, pwd=None):
         acc = ctx.env.get('HTTP_X_RUCIO_ACCOUNT')
     if not idt:
         idt = ctx.env.get('SSL_CLIENT_S_DN')
+        if not idt.startswith('/'):
+            idt = '/%s' % '/'.join(idt.split(',')[::-1])
     if not (acc and idt):
         return None
     try:


Test patch:
Repository: rucio/rucio

Issue:
Add possibility to ask for Staging from DISK RSEs
Motivation
----------
Due to novel R&D in the area of QoS for storage systems, there are storages which are a hybrid between DISK & TAPE. However, in Rucio they need to be assigned one type. If the assignment is DISK all third party copy transfer requests will be done without asking for a STAGING/BRINGONLINE request, which will fail in certain conditions. The proposal of this issue is to add an RSE attribute `staging_required` (Name to be decided) which can be set also for DISK rses. For third-party-copy requests also staging requests are issued for these RSEs.



Discussion:

Resolving patch:
diff --git a/lib/rucio/db/sqla/migrate_repo/versions/a118956323f8_added_vo_table_and_vo_col_to_rse.py b/lib/rucio/db/sqla/migrate_repo/versions/a118956323f8_added_vo_table_and_vo_col_to_rse.py
--- a/lib/rucio/db/sqla/migrate_repo/versions/a118956323f8_added_vo_table_and_vo_col_to_rse.py
+++ b/lib/rucio/db/sqla/migrate_repo/versions/a118956323f8_added_vo_table_and_vo_col_to_rse.py
@@ -26,7 +26,7 @@
 
 
 def String(*arg, **kw):
-    kw['convert_unicode'] = 'force'
+    kw['convert_unicode'] = True
     return sa.String(*arg, **kw)
 
 
diff --git a/lib/rucio/db/sqla/models.py b/lib/rucio/db/sqla/models.py
--- a/lib/rucio/db/sqla/models.py
+++ b/lib/rucio/db/sqla/models.py
@@ -58,17 +58,17 @@
 # Recipe to force str instead if unicode
 # https://groups.google.com/forum/#!msg/sqlalchemy/8Xn31vBfGKU/bAGLNKapvSMJ
 def String(*arg, **kw):
-    kw['convert_unicode'] = 'force'
+    kw['convert_unicode'] = True
     return _String(*arg, **kw)
 
 
 def InternalScopeString(*arg, **kw):
-    kw['convert_unicode'] = 'force'
+    kw['convert_unicode'] = True
     return _InternalScopeString(*arg, **kw)
 
 
 def InternalAccountString(*arg, **kw):
-    kw['convert_unicode'] = 'force'
+    kw['convert_unicode'] = True
     return _InternalAccountString(*arg, **kw)
 
 
diff --git a/lib/rucio/vcsversion.py b/lib/rucio/vcsversion.py
--- a/lib/rucio/vcsversion.py
+++ b/lib/rucio/vcsversion.py
@@ -4,8 +4,8 @@
 '''
 VERSION_INFO = {
     'final': True,
-    'version': '1.22.5',
-    'branch_nick': 'patch-0-Release__1_22_5_preparation',
-    'revision_id': '12c42ad15e55ed30a5fd6ddf90526e657827740c',
-    'revno': 9457
+    'version': '1.22.6',
+    'branch_nick': 'patch-0-Release_1_22_6_preparation',
+    'revision_id': '066294e11bd163f076479369946d2192cd23fcbd',
+    'revno': 9500
 }


Test patch:
Repository: rucio/rucio

Issue:
Fix for unicode enforced strings brakes Python 2.7 deployment
Motivation
----------
The fix deployed in #3480 apparently brakes Python 2.7 deployments.

Modification
------------

I will put the change back and make it conditional to Python 2.7:
```python
if sys.version_info[0] < 3:
    kw['convert_unicode'] = 'force'
```
This should at least fix it for Python 2.7, possibly for 3.* as well.


Discussion:

Resolving patch:
diff --git a/lib/rucio/db/sqla/models.py b/lib/rucio/db/sqla/models.py
--- a/lib/rucio/db/sqla/models.py
+++ b/lib/rucio/db/sqla/models.py
@@ -18,7 +18,7 @@
 # - Angelos Molfetas, <angelos.molfetas@cern.ch>, 2012
 # - Ralph Vigne, <ralph.vigne@cern.ch>, 2013
 # - Cedric Serfon, <cedric.serfon@cern.ch>, 2013-2018
-# - Martin Barisits, <martin.barisits@cern.ch>, 2013-2019
+# - Martin Barisits, <martin.barisits@cern.ch>, 2013-2020
 # - Wen Guan, <wen.guan@cern.ch>, 2015
 # - Joaquin Bogado <jbogado@linti.unlp.edu.ar>, 2015-2019
 # - Hannes Hansen, <hannes.jakob.hansen@cern.ch>, 2019
@@ -29,6 +29,7 @@
 # PY3K COMPATIBLE
 
 import datetime
+import sys
 import uuid
 
 from six import iteritems
@@ -58,17 +59,20 @@
 # Recipe to force str instead if unicode
 # https://groups.google.com/forum/#!msg/sqlalchemy/8Xn31vBfGKU/bAGLNKapvSMJ
 def String(*arg, **kw):
-    kw['convert_unicode'] = True
+    if sys.version_info[0] < 3:
+        kw['convert_unicode'] = 'force'
     return _String(*arg, **kw)
 
 
 def InternalScopeString(*arg, **kw):
-    kw['convert_unicode'] = True
+    if sys.version_info[0] < 3:
+        kw['convert_unicode'] = 'force'
     return _InternalScopeString(*arg, **kw)
 
 
 def InternalAccountString(*arg, **kw):
-    kw['convert_unicode'] = True
+    if sys.version_info[0] < 3:
+        kw['convert_unicode'] = 'force'
     return _InternalAccountString(*arg, **kw)
 
 


Test patch:
Repository: rucio/rucio

Issue:
ius repo link is being decommissioned
Motivation
----------
The link currently used for the CentOS repo (https://centos7.iuscommunity.org/ius-release.rpm) is being decommissioned and replaced with a new link (https://repo.ius.io/ius-release-el7.rpm). Trying to use the old link will cause the Travis suites to error/fail.

Modification
------------
Change to the new link.




Discussion:

Resolving patch:
diff --git a/lib/rucio/client/ruleclient.py b/lib/rucio/client/ruleclient.py
--- a/lib/rucio/client/ruleclient.py
+++ b/lib/rucio/client/ruleclient.py
@@ -21,6 +21,11 @@
 #
 # PY3K COMPATIBLE
 
+try:
+    from urllib import quote_plus
+except ImportError:
+    from urllib.parse import quote_plus
+
 from json import dumps, loads
 from requests.status_codes import codes
 
@@ -205,7 +210,7 @@ def list_replication_rule_full_history(self, scope, name):
         :param scope: The scope of the DID.
         :param name: The name of the DID.
         """
-        path = self.RULE_BASEURL + '/' + scope + '/' + name + '/history'
+        path = '/'.join([self.RULE_BASEURL, quote_plus(scope), quote_plus(name), 'history'])
         url = build_url(choice(self.list_hosts), path=path)
         r = self._send_request(url, type='GET')
         if r.status_code == codes.ok:


Test patch:
Repository: rucio/rucio

Issue:
ius repo link is being decommissioned
Motivation
----------
The link currently used for the CentOS repo (https://centos7.iuscommunity.org/ius-release.rpm) is being decommissioned and replaced with a new link (https://repo.ius.io/ius-release-el7.rpm). Trying to use the old link will cause the Travis suites to error/fail.

Modification
------------
Change to the new link.




Discussion:

Resolving patch:
diff --git a/lib/rucio/core/monitor.py b/lib/rucio/core/monitor.py
--- a/lib/rucio/core/monitor.py
+++ b/lib/rucio/core/monitor.py
@@ -25,16 +25,16 @@
 from prometheus_client import start_http_server
 from statsd import StatsClient
 
-from rucio.common.config import config_get
+from rucio.common.config import config_get, config_get_bool, config_get_int
 
 SERVER = config_get('monitor', 'carbon_server', raise_exception=False, default='localhost')
 PORT = config_get('monitor', 'carbon_port', raise_exception=False, default=8125)
 SCOPE = config_get('monitor', 'user_scope', raise_exception=False, default='rucio')
 CLIENT = StatsClient(host=SERVER, port=PORT, prefix=SCOPE)
 
-ENABLE_METRICS = config_get('monitor', 'enable_metrics', raise_exception=False, default=False)
+ENABLE_METRICS = config_get_bool('monitor', 'enable_metrics', raise_exception=False, default=False)
 if ENABLE_METRICS:
-    METRICS_PORT = config_get('monitor', 'metrics_port', raise_exception=False, default=8080)
+    METRICS_PORT = config_get_int('monitor', 'metrics_port', raise_exception=False, default=8080)
     start_http_server(METRICS_PORT)
 
 


Test patch:
Repository: rucio/rucio

Issue:
Multihop resolve query inefficient in case of not-connected RSEs
Motivation
----------
The resolve query takes a lot of time in cases where the RSE is not connected.


Modification
------------
Need to introduce thresholds to speed up the query.




Discussion:

Resolving patch:
diff --git a/lib/rucio/core/transfer.py b/lib/rucio/core/transfer.py
--- a/lib/rucio/core/transfer.py
+++ b/lib/rucio/core/transfer.py
@@ -488,8 +488,7 @@ def get_hops(source_rse_id, dest_rse_id, include_multihop=False, multihop_rses=N
     if multihop_rses is None:
         multihop_rses = []
 
-    # TODO: Might be problematic to always load the distance_graph, since it might be expensive
-    # TODO: Have an rse_expression to specify the eligible hops
+    # TODO: Might be problematic to always load the distance_graph, since it might be expensiv
 
     # Load the graph from the distances table
     # distance_graph = __load_distance_graph(session=session)
@@ -523,6 +522,11 @@ def get_hops(source_rse_id, dest_rse_id, include_multihop=False, multihop_rses=N
     # 2. There is no connection or no scheme match --> Try a multi hop --> Dijkstra algorithm
     HOP_PENALTY = core_config_get('transfers', 'hop_penalty', default=10, session=session)  # Penalty to be applied to each further hop
 
+    # Check if the destination RSE is an island RSE:
+    if not __load_distance_edges_node(rse_id=dest_rse_id, session=session):
+        # The destination RSE is an island
+        raise NoDistance()
+
     visited_nodes = {source_rse_id: {'distance': 0,
                                      'path': []}}  # Dijkstra already visisted nodes
     # {rse_id: {'path': [{'source_rse_id':, 'dest_rse_id':, 'source_scheme', 'dest_scheme': }],


Test patch:
Repository: rucio/rucio

Issue:
list-rules --file should show an appropriate error if the DID does not exist
Motivation
----------

```
$ rucio list-rules --file foo:bar
ID    ACCOUNT    SCOPE:NAME    STATE[OK/REPL/STUCK]    RSE_EXPRESSION    COPIES    EXPIRES (UTC)    CREATED (UTC)
----  ---------  ------------  ----------------------  ----------------  --------  ---------------  ---------------
```

Modification
------------

Raise a `DataIdentifierNotFound` exception.



Discussion:

Resolving patch:
diff --git a/lib/rucio/core/rule.py b/lib/rucio/core/rule.py
--- a/lib/rucio/core/rule.py
+++ b/lib/rucio/core/rule.py
@@ -855,6 +855,7 @@ def list_associated_rules_for_file(scope, name, session=None):
     :raises:        RucioException
     """
 
+    rucio.core.did.get_did(scope=scope, name=name, session=session)  # Check if the did acually exists
     query = session.query(models.ReplicationRule).\
         with_hint(models.ReplicaLock, "INDEX(LOCKS LOCKS_PK)", 'oracle').\
         join(models.ReplicaLock, models.ReplicationRule.id == models.ReplicaLock.rule_id).\
diff --git a/lib/rucio/web/rest/webpy/v1/did.py b/lib/rucio/web/rest/webpy/v1/did.py
--- a/lib/rucio/web/rest/webpy/v1/did.py
+++ b/lib/rucio/web/rest/webpy/v1/did.py
@@ -20,7 +20,7 @@
 # - Mario Lassnig <mario.lassnig@cern.ch>, 2012-2018
 # - Yun-Pin Sun <yun-pin.sun@cern.ch>, 2013
 # - Cedric Serfon <cedric.serfon@cern.ch>, 2014-2018
-# - Martin Baristis <martin.barisits@cern.ch>, 2014-2015
+# - Martin Baristis <martin.barisits@cern.ch>, 2014-2020
 # - Hannes Hansen <hannes.jakob.hansen@cern.ch>, 2018-2019
 # - Ruturaj Gujar, <ruturaj.gujar23@gmail.com>, 2019
 #
@@ -703,6 +703,8 @@ def GET(self, scope, name):
         try:
             for rule in list_associated_replication_rules_for_file(scope=scope, name=name):
                 yield dumps(rule, cls=APIEncoder) + '\n'
+        except DataIdentifierNotFound as error:
+            raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0])
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:


Test patch:
Repository: rucio/rucio

Issue:
__sort_link_ranking in conveyor is done in wrong order
Motivation
----------
https://github.com/rucio/rucio/blob/defa6efc011bb5c30ddf1177f7d6ea26bc8556b4/lib/rucio/daemons/conveyor/submitter.py#L361
This should not be done in reverse but in a normal sort.

Modification
------------
Remove `reverse=True`




Discussion:

Resolving patch:
diff --git a/lib/rucio/daemons/conveyor/submitter.py b/lib/rucio/daemons/conveyor/submitter.py
--- a/lib/rucio/daemons/conveyor/submitter.py
+++ b/lib/rucio/daemons/conveyor/submitter.py
@@ -363,7 +363,7 @@ def __sort_link_ranking(sources):
             rank_sources[link_ranking] = []
         rank_sources[link_ranking].append(source)
     rank_keys = list(rank_sources.keys())
-    rank_keys.sort(reverse=True)
+    rank_keys.sort()
     for rank_key in rank_keys:
         sources_list = rank_sources[rank_key]
         random.shuffle(sources_list)


Test patch:
Repository: rucio/rucio

Issue:
List all rules does not have a python equivalent, only REST
Motivation
----------

CMS wants this to filter on rules waiting for approval.

Modification
------------

Add it to python client. Don't expose to CLI to discourage mis-use




Discussion:

Resolving patch:
diff --git a/lib/rucio/client/ruleclient.py b/lib/rucio/client/ruleclient.py
--- a/lib/rucio/client/ruleclient.py
+++ b/lib/rucio/client/ruleclient.py
@@ -247,3 +247,20 @@ def list_replica_locks(self, rule_id):
             return self._load_json_data(r)
         exc_cls, exc_msg = self._get_exception(r.headers, r.status_code)
         raise exc_cls(exc_msg)
+
+    def list_replication_rules(self, filters=None):
+        """
+        List all replication rules which match a filter
+        :param filters: dictionary of attributes by which the rules should be filtered
+
+        :returns: True if successful, otherwise false.
+        """
+        filters = filters or {}
+        path = self.RULE_BASEURL + '/'
+        url = build_url(choice(self.list_hosts), path=path)
+        r = self._send_request(url, type='GET', params=filters)
+        if r.status_code == codes.ok:
+            return self._load_json_data(r)
+        else:
+            exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
+            raise exc_cls(exc_msg)


Test patch:
Repository: rucio/rucio

Issue:
Unable to create new meta key with string type
Motivation
----------
If one attempts to make a DID key with a string value type:
```python
client.add_key(
    key="asdf",
    key_type="COLLECTION",
    value_type=str,
    value_regexp="\w{,50}",
)
```
then an exception is raised:
```
rucio.common.exception.UnsupportedValueType: Unsupported type for the value. List of supported types: (<type 'float'>, <type 'int'>, (<type 'basestring'>,)).
Details: The type '<type 'str'>' is not supported for values!
```

Proposal
---------
This is due to https://github.com/rucio/rucio/blob/master/lib/rucio/common/constraints.py#L25 where `six.string_types` is a tuple and should be added rather than nested. But that is not enough, as depending on whether you are in python2 or python3, different types will be valid. Really this should be an enum.

Note: tested in v1.22.2


Discussion:

Resolving patch:
diff --git a/lib/rucio/common/constraints.py b/lib/rucio/common/constraints.py
--- a/lib/rucio/common/constraints.py
+++ b/lib/rucio/common/constraints.py
@@ -1,4 +1,4 @@
-# Copyright 2012-2018 CERN for the benefit of the ATLAS collaboration.
+# Copyright 2012-2020 CERN for the benefit of the ATLAS collaboration.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -16,11 +16,12 @@
 # - Vincent Garonne <vgaronne@gmail.com>, 2012-2018
 # - Frank Berghaus <frank.berghaus@cern.ch>, 2018
 # - Hannes Hansen <hannes.jakob.hansen@cern.ch>, 2019
+# - Martin Barisits <martin.barisits@cern.ch>, 2020
 #
 # PY3K COMPATIBLE
 
 from six import string_types
 
 # List of authorized value types for key
-AUTHORIZED_VALUE_TYPES = (float, int, string_types)
+AUTHORIZED_VALUE_TYPES = (float, int) + string_types
 STRING_TYPES = string_types


Test patch:
Repository: rucio/rucio

Issue:
Unused and broken submodule `doc/source/sphinx-argparse`
Motivation
----------
Currently the submodule `doc/source/sphinx-argparse` is registered in git, but a .gitmodules file is missing and it seems to be unused.


Modification
------------
Check if it is really unused and remove the mentioned submodule from git.


Discussion:

Resolving patch:
diff --git a/lib/rucio/daemons/conveyor/receiver.py b/lib/rucio/daemons/conveyor/receiver.py
--- a/lib/rucio/daemons/conveyor/receiver.py
+++ b/lib/rucio/daemons/conveyor/receiver.py
@@ -185,7 +185,7 @@ def receiver(id, total_threads=1, full_mode=False):
 
     logging.info('receiver starting in full mode: %s' % full_mode)
 
-    executable = ' '.join(sys.argv)
+    executable = 'conveyor-receiver'
     hostname = socket.getfqdn()
     pid = os.getpid()
     hb_thread = threading.current_thread()


Test patch:
Repository: rucio/rucio

Issue:
Unused and broken submodule `doc/source/sphinx-argparse`
Motivation
----------
Currently the submodule `doc/source/sphinx-argparse` is registered in git, but a .gitmodules file is missing and it seems to be unused.


Modification
------------
Check if it is really unused and remove the mentioned submodule from git.


Discussion:

Resolving patch:
diff --git a/lib/rucio/common/utils.py b/lib/rucio/common/utils.py
--- a/lib/rucio/common/utils.py
+++ b/lib/rucio/common/utils.py
@@ -222,8 +222,8 @@ def all_oidc_req_claims_present(scope, audience, required_scope, required_audien
         req_scope_present = all(elem in scope for elem in required_scope)
         req_audience_present = all(elem in audience for elem in required_audience)
         return req_scope_present and req_audience_present
-    elif (isinstance(scope, basestring) and isinstance(audience, basestring) and  # NOQA: W504
-          isinstance(required_scope, basestring) and isinstance(required_audience, basestring)):
+    elif (isinstance(scope, string_types) and isinstance(audience, string_types) and  # NOQA: W504
+          isinstance(required_scope, string_types) and isinstance(required_audience, string_types)):
         scope = str(scope)
         audience = str(audience)
         required_scope = str(required_scope)
@@ -232,7 +232,7 @@ def all_oidc_req_claims_present(scope, audience, required_scope, required_audien
         req_audience_present = all(elem in audience.split(sepatator) for elem in required_audience.split(sepatator))
         return req_scope_present and req_audience_present
     elif (isinstance(scope, list) and isinstance(audience, list) and  # NOQA: W504
-          isinstance(required_scope, basestring) and isinstance(required_audience, basestring)):
+          isinstance(required_scope, string_types) and isinstance(required_audience, string_types)):
         scope = [str(it) for it in scope]
         audience = [str(it) for it in audience]
         required_scope = str(required_scope)
@@ -240,7 +240,7 @@ def all_oidc_req_claims_present(scope, audience, required_scope, required_audien
         req_scope_present = all(elem in scope for elem in required_scope.split(sepatator))
         req_audience_present = all(elem in audience for elem in required_audience.split(sepatator))
         return req_scope_present and req_audience_present
-    elif (isinstance(scope, basestring) and isinstance(audience, basestring) and  # NOQA: W504
+    elif (isinstance(scope, string_types) and isinstance(audience, string_types) and  # NOQA: W504
           isinstance(required_scope, list) and isinstance(required_audience, list)):
         scope = str(scope)
         audience = str(audience)


Test patch: