Skip to content

Commit 7e0d19b

Browse files
Bump black from 25.11.0 to 26.3.0 (#611)
* Bump black from 25.11.0 to 26.3.0 Bumps [black](https://github.com/psf/black) from 25.11.0 to 26.3.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](psf/black@25.11.0...26.3.0) --- updated-dependencies: - dependency-name: black dependency-version: 26.3.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Run "make format " poetry run black . reformatted /Users/macbre/git/sql-metadata/test/test_create_table.py reformatted /Users/macbre/git/sql-metadata/test/test_mssql_server.py reformatted /Users/macbre/git/sql-metadata/test/test_multiple_subqueries.py reformatted /Users/macbre/git/sql-metadata/test/test_with_statements.py reformatted /Users/macbre/git/sql-metadata/test/test_getting_tables.py reformatted /Users/macbre/git/sql-metadata/test/test_getting_columns.py reformatted /Users/macbre/git/sql-metadata/sql_metadata/parser.py All done! ✨ 🍰 ✨ 7 files reformatted, 27 files left unchanged. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: macbre <maciej.brencz@gmail.com>
1 parent 3bc4bf5 commit 7e0d19b

File tree

9 files changed

+128
-135
lines changed

9 files changed

+128
-135
lines changed

poetry.lock

Lines changed: 86 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ python = "^3.10"
1717
sqlparse = ">=0.4.1,<0.6.0"
1818

1919
[tool.poetry.dev-dependencies]
20-
black = "^25.11"
20+
black = "^26.3"
2121
coverage = {extras = ["toml"], version = "^7.13"}
2222
pylint = "^3.3.9"
2323
pytest = "^9.0.2"

sql_metadata/parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""
33
This module provides SQL query parsing functions
44
"""
5+
56
import logging
67
import re
78
from typing import Dict, List, Optional, Set, Tuple, Union

test/test_create_table.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,25 @@ def test_is_create_table_query():
1919

2020

2121
def test_create_table():
22-
parser = Parser(
23-
"""
22+
parser = Parser("""
2423
CREATE TABLE `new_table` (
2524
`item_id` int(9) NOT NULL AUTO_INCREMENT,
2625
`foo` varchar(16) NOT NULL DEFAULT '',
2726
PRIMARY KEY (`item_id`,`foo`),
2827
KEY `idx_foo` (`foo`)
2928
) CHARACTER SET utf8;
30-
"""
31-
)
29+
""")
3230
assert parser.query_type == QueryType.CREATE
3331
assert parser.tables == ["new_table"]
3432
assert parser.columns == ["item_id", "foo"]
3533

3634

3735
def test_simple_create_table_as_select():
38-
parser = Parser(
39-
"""
36+
parser = Parser("""
4037
CREATE table abc.foo
4138
as SELECT pqr.foo1 , ab.foo2
4239
FROM foo pqr, bar ab;
43-
"""
44-
)
40+
""")
4541
assert parser.query_type == QueryType.CREATE
4642
assert parser.tables == ["abc.foo", "foo", "bar"]
4743
assert parser.columns == ["foo.foo1", "bar.foo2"]
@@ -168,11 +164,9 @@ def test_create_if_not_exists_simple_name():
168164

169165
def test_create_temporary_table():
170166
# https://dev.mysql.com/doc/refman/8.4/en/create-temporary-table.html
171-
parser = Parser(
172-
"""
167+
parser = Parser("""
173168
CREATE TEMPORARY TABLE new_tbl SELECT * FROM orig_tbl LIMIT 0;;
174-
"""
175-
)
169+
""")
176170
assert parser.query_type == QueryType.CREATE
177171
assert parser.tables == ["new_tbl", "orig_tbl"]
178172
assert parser.columns == ["*"]

test/test_getting_columns.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,10 @@ def test_getting_columns():
9292
"test",
9393
]
9494
assert Parser("SELECT /* a comment */ bar FROM test_table").columns == ["bar"]
95-
assert (
96-
Parser(
97-
"""
95+
assert Parser("""
9896
WITH foo AS (SELECT test_table.* FROM test_table)
9997
SELECT foo.bar FROM foo
100-
"""
101-
).columns
102-
== ["test_table.*", "bar"]
103-
)
98+
""").columns == ["test_table.*", "bar"]
10499

105100

106101
def test_columns_with_order_by():
@@ -273,11 +268,9 @@ def test_columns_with_comments():
273268
"order_by": ["cl_sortkey"],
274269
}
275270

276-
parser = Parser(
277-
"""WITH aa AS --sdfsdfsdf
271+
parser = Parser("""WITH aa AS --sdfsdfsdf
278272
(SELECT C1, C2 FROM T1)
279-
SELECT C1, C2 FROM aa"""
280-
)
273+
SELECT C1, C2 FROM aa""")
281274
assert parser.columns == ["C1", "C2"]
282275
assert parser.columns_dict == {"select": ["C1", "C2"]}
283276

test/test_getting_tables.py

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,9 @@ def test_complex_query_tables():
100100

101101
# test whitespaces in keywords
102102
# @see https://github.com/macbre/sql-metadata/issues/80
103-
assert (
104-
["tab", "tab2"]
105-
== Parser(
106-
"""SELECT a,b,c from tab
103+
assert ["tab", "tab2"] == Parser("""SELECT a,b,c from tab
107104
full outer \r\n\t join tab2 on (col1 = col2) group
108-
\r\n \t by a, b, c """
109-
).tables
110-
)
105+
\r\n \t by a, b, c """).tables
111106

112107

113108
def test_joins():
@@ -291,16 +286,11 @@ def test_table_name_with_group_by():
291286
== expected_tables
292287
)
293288

294-
assert (
295-
Parser(
296-
"""
289+
assert Parser("""
297290
SELECT s.cust_id,count(s.cust_id) FROM SH.sales s
298291
GROUP BY s.cust_id HAVING s.cust_id != '1660'
299292
AND s.cust_id != '2'
300-
""".strip()
301-
).tables
302-
== expected_tables
303-
)
293+
""".strip()).tables == expected_tables
304294

305295

306296
def test_datasets():
@@ -344,31 +334,21 @@ def test_unions():
344334

345335

346336
def test_with_brackets():
347-
assert (
348-
["database1.table1", "database2.table2"]
349-
== Parser(
350-
"""
337+
assert ["database1.table1", "database2.table2"] == Parser("""
351338
SELECT
352339
"xxxxx"
353340
FROM
354341
(database1.table1 alias
355342
LEFT JOIN database2.table2 ON ("tt"."ttt"."fff" = "xx"."xxx"))
356-
"""
357-
).tables
358-
)
343+
""").tables
359344

360-
assert (
361-
["inner_table"]
362-
== Parser(
363-
"""
345+
assert ["inner_table"] == Parser("""
364346
SELECT
365347
t.foo
366348
FROM
367349
(SELECT foo FROM inner_table
368350
WHERE bar = '1') t
369-
"""
370-
).tables
371-
)
351+
""").tables
372352

373353

374354
def test_db2_query():
@@ -725,16 +705,14 @@ def test_join_followed_by_tables():
725705
parser = Parser(query)
726706
assert parser.tables == ["web_sales", "web_returns", "date_dim", "web_site"]
727707

728-
parser = Parser(
729-
"""
708+
parser = Parser("""
730709
SELECT *
731710
FROM Sales
732711
JOIN Customers
733712
ON Sales.CustomerID = Customers.CustomerID,
734713
(SELECT MAX(Revenue) FROM Sales),
735714
Stores
736-
"""
737-
)
715+
""")
738716
assert parser.tables == ["Sales", "Customers", "Stores"]
739717

740718

test/test_mssql_server.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,53 +39,45 @@ def test_sql_server_cte():
3939
@see https://www.sqlservertutorial.net/sql-server-basics/sql-server-cte/
4040
"""
4141

