Skip to content
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

fix: set if-else to prevent multiple yields #203

Merged
merged 2 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Ruff check
run: poetry run ruff check backend/ tests/
- name: Pyupgrade
run: poetry run pyupgrade backend/ tests/
run: poetry run pyupgrade --py311-plus **/*.py
test:
runs-on: ubuntu-latest
strategy:
Expand Down
12 changes: 6 additions & 6 deletions backend/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ def _get_optional_redis(
) -> typing.Generator[Redis | None, None, None]:
if redis_url is None:
yield None

redis: Redis = Redis.from_url(redis_url) # type: ignore
try:
yield redis
finally:
redis.close()
else:
redis: Redis = Redis.from_url(redis_url) # type: ignore
try:
yield redis
finally:
redis.close()


def get_optional_redis(redis_url: str | None = cast_optional_str(settings.REDIS_URL)):
Expand Down