Repository navigation
Sourcery refactored main branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,8 +57,7 @@ | |
|
|
||
| short = "select 1 as a, case when 1 then 1 when 2 then 2 else 3 end as b, c from x" | ||
|
|
||
| crazy = "SELECT 1+" | ||
| crazy += "+".join(str(i) for i in range(500)) | ||
| crazy = "SELECT 1+" + "+".join(str(i) for i in range(500)) | ||
| crazy += " AS a, 2*" | ||
| crazy += "*".join(str(i) for i in range(500)) | ||
| crazy += " AS b FROM x" | ||
|
|
@@ -200,7 +199,7 @@ def diff(row, column): | |
| column = row[column] | ||
| if isinstance(column, str): | ||
| return " (N/A)" | ||
| return f" ({str(column / row['sqlglot'])[0:5]})" | ||
| return f" ({str(column / row['sqlglot'])[:5]})" | ||
|
Comment on lines
-203
to
+202
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| libs = [ | ||
|
|
@@ -219,7 +218,9 @@ def diff(row, column): | |
| table.append(row) | ||
| for lib in libs: | ||
| try: | ||
| row[lib] = np.mean(timeit.repeat(lambda: globals()[lib + "_parse"](sql), number=3)) | ||
| row[lib] = np.mean( | ||
| timeit.repeat(lambda: globals()[f"{lib}_parse"](sql), number=3) | ||
| ) | ||
|
Comment on lines
-222
to
+223
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
| except Exception as e: | ||
| print(e) | ||
| row[lib] = "error" | ||
|
|
@@ -230,11 +231,12 @@ def diff(row, column): | |
| lines = [border(column.rjust(width) for column, width in widths.items())] | ||
| lines.append(border(str("-" * width) for width in widths.values())) | ||
|
|
||
| for i, row in enumerate(table): | ||
| lines.append(border( | ||
| (str(row[column])[0:7] + diff(row, column)).rjust(width)[0 : width] | ||
| lines.extend( | ||
| border( | ||
| (str(row[column])[:7] + diff(row, column)).rjust(width)[:width] | ||
| for column, width in widths.items() | ||
| )) | ||
|
|
||
| ) | ||
| for row in table | ||
| ) | ||
| for line in lines: | ||
| print(line) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
|
|
||
| def sqlglotrs_version(): | ||
| with open("sqlglotrs/Cargo.toml") as fd: | ||
| for line in fd.readlines(): | ||
| for line in fd: | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| if line.strip().startswith("version"): | ||
| return line.split("=")[1].strip().strip('"') | ||
| raise ValueError("Could not find version in Cargo.toml") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines
60-61refactored with the following changes:merge-assign-and-aug-assign)