Skip to content

Commit

Permalink
Merge pull request #203 from ninoseki/fix-deps-error
Browse files Browse the repository at this point in the history
fix: set if-else to prevent multiple yields
  • Loading branch information
ninoseki authored Feb 3, 2024
2 parents 1477c33 + c662c59 commit 8fd0ae2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit 8fd0ae2

Please sign in to comment.