42-
parser = Parser(
43-
"""
42+
parser = Parser("""
4443
WITH x AS (
4544
SELECT * FROM n
4645
)
4746
SELECT
4847
*
4948
FROM x
5049
JOIN y ON x.a = y.a
51-
"""
52-
)
50+
""")
5351
assert parser.tables == ["n", "y"]
5452
assert parser.with_names == ["x"]
5553
assert parser.with_queries == {"x": "SELECT * FROM n"}
5654
assert parser.columns == ["*", "a", "y.a"]
5755

58-
parser = Parser(
59-
"""
56+
parser = Parser("""
6057
WITH x AS (
6158
SELECT * FROM n
6259
)
6360
SELECT
6461
*
6562
FROM x
6663
JOIN y ON x.a = y.a
67-
"""
68-
)
64+
""")
6965
assert parser.tables == ["n", "y"]
7066

71-
parser = Parser(
72-
"""
67+
parser = Parser("""
7368
WITH foo AS (
7469
SELECT * FROM n
7570
)
7671
UPDATE z from foo set z.q = foo.y
77-
"""
78-
)
72+
""")
7973
assert parser.tables == ["n", "z"]
8074

81-
parser = Parser(
82-
"""
75+
parser = Parser("""
8376
WITH foo AS (
8477
SELECT * FROM tab
8578
)
8679
DELETE FROM z JOIN foo ON z.a = foo.a
87-
"""
88-
)
80+
""")
8981
assert parser.tables == ["tab", "z"]
9082

