Skip to content

Commit

Permalink
Fix the lint errors found by ruff.
Browse files Browse the repository at this point in the history
  • Loading branch information
amjith committed Nov 25, 2024
1 parent 8d8fc08 commit 551984b
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion mycli/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ def mycli_line_magic(line):
return

if q.successful:
ipython = get_ipython()
ipython = get_ipython() # noqa: F821
return ipython.run_cell_magic("sql", line, q.query)
2 changes: 1 addition & 1 deletion mycli/packages/completion_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def suggest_based_on_last_token(token, text_before_cursor, full_text, identifier
else:
token_v = token.value.lower()

is_operand = lambda x: x and any([x.endswith(op) for op in ["+", "-", "*", "/"]])
is_operand = lambda x: x and any([x.endswith(op) for op in ["+", "-", "*", "/"]]) # noqa: E731

if not token:
return [{"type": "keyword"}, {"type": "special"}]
Expand Down
4 changes: 2 additions & 2 deletions mycli/packages/special/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ def export(defn):
return defn


from . import dbcommands
from . import iocommands
from . import dbcommands # noqa: E402 F401
from . import iocommands # noqa: E402 F401
2 changes: 1 addition & 1 deletion mycli/sqlexecute.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pymysql.converters import convert_datetime, convert_timedelta, convert_date, conversions, decoders

try:
import paramiko
import paramiko # noqa: F401
import sshtunnel
except ImportError:
pass
Expand Down
4 changes: 2 additions & 2 deletions test/features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def before_all(context):
os.environ["PROMPT_TOOLKIT_NO_CPR"] = "1"
os.environ["MYCLI_HISTFILE"] = os.devnull

test_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
login_path_file = os.path.join(test_dir, "mylogin.cnf")
# test_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
# login_path_file = os.path.join(test_dir, "mylogin.cnf")
# os.environ['MYSQL_TEST_LOGIN_FILE'] = login_path_file

context.package_root = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
Expand Down
16 changes: 8 additions & 8 deletions test/features/steps/basic_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from behave import when
from behave import when, then
from textwrap import dedent
import tempfile
import wrappers
Expand All @@ -28,9 +28,9 @@ def step_ctrl_d(context):
context.exit_sent = True


@when('we send "\?" command')
@when(r'we send "\?" command')
def step_send_help(context):
"""Send \?
r"""Send \?
to see help.
Expand All @@ -42,9 +42,9 @@ def step_send_help(context):
@when("we send source command")
def step_send_source_command(context):
with tempfile.NamedTemporaryFile() as f:
f.write(b"\?")
f.write(b"\\?")
f.flush()
context.cli.sendline("\. {0}".format(f.name))
context.cli.sendline("\\. {0}".format(f.name))
wrappers.expect_exact(context, context.conf["pager_boundary"] + "\r\n", timeout=5)


Expand Down Expand Up @@ -75,21 +75,21 @@ def step_see_found(context):


@then("we confirm the destructive warning")
def step_confirm_destructive_command(context):
def step_confirm_destructive_command(context): # noqa
"""Confirm destructive command."""
wrappers.expect_exact(context, "You're about to run a destructive command.\r\nDo you want to proceed? (y/n):", timeout=2)
context.cli.sendline("y")


@when('we answer the destructive warning with "{confirmation}"')
def step_confirm_destructive_command(context, confirmation):
def step_confirm_destructive_command(context, confirmation): # noqa
"""Confirm destructive command."""
wrappers.expect_exact(context, "You're about to run a destructive command.\r\nDo you want to proceed? (y/n):", timeout=2)
context.cli.sendline(confirmation)


@then('we answer the destructive warning with invalid "{confirmation}" and see text "{text}"')
def step_confirm_destructive_command(context, confirmation, text):
def step_confirm_destructive_command(context, confirmation, text): # noqa
"""Confirm destructive command."""
wrappers.expect_exact(context, "You're about to run a destructive command.\r\nDo you want to proceed? (y/n):", timeout=2)
context.cli.sendline(confirmation)
Expand Down
1 change: 1 addition & 0 deletions test/myclirc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ output.null = "#808080"
# Favorite queries.
[favorite_queries]
check = 'select "✔"'
foo_args = 'SELECT $1, "$2", "$3"'

# Use the -d option to reference a DSN.
# Special characters in passwords and other strings can be escaped with URL encoding.
Expand Down
4 changes: 2 additions & 2 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def db_connection(dbname=None):
try:
db_connection()
CAN_CONNECT_TO_DB = True
except:
except Exception:
CAN_CONNECT_TO_DB = False

dbtest = pytest.mark.skipif(not CAN_CONNECT_TO_DB, reason="Need a mysql instance at localhost accessible by user 'root'")
Expand All @@ -39,7 +39,7 @@ def create_db(dbname):
try:
cur.execute("""DROP DATABASE IF EXISTS mycli_test_db""")
cur.execute("""CREATE DATABASE mycli_test_db""")
except:
except Exception:
pass


Expand Down

0 comments on commit 551984b

Please sign in to comment.