Skip to content

Commit 3cf251f

Browse files
committed
🎨 update: code format
1 parent eb3ca5e commit 3cf251f

File tree

7 files changed

+32
-34
lines changed

7 files changed

+32
-34
lines changed

Diff for: docs/advanced/migrations.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Then go to `migrations\script.py.mako` to add sqlmodel module.
9292
```Python hl_lines="5-5"
9393
# Code above omitted 👆
9494

95-
{!./docs_src/advanced/migrations/tutorial003.py[ln:8-10]!}
95+
{!./docs_src/advanced/migrations/tutorial003.mako[ln:8-10]!}
9696

9797
# Code below omitted 👇
9898
```
@@ -104,7 +104,7 @@ Then go to `migrations\script.py.mako` to add sqlmodel module.
104104
<summary>👀 Full script.py.mako example</summary>
105105

106106
```Python
107-
{!./docs_src/advanced/migrations/tutorial003.py!}
107+
{!./docs_src/advanced/migrations/tutorial003.mako!}
108108
```
109109

110110
</details>

Diff for: docs_src/advanced/migrations/main.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Hero(SQLModel, table=True):
1515

1616
engine = create_engine(sqlite_url, echo=True)
1717

18+
1819
def create_heroes():
1920
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
2021
hero_2 = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")

Diff for: docs_src/advanced/migrations/tutorial004.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from logging.config import fileConfig
1+
from logging.config import fileConfig # isort:skip
22

3-
from main import Hero
4-
from sqlmodel import SQLModel
3+
from main import Hero # isort:skip
4+
from sqlmodel import SQLModel # isort:skip
55

6-
from sqlalchemy import engine_from_config
7-
from sqlalchemy import pool
6+
from sqlalchemy import engine_from_config # isort:skip
7+
from sqlalchemy import pool # isort:skip
88

9-
from alembic import context
9+
from alembic import context # isort:skip
1010

1111
# this is the Alembic Config object, which provides
1212
# access to the values within the .ini file in use.
@@ -32,15 +32,12 @@
3232

3333
def run_migrations_offline() -> None:
3434
"""Run migrations in 'offline' mode.
35-
3635
This configures the context with just a URL
3736
and not an Engine, though an Engine is acceptable
3837
here as well. By skipping the Engine creation
3938
we don't even need a DBAPI to be available.
40-
4139
Calls to context.execute() here emit the given string to the
4240
script output.
43-
4441
"""
4542
url = config.get_main_option("sqlalchemy.url")
4643
context.configure(
@@ -56,10 +53,8 @@ def run_migrations_offline() -> None:
5653

5754
def run_migrations_online() -> None:
5855
"""Run migrations in 'online' mode.
59-
6056
In this scenario we need to create an Engine
6157
and associate a connection with the context.
62-
6358
"""
6459
connectable = engine_from_config(
6560
config.get_section(config.config_ini_section),
@@ -68,9 +63,7 @@ def run_migrations_online() -> None:
6863
)
6964

7065
with connectable.connect() as connection:
71-
context.configure(
72-
connection=connection, target_metadata=target_metadata
73-
)
66+
context.configure(connection=connection, target_metadata=target_metadata)
7467

7568
with context.begin_transaction():
7669
context.run_migrations()

Diff for: docs_src/advanced/migrations/tutorial005.py

+14-11
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,34 @@
55
Create Date:
66
77
"""
8-
from alembic import op
9-
import sqlalchemy as sa
10-
import sqlmodel # (1)
8+
from alembic import op # isort:skip
9+
import sqlalchemy as sa # isort:skip
10+
import sqlmodel # (1), # isort:skip
1111

1212

1313
# revision identifiers, used by Alembic.
14-
revision = '34abfb7ac266'
14+
revision = "34abfb7ac266"
1515
down_revision = None
1616
branch_labels = None
1717
depends_on = None
1818

1919

2020
def upgrade() -> None: # (2)
2121
# ### commands auto generated by Alembic - please adjust! ###
22-
op.create_table('hero', # (3)
23-
sa.Column('id', sa.Integer(), nullable=False), # (4)
24-
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False), # (5)
25-
sa.Column('secret_name', sqlmodel.sql.sqltypes.AutoString(), nullable=False), # (6)
26-
sa.Column('age', sa.Integer(), nullable=True), # (7)
27-
sa.PrimaryKeyConstraint('id') # (8)
22+
op.create_table(
23+
"hero", # (3)
24+
sa.Column("id", sa.Integer(), nullable=False), # (4)
25+
sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False), # (5)
26+
sa.Column(
27+
"secret_name", sqlmodel.sql.sqltypes.AutoString(), nullable=False
28+
), # (6)
29+
sa.Column("age", sa.Integer(), nullable=True), # (7)
30+
sa.PrimaryKeyConstraint("id"), # (8)
2831
)
2932
# ### end Alembic commands ###
3033

3134

3235
def downgrade() -> None: # (9)
3336
# ### commands auto generated by Alembic - please adjust! ###
34-
op.drop_table('hero') # (10)
37+
op.drop_table("hero") # (10)
3538
# ### end Alembic commands ###

Diff for: docs_src/advanced/migrations/tutorial006.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Hero(SQLModel, table=True):
1616

1717
engine = create_engine(sqlite_url, echo=True)
1818

19+
1920
def create_heroes():
2021
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
2122
hero_2 = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")

Diff for: docs_src/advanced/migrations/tutorial007.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55
Create Date:
66
77
"""
8-
from alembic import op
9-
import sqlalchemy as sa
10-
import sqlmodel
8+
from alembic import op # isort:skip
9+
import sqlalchemy as sa # isort:skip
10+
import sqlmodel # isort:skip
1111

1212

1313
# revision identifiers, used by Alembic.
14-
revision = 'b39b8d3c77f0' # (1)
15-
down_revision = '357d6ebcfadf' # (2)
14+
revision = "b39b8d3c77f0" # (1)
15+
down_revision = "357d6ebcfadf" # (2)
1616
branch_labels = None
1717
depends_on = None
1818

1919

2020
def upgrade() -> None:
2121
# ### commands auto generated by Alembic - please adjust! ###
22-
op.add_column('hero', sa.Column('power', sa.Integer(), nullable=True)) # (3)
22+
op.add_column("hero", sa.Column("power", sa.Integer(), nullable=True)) # (3)
2323
# ### end Alembic commands ###
2424

2525

2626
def downgrade() -> None:
2727
# ### commands auto generated by Alembic - please adjust! ###
28-
op.drop_column('hero', 'power') # (4)
28+
op.drop_column("hero", "power") # (4)
2929
# ### end Alembic commands ###

0 commit comments

Comments
 (0)