Skip to content

Commit 5a1f3c4

Browse files
committed
Move the username argument in the Redis and Connection classes to the end
This helps those poor souls that specify all their connection options as non-keyword arguments. Fixes #1276
1 parent e39ae45 commit 5a1f3c4

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
* 3.4.1 (in development)
2+
* Move the username argument in the Redis and Connection classes to the
3+
end of the argument list. This helps those poor souls that specify all
4+
their connection options as non-keyword arguments. #1276
25
* Prior to ACL support, redis-py ignored the username component of
36
Connection URLs. With ACL support, usernames are no longer ignored and
47
are used to authenticate against an ACL rule. Some cloud vendors with

redis/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ def from_url(cls, url, db=None, **kwargs):
674674
return cls(connection_pool=connection_pool)
675675

676676
def __init__(self, host='localhost', port=6379,
677-
db=0, username=None, password=None, socket_timeout=None,
677+
db=0, password=None, socket_timeout=None,
678678
socket_connect_timeout=None,
679679
socket_keepalive=None, socket_keepalive_options=None,
680680
connection_pool=None, unix_socket_path=None,
@@ -685,7 +685,7 @@ def __init__(self, host='localhost', port=6379,
685685
ssl_cert_reqs='required', ssl_ca_certs=None,
686686
ssl_check_hostname=False,
687687
max_connections=None, single_connection_client=False,
688-
health_check_interval=0, client_name=None):
688+
health_check_interval=0, client_name=None, username=None):
689689
if not connection_pool:
690690
if charset is not None:
691691
warnings.warn(DeprecationWarning(

redis/connection.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,14 +490,13 @@ def read_response(self):
490490
class Connection(object):
491491
"Manages TCP communication to and from a Redis server"
492492

493-
def __init__(self, host='localhost', port=6379, db=0, username=None,
494-
password=None, socket_timeout=None,
495-
socket_connect_timeout=None, socket_keepalive=False,
496-
socket_keepalive_options=None, socket_type=0,
497-
retry_on_timeout=False, encoding='utf-8',
493+
def __init__(self, host='localhost', port=6379, db=0, password=None,
494+
socket_timeout=None, socket_connect_timeout=None,
495+
socket_keepalive=False, socket_keepalive_options=None,
496+
socket_type=0, retry_on_timeout=False, encoding='utf-8',
498497
encoding_errors='strict', decode_responses=False,
499498
parser_class=DefaultParser, socket_read_size=65536,
500-
health_check_interval=0, client_name=None):
499+
health_check_interval=0, client_name=None, username=None):
501500
self.pid = os.getpid()
502501
self.host = host
503502
self.port = int(port)

0 commit comments

Comments
 (0)