Skip to content

Commit 3051e93

Browse files
committed
Switched to Black for code formatting
1 parent a3f70f1 commit 3051e93

File tree

8 files changed

+1529
-882
lines changed

8 files changed

+1529
-882
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ repos:
2121
- id: pyupgrade
2222
args: [ "--py37-plus" ]
2323

24-
- repo: https://github.com/pre-commit/mirrors-autopep8
25-
rev: v1.6.0
24+
- repo: https://github.com/psf/black
25+
rev: 22.3.0
2626
hooks:
27-
- id: autopep8
27+
- id: black
2828

2929
- repo: https://github.com/pycqa/isort
3030
rev: 5.10.1

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ local_scheme = "dirty-tag"
6262
[tool.isort]
6363
src_paths = ["src"]
6464
skip_gitignore = true
65-
line_length = 99
66-
multi_line_output = 4
65+
profile = "black"
6766

6867
[tool.flake8]
6968
max-line-length = 99

src/sqlacodegen/cli.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,46 @@
1414

1515

1616
def main() -> None:
17-
generators = {ep.name: ep for ep in entry_points(group='sqlacodegen.generators')}
17+
generators = {ep.name: ep for ep in entry_points(group="sqlacodegen.generators")}
1818
parser = argparse.ArgumentParser(
19-
description='Generates SQLAlchemy model code from an existing database.')
20-
parser.add_argument('url', nargs='?', help='SQLAlchemy url to the database')
21-
parser.add_argument('--option', nargs='*', help="options passed to the generator class")
22-
parser.add_argument('--version', action='store_true', help="print the version number and exit")
23-
parser.add_argument('--schemas', help='load tables from the given schemas (comma separated)')
24-
parser.add_argument('--generator', choices=generators, default='declarative',
25-
help="generator class to use")
26-
parser.add_argument('--tables', help='tables to process (comma-separated, default: all)')
27-
parser.add_argument('--noviews', action='store_true', help="ignore views")
28-
parser.add_argument('--outfile', help='file to write output to (default: stdout)')
19+
description="Generates SQLAlchemy model code from an existing database."
20+
)
21+
parser.add_argument("url", nargs="?", help="SQLAlchemy url to the database")
22+
parser.add_argument(
23+
"--option", nargs="*", help="options passed to the generator class"
24+
)
25+
parser.add_argument(
26+
"--version", action="store_true", help="print the version number and exit"
27+
)
28+
parser.add_argument(
29+
"--schemas", help="load tables from the given schemas (comma separated)"
30+
)
31+
parser.add_argument(
32+
"--generator",
33+
choices=generators,
34+
default="declarative",
35+
help="generator class to use",
36+
)
37+
parser.add_argument(
38+
"--tables", help="tables to process (comma-separated, default: all)"
39+
)
40+
parser.add_argument("--noviews", action="store_true", help="ignore views")
41+
parser.add_argument("--outfile", help="file to write output to (default: stdout)")
2942
args = parser.parse_args()
3043

3144
if args.version:
32-
print(version('sqlacodegen'))
45+
print(version("sqlacodegen"))
3346
return
3447
if not args.url:
35-
print('You must supply a url\n', file=sys.stderr)
48+
print("You must supply a url\n", file=sys.stderr)
3649
parser.print_help()
3750
return
3851

3952
# Use reflection to fill in the metadata
4053
engine = create_engine(args.url)
4154
metadata = MetaData()
42-
tables = args.tables.split(',') if args.tables else None
43-
schemas = args.schemas.split(',') if args.schemas else [None]
55+
tables = args.tables.split(",") if args.tables else None
56+
schemas = args.schemas.split(",") if args.schemas else [None]
4457
for schema in schemas:
4558
metadata.reflect(engine, schema, not args.noviews, tables)
4659

@@ -51,7 +64,7 @@ def main() -> None:
5164
# Open the target file (if given)
5265
with ExitStack() as stack:
5366
if args.outfile:
54-
outfile = open(args.outfile, 'w', encoding='utf-8')
67+
outfile = open(args.outfile, "w", encoding="utf-8")
5568
stack.enter_context(outfile)
5669
else:
5770
outfile = sys.stdout

0 commit comments

Comments
 (0)