Skip to content

Commit 7d5e479

Browse files
committed
Fix linting issues detected by the latest pylint version
Change-Id: I47997a2d17733811013aa5c0da654ea16bc30496
1 parent 099e3f1 commit 7d5e479

File tree

7 files changed

+13
-16
lines changed

7 files changed

+13
-16
lines changed

lib/mysql/connector/connection_cext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import socket
3434

3535
from . import version
36-
from .abstracts import MySQLConnectionAbstract, MySQLCursorAbstract
36+
from .abstracts import MySQLConnectionAbstract
3737
from .constants import CharacterSet, ClientFlag, FieldFlag, ServerFlag, ShutdownType
3838
from .errors import (
3939
InterfaceError,

lib/mysql/connector/cursor.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,6 @@ def _check_executed(self):
359359
if self._executed is None:
360360
raise InterfaceError(ERR_NO_RESULT_TO_FETCH)
361361

362-
def next(self):
363-
"""Used for iterating over the result set."""
364-
return self.__next__()
365-
366362
def __next__(self):
367363
"""
368364
Used for iterating over the result set. Calles self.fetchone()

lib/mysql/connector/protocol.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def make_conn_attrs(conn_attrs):
162162
if conn_attrs[attr_name] is None:
163163
conn_attrs[attr_name] = ""
164164
conn_attrs_len = (
165-
sum([len(x) + len(conn_attrs[x]) for x in conn_attrs])
165+
sum(len(x) + len(conn_attrs[x]) for x in conn_attrs)
166166
+ len(conn_attrs.keys())
167167
+ len(conn_attrs.values())
168168
)
@@ -810,8 +810,7 @@ def make_stmt_execute(
810810
"Failed executing prepared statement: data values does not"
811811
" match number of parameters"
812812
)
813-
for pos, _ in enumerate(data):
814-
value = data[pos]
813+
for pos, value in enumerate(data):
815814
_flags = 0
816815
if value is None:
817816
null_bitmap[(pos // 8)] |= 1 << (pos % 8)

lib/mysqlx/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,7 @@ def use_pure(self):
22242224
return Protobuf.use_pure
22252225

22262226
@use_pure.setter
2227-
def use_pure(self, value): # pylint: disable=no-self-use
2227+
def use_pure(self, value):
22282228
if not isinstance(value, bool):
22292229
raise ProgrammingError("'use_pure' option should be True or False")
22302230
Protobuf.set_use_pure(value)

lib/mysqlx/protocol.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,12 @@ def _get_binding_args(self, stmt, is_scalar=True):
431431
Returns:
432432
list: A list of ``Any`` or ``Scalar`` objects.
433433
"""
434-
build_value = (
435-
lambda value: build_scalar(value).get_message()
436-
if is_scalar
437-
else self._create_any(value).get_message()
438-
)
434+
435+
def build_value(value):
436+
if is_scalar:
437+
return build_scalar(value).get_message()
438+
return self._create_any(value).get_message()
439+
439440
bindings = stmt.get_bindings()
440441
binding_map = stmt.get_binding_map()
441442

lib/mysqlx/statement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ def __init__(self, update_type, source, value=None):
731731
try:
732732
self.source = ExprParser(source, False).document_field().identifier
733733
except ValueError as err:
734-
raise ProgrammingError(f"{err}")
734+
raise ProgrammingError(f"{err}") from err
735735
self.value = value
736736

737737
def _table_set(self, source, value):

tests/test_cursor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,12 @@ def __init__(self):
335335

336336
def test_next(self):
337337
"""MySQLCursor object next()-method"""
338-
self.check_method(self.cur, "next")
338+
self.check_method(self.cur, "__next__")
339339

340340
self.cnx = connection.MySQLConnection(**tests.get_mysql_config())
341341
self.cur = cursor.MySQLCursor(self.cnx)
342342
self.assertRaises(StopIteration, self.cur.__next__)
343+
self.assertRaises(StopIteration, next, self.cur)
343344
self.cur.execute("SELECT BINARY 'ham'")
344345
exp = (bytearray(b"ham"),)
345346
self.assertEqual(exp, next(self.cur))

0 commit comments

Comments
 (0)