9183

@@ -133,8 +125,7 @@ def test_sql_server_cte_sales_by_year():
133125

134126
def test_partition_over_with_rank_and_one_order():
135127
"""Test for #204"""
136-
parser = Parser(
137-
"""
128+
parser = Parser("""
138129
select t.RANKED, t.RANKED_two, t.test from (
139130
SELECT
140131
RANK() OVER (PARTITION BY col_one ORDER BY col_two) RANKED,
@@ -144,8 +135,7 @@ def test_partition_over_with_rank_and_one_order():
144135
where t.RANKED = 1
145136
and t.RANKED_two = 2
146137
order by test
147-
"""
148-
)
138+
""")
149139
assert parser.tables == ["nice_table"]
150140
assert parser.columns_aliases_names == ["RANKED", "RANKED_two", "test"]
151141
assert parser.columns_aliases == {
@@ -163,8 +153,7 @@ def test_partition_over_with_rank_and_one_order():
163153

164154
def test_partition_over_with_row_number_and_many_orders():
165155
"""Test for #204"""
166-
parser = Parser(
167-
"""
156+
parser = Parser("""
168157
select t.row_no, t.row_no_two, t.test from (
169158
SELECT
170159
ROW_NUMBER() OVER (
@@ -178,8 +167,7 @@ def test_partition_over_with_row_number_and_many_orders():
178167
where t.row_no = 1
179168
and t.row_no_two = 2
180169
order by t.row_no
181-
"""
182-
)
170+
""")
183171
assert parser.tables == ["nice_table"]
184172
assert parser.columns_aliases_names == ["row_no", "row_no_two", "test"]
185173
assert parser.columns_aliases == {

test/test_multiple_subqueries.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,12 @@ def test_resolving_columns_in_sub_queries_functions():
410410

411411

412412
def test_readme_query():
413-
parser = Parser(
414-
"""
413+
parser = Parser("""
415414
SELECT COUNT(1) FROM
416415
(SELECT std.task_id FROM some_task_detail std WHERE std.STATUS = 1) a
417416
JOIN (SELECT st.task_id FROM some_task st WHERE task_type_id = 80) b
418417
ON a.task_id = b.task_id;
419-
"""
420-
)
418+
""")
421419
assert parser.subqueries == {
422420
"a": "SELECT std.task_id FROM some_task_detail std WHERE std.STATUS = 1",
423421
"b": "SELECT st.task_id FROM some_task st WHERE task_type_id = 80",

test/test_with_statements.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66

77
def test_with_statements():
8-
parser = Parser(
9-
"""
8+
parser = Parser("""
109
WITH
1110
database1.tableFromWith AS (SELECT aa.* FROM table3 as aa
1211
left join table4 on aa.col1=table4.col2),
@@ -16,17 +15,15 @@ def test_with_statements():
1615
FROM
1716
database1.tableFromWith alias
1817
LEFT JOIN database2.table2 ON ("tt"."ttt"."fff" = "xx"."xxx")
19-
"""
20-
)
18+
""")
2119
assert parser.tables == ["table3", "table4", "database2.table2"]
2220
assert parser.with_names == ["database1.tableFromWith", "test"]
2321
assert parser.with_queries == {
2422
"database1.tableFromWith": "SELECT aa.* FROM table3 as aa left join table4 on "
2523
"aa.col1 = table4.col2",
2624
"test": "SELECT * from table3",
2725
}
28-
parser = Parser(
29-
"""
26+
parser = Parser("""
3027
WITH
3128
database1.tableFromWith AS (SELECT * FROM table3),
3229
database1.tableFromWith2 AS (SELECT * FROM table4),
@@ -37,8 +34,7 @@ def test_with_statements():
3734
FROM
3835
database1.tableFromWith alias
3936
LEFT JOIN database2.table2 ON ("tt"."ttt"."fff" = "xx"."xxx")
40-
"""
41-
)
37+
""")
4238

4339
assert parser.with_names == [
4440
"database1.tableFromWith",
@@ -54,15 +50,13 @@ def test_with_statements():
5450
}
5551
assert parser.tables == ["table3", "table4", "table5", "table6", "database2.table2"]
5652

57-
parser = Parser(
58-
"""
53+
parser = Parser("""
5954
WITH
6055
cte1 AS (SELECT a, b FROM table1),
6156
cte2 AS (SELECT c, d FROM table2)
6257
SELECT cte1.b, d FROM cte1 JOIN cte2
6358
WHERE cte1.a = cte2.c;
64-
"""
65-
)
59+
""")
6660

6761
assert parser.with_names == ["cte1", "cte2"]
6862
assert parser.with_queries == {

0 commit comments

Comments
 (0)