diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 5e975a4..7baeb64 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -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: diff --git a/backend/deps.py b/backend/deps.py index a57219f..85eca8f 100644 --- a/backend/deps.py +++ b/backend/deps.py @@ -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)):