Skip to content

Commit 0c50948

Browse files
authored
🎨 black & isort (#45)
1 parent ded1a8e commit 0c50948

File tree

15 files changed

+244
-480
lines changed

15 files changed

+244
-480
lines changed

.github/workflows/test.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,33 @@ name: Test
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches:
6+
- master
67
pull_request:
7-
branches: [ master ]
8+
branches:
9+
- master
10+
defaults:
11+
run:
12+
shell: bash
13+
permissions: read-all
814

915
jobs:
16+
analyze:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Set up Python
21+
uses: actions/setup-python@v3
22+
with:
23+
python-version: "3.x"
24+
- name: Install dependencies
25+
run: |
26+
python3 -m pip install --upgrade pip
27+
pip install -r requirements_dev.txt
28+
- name: Run static analysis
29+
run: tox -e linters
1030
test:
31+
needs: analyze
1132
runs-on: ubuntu-latest
1233
strategy:
1334
matrix:

mysql_to_sqlite3/cli.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
help="SQLite3 database file",
2020
required=True,
2121
)
22-
@click.option(
23-
"-d", "--mysql-database", default=None, help="MySQL database name", required=True
24-
)
22+
@click.option("-d", "--mysql-database", default=None, help="MySQL database name", required=True)
2523
@click.option("-u", "--mysql-user", default=None, help="MySQL user", required=True)
2624
@click.option(
2725
"-p",
@@ -80,24 +78,16 @@
8078
help="Prefix indices with their corresponding tables. "
8179
"This ensures that their names remain unique across the SQLite database.",
8280
)
83-
@click.option(
84-
"-X", "--without-foreign-keys", is_flag=True, help="Do not transfer foreign keys."
85-
)
81+
@click.option("-X", "--without-foreign-keys", is_flag=True, help="Do not transfer foreign keys.")
8682
@click.option(
8783
"-W",
8884
"--without-data",
8985
is_flag=True,
9086
help="Do not transfer table data, DDL only.",
9187
)
92-
@click.option(
93-
"-h", "--mysql-host", default="localhost", help="MySQL host. Defaults to localhost."
94-
)
95-
@click.option(
96-
"-P", "--mysql-port", type=int, default=3306, help="MySQL port. Defaults to 3306."
97-
)
98-
@click.option(
99-
"-S", "--skip-ssl", is_flag=True, help="Disable MySQL connection encryption."
100-
)
88+
@click.option("-h", "--mysql-host", default="localhost", help="MySQL host. Defaults to localhost.")
89+
@click.option("-P", "--mysql-port", type=int, default=3306, help="MySQL port. Defaults to 3306.")
90+
@click.option("-S", "--skip-ssl", is_flag=True, help="Disable MySQL connection encryption.")
10191
@click.option(
10292
"-c",
10393
"--chunk",
@@ -123,9 +113,7 @@
123113
)
124114
@click.option("-q", "--quiet", is_flag=True, help="Quiet. Display only errors.")
125115
@click.option("--debug", is_flag=True, help="Debug mode. Will throw exceptions.")
126-
@click.version_option(
127-
message=tabulate(info(), headers=["software", "version"], tablefmt="github")
128-
)
116+
@click.version_option(message=tabulate(info(), headers=["software", "version"], tablefmt="github"))
129117
def cli(
130118
sqlite_file,
131119
mysql_user,
@@ -153,9 +141,7 @@ def cli(
153141
"""Transfer MySQL to SQLite using the provided CLI options."""
154142
try:
155143
if mysql_tables and exclude_mysql_tables:
156-
raise click.UsageError(
157-
"Illegal usage: --mysql-tables and --exclude-mysql-tables are mutually exclusive!"
158-
)
144+
raise click.UsageError("Illegal usage: --mysql-tables and --exclude-mysql-tables are mutually exclusive!")
159145

160146
converter = MySQLtoSQLite(
161147
sqlite_file=sqlite_file,
@@ -167,8 +153,7 @@ def cli(
167153
limit_rows=limit_rows,
168154
collation=collation,
169155
prefix_indices=prefix_indices,
170-
without_foreign_keys=without_foreign_keys
171-
or (mysql_tables is not None and len(mysql_tables) > 0),
156+
without_foreign_keys=without_foreign_keys or (mysql_tables is not None and len(mysql_tables) > 0),
172157
without_data=without_data,
173158
mysql_host=mysql_host,
174159
mysql_port=mysql_port,

mysql_to_sqlite3/click_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ def parser_process(value, state):
4040
# call the actual process
4141
self._previous_parser_process(value, state)
4242

43-
retval = super(OptionEatAll, self).add_to_parser( # pylint: disable=E1111
44-
parser, ctx
45-
)
43+
retval = super(OptionEatAll, self).add_to_parser(parser, ctx) # pylint: disable=E1111
4644
for name in self.opts:
4745
# pylint: disable=W0212
4846
our_parser = parser._long_opt.get(name) or parser._short_opt.get(name)

mysql_to_sqlite3/debug_info.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ def _implementation():
4444
sys.pypy_version_info.minor, # noqa: ignore=E1101 pylint: disable=E1101
4545
sys.pypy_version_info.micro, # noqa: ignore=E1101 pylint: disable=E1101
4646
)
47-
rel = (
48-
sys.pypy_version_info.releaselevel # noqa: ignore=E1101 pylint: disable=E1101
49-
)
47+
rel = sys.pypy_version_info.releaselevel # noqa: ignore=E1101 pylint: disable=E1101
5048
if rel != "final":
5149
implementation_version = "".join([implementation_version, rel])
5250
elif implementation == "Jython":

mysql_to_sqlite3/sqlite_utils.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import six
1111
from pytimeparse.timeparse import timeparse
1212

13+
1314
if version_info.major == 3 and 4 <= version_info.minor <= 6:
1415
from backports.datetime_fromisoformat import MonkeyPatch # pylint: disable=E0401
1516

@@ -60,12 +61,8 @@ def convert_date(value):
6061
try:
6162
return date.fromisoformat(value.decode())
6263
except ValueError as err:
63-
raise ValueError( # pylint: disable=W0707
64-
"DATE field contains {}".format(err)
65-
)
64+
raise ValueError("DATE field contains {}".format(err)) # pylint: disable=W0707
6665
try:
6766
return datetime.strptime(value.decode(), "%Y-%m-%d").date()
6867
except ValueError as err:
69-
raise ValueError( # pylint: disable=W0707
70-
"DATE field contains Invalid isoformat string: {}".format(err)
71-
)
68+
raise ValueError("DATE field contains Invalid isoformat string: {}".format(err)) # pylint: disable=W0707

0 commit comments

Comments
 (0)