Skip to content

Commit e257060

Browse files
euri10cofin
authored andcommitted
lint
1 parent 97b169c commit e257060

32 files changed

+214
-176
lines changed

docs/examples/usage/usage_query_builder_1.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from pathlib import Path
22

3+
__all__ = ("test_example_1", )
4+
35

46
def test_example_1(tmp_path: Path) -> None:
57
from sqlspec import SQLSpec, sql
@@ -25,5 +27,5 @@ def test_example_1(tmp_path: Path) -> None:
2527
sql.select("id", "name", "email").from_("users").where("status = ?").order_by("created_at DESC").limit(10)
2628
)
2729
# Execute with session
28-
result = session.execute(query, "active")
30+
session.execute(query, "active")
2931
# end-example

docs/examples/usage/usage_query_builder_10.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from pathlib import Path
22

3+
__all__ = ("test_example_10", )
4+
35

46
def test_example_10(tmp_path: Path) -> None:
57
from sqlspec import SQLSpec, sql

docs/examples/usage/usage_query_builder_11.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from pathlib import Path
22

3+
__all__ = ("test_example_11", )
4+
5+
36
def test_example_11(tmp_path: Path) -> None:
47
from sqlspec import SQLSpec, sql
58
from sqlspec.adapters.sqlite.config import SqliteConfig
@@ -16,16 +19,12 @@ def test_example_11(tmp_path: Path) -> None:
1619
}
1720
)
1821
with db.provide_session(config) as session:
19-
session.execute("""CREATE TABLE if not exists users(id integer primary key autoincrement, name text, email text, created_at timestamp)""")
22+
session.execute(
23+
"""CREATE TABLE if not exists users(id integer primary key autoincrement, name text, email text, created_at timestamp)"""
24+
)
2025
# start-example
2126
# PostgreSQL RETURNING clause
22-
query = (
23-
sql.insert("users")
24-
.columns("name", "email")
25-
.values("?", "?")
26-
.returning("id", "created_at")
27-
)
27+
(sql.insert("users").columns("name", "email").values("?", "?").returning("id", "created_at"))
2828

2929
# SQLite does not support RETURNING, so we skip execution for this example.
3030
# end-example
31-

docs/examples/usage/usage_query_builder_12.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from pathlib import Path
22

3+
__all__ = ("test_example_12", )
4+
5+
36
def test_example_12(tmp_path: Path) -> None:
47
from sqlspec import SQLSpec, sql
58
from sqlspec.adapters.sqlite.config import SqliteConfig
@@ -16,17 +19,14 @@ def test_example_12(tmp_path: Path) -> None:
1619
}
1720
)
1821
with db.provide_session(config) as session:
19-
session.execute("""CREATE TABLE if not exists users(id integer primary key autoincrement, name text, email text)""")
22+
session.execute(
23+
"""CREATE TABLE if not exists users(id integer primary key autoincrement, name text, email text)"""
24+
)
2025
# start-example
2126
# Update with WHERE
22-
query = (
23-
sql.update("users")
24-
.set("email", "?")
25-
.where("id = ?")
26-
)
27+
query = sql.update("users").set("email", "?").where("id = ?")
2728
# SQL: UPDATE users SET email = ? WHERE id = ?
2829

29-
result = session.execute(query, 1, "[email protected]")
30+
session.execute(query, 1, "[email protected]")
3031
# print(f"Updated {result.rows_affected} rows")
3132
# end-example
32-

docs/examples/usage/usage_query_builder_13.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from pathlib import Path
22

