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

Try using redis tls config as recommended #314

Merged
merged 15 commits into from
Sep 8, 2023
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
8 changes: 4 additions & 4 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ flake8-docstrings = "==1.6.0"
flake8-isort = "==4.1.1"
ipython = "==8.10.0"
isort = "==5.10.1"
mypy = "*"
mypy = "1.4.1"
pytest = "==7.2.1"
pytest-asyncio = "==0.20.3"
pytest-celery = "==0.0.0"
pytest-django = "==4.5.2"
pyright = "*"
pyright = "==1.1.318"
django-types = "*"
pytest-xdist = {extras = ["psutil"], version = "*"}
types-tqdm = "*"
Expand Down Expand Up @@ -47,8 +47,8 @@ psycopg2 = "==2.9.3"
python-dotenv = "==0.20.0"
redis = "==4.5.4"
rules = "==3.3"
strawberry-graphql = "==0.119.0"
strawberry-graphql-django = "==0.4.0"
strawberry-graphql = "~=0.205.0"
strawberry-graphql-django = "~=0.16.1"
stripe = "==3.5.0"
tqdm = "==4.64.0"
uvicorn = "==0.17.6"
Expand Down
186 changes: 82 additions & 104 deletions Pipfile.lock

Large diffs are not rendered by default.

49 changes: 0 additions & 49 deletions projectify/redis_helper.py

This file was deleted.

25 changes: 8 additions & 17 deletions projectify/settings/production.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
"""Production settings."""
import os
import ssl

from .. import (
redis_helper,
)

# flake8: noqa: F401, F403
from .base import *
Expand Down Expand Up @@ -75,22 +70,18 @@
STRIPE_PRICE_OBJECT = os.environ["STRIPE_PRICE_OBJECT"]
STRIPE_ENDPOINT_SECRET = os.environ["STRIPE_ENDPOINT_SECRET"]

# REDIS
# https://devcenter.heroku.com/articles/connecting-heroku-redis#connecting-in-python
# Obviously, this isn't great
# https://github.com/django/channels_redis/issues/235
# https://github.com/django/channels_redis/pull/337
redis_url = redis_helper.decode_redis_url(
os.environ["REDIS_TLS_URL"],
)

# Django Channels configuration
# channels_redis
# From:
# https://github.com/django/channels_redis/blob/1e9b7387814f3c1dae5cab5034624e283f88b4bf/README.rst?plain=1#L76
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [
redis_helper.make_channels_redis_host(redis_url),
],
"hosts": {
"address": REDIS_TLS_URL,
"ssl_cert_reqs": None,
},
"symmetric_encryption_keys": [SECRET_KEY],
},
},
Expand Down
28 changes: 0 additions & 28 deletions projectify/settings/test_redis.py

This file was deleted.

4 changes: 3 additions & 1 deletion projectify/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class RequestContext:
META: dict[str, str]


class GraphQLView(views.GraphQLView):
# projectify/views.py:35: error: Missing type parameters for generic type "GraphQLView" [type-arg]
# Why? XXX Justus 2023-09-08
class GraphQLView(views.GraphQLView): # type: ignore
"""Default GraphQLView override."""

def get_context(
Expand Down
31 changes: 1 addition & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,7 @@ known_first_party = ["user"]
mypy_path = [
"mypy/stubs",
]
# https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options
# Start off with these - done!
warn_unused_configs = true
warn_redundant_casts = true
warn_unused_ignores = true

# Getting these passing should be easy - done!
strict_equality = true
strict_concatenate = true

# Strongly recommend enabling this one as soon as you can - done!
check_untyped_defs = true

# These shouldn't be too much additional work, but may be tricky to
# get passing if you use a lot of untyped libraries - done, sort of!
disallow_untyped_decorators = true
disallow_subclassing_any = true
disallow_any_generics = true

# These next few are various gradations of forcing use of type annotations
# done!
disallow_untyped_calls = true
disallow_incomplete_defs = true
disallow_untyped_defs = true

# This one isn't too hard to get passing, but return on investment is lower
no_implicit_reexport = true

# This one can be tricky to get passing if you use a lot of untyped libraries
warn_return_any = true
strict = true

# Library imports
[[tool.mypy.overrides]]
Expand Down
4 changes: 3 additions & 1 deletion workspace/schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def user_invitations(self) -> list["UserInvitation"]:
invites = []
qs = self.workspaceuserinvite_set.filter_by_redeemed(False)
for invite in qs.iterator():
i = UserInvitation(email=invite.user_invite.email) # type:ignore
# workspace/schema/types.py:58: error: Unexpected keyword argument "email" for "UserInvitation" [call-arg]
# Why??? XXX Justus 2023-09-08
i = UserInvitation(email=invite.user_invite.email)
invites.append(i)
return invites

Expand Down