Skip to content

Commit 9792b3d

Browse files
committed
Fix linting
1 parent 8d75041 commit 9792b3d

File tree

10 files changed

+15
-15
lines changed

10 files changed

+15
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ engine = create_engine(
111111
)
112112
Base.metadata.create_all(engine)
113113

114-
with Session(engine) as session:
115-
session.add(Attachment(name="attachment1", content=open("./example.txt", "rb")))
114+
with Session(engine) as session, open("./example.txt", "rb") as local_file:
115+
session.add(Attachment(name="attachment1", content=local_file))
116116
session.add(Attachment(name="attachment2", content=b"Hello world"))
117117
session.add(Attachment(name="attachment3", content="Hello world"))
118118
file = File(content="Hello World", filename="hello.txt", content_type="text/plain")

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ engine = create_engine(
110110
)
111111
Base.metadata.create_all(engine)
112112

113-
with Session(engine) as session:
114-
session.add(Attachment(name="attachment1", content=open("./example.txt", "rb")))
113+
with Session(engine) as session, open("./example.txt", "rb") as local_file:
114+
session.add(Attachment(name="attachment1", content=local_file))
115115
session.add(Attachment(name="attachment2", content=b"Hello world"))
116116
session.add(Attachment(name="attachment3", content="Hello world"))
117117
file = File(content="Hello World", filename="hello.txt", content_type="text/plain")

docs_src/example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class Attachment(Base):
3030
)
3131
Base.metadata.create_all(engine)
3232

33-
with Session(engine) as session:
34-
session.add(Attachment(name="attachment1", content=open("./example.txt", "rb")))
33+
with Session(engine) as session, open("./example.txt", "rb") as local_file:
34+
session.add(Attachment(name="attachment1", content=local_file))
3535
session.add(Attachment(name="attachment2", content=b"Hello world"))
3636
session.add(Attachment(name="attachment3", content="Hello world"))
3737
file = File(content="Hello World", filename="hello.txt", content_type="text/plain")

docs_src/tutorial/quick-start/save_your_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class Attachment(Base):
3030
)
3131
Base.metadata.create_all(engine)
3232

33-
with Session(engine) as session:
34-
session.add(Attachment(name="attachment1", content=open("./example.txt", "rb")))
33+
with Session(engine) as session, open("./example.txt", "rb") as local_file:
34+
session.add(Attachment(name="attachment1", content=local_file))
3535
session.add(Attachment(name="attachment2", content=b"Hello world"))
3636
session.add(Attachment(name="attachment3", content="Hello world"))
3737
# Use sqlalchemy_file.File object to provide custom filename and content_type

docs_src/tutorial/using-files-in-models/007_multiple_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ class Attachment(Base):
2929
)
3030
Base.metadata.create_all(engine)
3131

32-
with Session(engine) as session:
32+
with Session(engine) as session, open("./example.txt", "rb") as file:
3333
session.add(
3434
Attachment(
3535
name="attachment1",
3636
multiple_content=[
3737
"from str",
3838
b"from bytes",
39-
open("./example.txt", "rb"),
39+
file,
4040
File(
4141
content="Hello World",
4242
filename="hello.txt",

docs_src/tutorial/using-files-in-models/008_file_information.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class Attachment(Base):
3030
)
3131
Base.metadata.create_all(engine)
3232

33-
with Session(engine) as session:
34-
session.add(Attachment(name="attachment1", content=open("./example.txt", "rb")))
33+
with Session(engine) as session, open("./example.txt", "rb") as local_file:
34+
session.add(Attachment(name="attachment1", content=local_file))
3535
session.add(Attachment(name="attachment2", content=b"Hello world"))
3636
session.add(Attachment(name="attachment3", content="Hello world"))
3737
file = File(content="Hello World", filename="hello.txt", content_type="text/plain")

examples/fastapi/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async def serve_files(storage: str = Path(...), file_id: str = Path(...)):
133133
return FileResponse(
134134
file.get_cdn_url(), media_type=file.content_type, filename=file.filename
135135
)
136-
elif file.get_cdn_url() is not None:
136+
elif file.get_cdn_url() is not None: # noqa: RET505
137137
"""If file has public url, redirect to this url"""
138138
return RedirectResponse(file.get_cdn_url())
139139
else:

examples/flask/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def serve_files(storage, file_id):
8888
mimetype=file.content_type,
8989
download_name=file.filename,
9090
)
91-
elif file.get_cdn_url() is not None:
91+
elif file.get_cdn_url() is not None: # noqa: RET505
9292
"""If file has public url, redirect to this url"""
9393
return app.redirect(file.get_cdn_url())
9494
else:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ known-third-party = ["sqlalchemy_file"]
165165

166166
[tool.ruff.per-file-ignores]
167167
"__init__.py" = ["F401"]
168+
"docs_src/**" = ["N999"]
168169

169170
[tool.mypy]
170171
strict = true

sqlalchemy_file/file.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class File(BaseFile):
2424
Default attributes provided for all ``File`` include:
2525
2626
Attributes:
27-
----------
2827
filename (str): This is the name of the uploaded file
2928
file_id: This is the generated UUID for the uploaded file
3029
upload_storage: Name of the storage used to save the uploaded file

0 commit comments

Comments
 (0)