3+
__all__ = ("test_example_13", )
4+
5+
36
def test_example_13(tmp_path: Path) -> None:
47
from sqlspec import SQLSpec, sql
58
from sqlspec.adapters.sqlite.config import SqliteConfig
@@ -16,7 +19,9 @@ def test_example_13(tmp_path: Path) -> None:
1619
}
1720
)
1821
with db.provide_session(config) as session:
19-
session.execute("""CREATE TABLE if not exists users(id integer primary key autoincrement, name text, email text, updated_at timestamp)""")
22+
session.execute(
23+
"""CREATE TABLE if not exists users(id integer primary key autoincrement, name text, email text, updated_at timestamp)"""
24+
)
2025
# start-example
2126
# Update multiple columns
2227
query = (
@@ -29,4 +34,3 @@ def test_example_13(tmp_path: Path) -> None:
2934

3035
session.execute(query, 1, "New Name", "[email protected]")
3136
# end-example
32-

docs/examples/usage/usage_query_builder_14.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from pathlib import Path
22

3+
__all__ = ("test_example_14", )
4+
5+
36
def test_example_14(tmp_path: Path) -> None:
47
from sqlspec import SQLSpec, sql
58
from sqlspec.adapters.sqlite.config import SqliteConfig
@@ -16,7 +19,10 @@ def test_example_14(tmp_path: Path) -> None:
1619
}
1720
)
1821
with db.provide_session(config) as session:
19-
session.execute("""CREATE TABLE if not exists users(id integer primary key autoincrement, name text, email text, status text)""")
22+
session.execute(
23+
"""CREATE TABLE if not exists users(id integer primary key autoincrement, name text, email text, status text)"""
24+
)
25+
2026
# start-example
2127
# Dynamic update builder
2228
def update_user(user_id, **fields):
@@ -36,4 +42,3 @@ def update_user(user_id, **fields):
3642
# Usage
3743
update_user(1, name="Alice", email="[email protected]", status="active")
3844
# end-example
39-

docs/examples/usage/usage_query_builder_15.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from pathlib import Path
22

3+
__all__ = ("test_example_15", )
4+
5+
36
def test_example_15(tmp_path: Path) -> None:
47
from sqlspec import SQLSpec, sql
58
from sqlspec.adapters.sqlite.config import SqliteConfig
@@ -16,13 +19,14 @@ def test_example_15(tmp_path: Path) -> None:
1619
}
1720
)
1821
with db.provide_session(config) as session:
19-
session.execute("""CREATE TABLE if not exists users(id integer primary key autoincrement, name text, email text)""")
22+
session.execute(
23+
"""CREATE TABLE if not exists users(id integer primary key autoincrement, name text, email text)"""
24+
)
2025
# start-example
2126
# Delete with WHERE
2227
query = sql.delete().from_("users").where("id = ?")
2328
# SQL: DELETE FROM users WHERE id = ?
2429

25-
result = session.execute(query, 1)
30+
session.execute(query, 1)
2631
# print(f"Deleted {result.rows_affected} rows")
2732
# end-example
28-

docs/examples/usage/usage_query_builder_16.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
from pathlib import Path
21
import datetime
2+
from pathlib import Path
3+
4+
__all__ = ("test_example_16", )
5+
36

47
def test_example_16(tmp_path: Path) -> None:
58
from sqlspec import SQLSpec, sql
@@ -17,15 +20,12 @@ def test_example_16(tmp_path: Path) -> None:
1720
}
1821
)
1922
with db.provide_session(config) as session:
20-
session.execute("""CREATE TABLE if not exists users(id integer primary key autoincrement, status text, last_login date)""")
23+
session.execute(
24+
"""CREATE TABLE if not exists users(id integer primary key autoincrement, status text, last_login date)"""
25+
)
2126
# start-example
2227
# Delete with multiple conditions
23-
query = (
24-
sql.delete().from_("users")
25-
.where("status = ?")
26-
.where("last_login < ?")
27-
)
28+
query = sql.delete().from_("users").where("status = ?").where("last_login < ?")
2829

2930
session.execute(query, "inactive", datetime.date(2024, 1, 1))
3031
# end-example
31-

docs/examples/usage/usage_query_builder_17.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from pathlib import Path
22

3+
__all__ = ("test_example_17", )
4+
5+
36
def test_example_17(tmp_path: Path) -> None:
47
from sqlspec import SQLSpec, sql
58
from sqlspec.adapters.sqlite.config import SqliteConfig
@@ -28,4 +31,3 @@ def test_example_17(tmp_path: Path) -> None:
2831

2932
session.execute(query)
3033
# end-example
31-

docs/examples/usage/usage_query_builder_18.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from pathlib import Path
22

3+
__all__ = ("test_example_18", )
4+
5+
36
def test_example_18(tmp_path: Path) -> None:
47
from sqlspec import SQLSpec, sql
58
from sqlspec.adapters.sqlite.config import SqliteConfig
@@ -25,4 +28,3 @@ def test_example_18(tmp_path: Path) -> None:
2528

2629
session.execute(query)
2730
# end-example
28-

0 commit comments

Comments
 (0)