prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  DJStripeSubscriptionPermission issue returning bool
  This permission is not returning properly the bool.
  
  **Current behaviour**
  
  ```python
  class DJStripeSubscriptionPermission(BasePermission):
      """
      A permission to be used when wanting to permit users with active subscriptions.
      """
  
      def has_permission(self, request, view):
          """
          Check if the subscriber has an active subscription.
  
          Returns false if:
              * a subscriber isn't passed through the request
  
          See ``utils.subscriber_has_active_subscription`` for more rules.
  
          """
          try:
              subscriber_has_active_subscription(subscriber_request_callback(request))
          except AttributeError:
              return False
  ```
  
  Here is not returning True or False except if it falls in the exception.
  
  
  **Expected Behaviour**
  
  
  ```python
  class DJStripeSubscriptionPermission(BasePermission):
      """
      A permission to be used when wanting to permit users with active subscriptions.
      """
  
      def has_permission(self, request, view):
          """
          Check if the subscriber has an active subscription.
  
          Returns false if:
              * a subscriber isn't passed through the request
  
          See ``utils.subscriber_has_active_subscription`` for more rules.
  
          """
          try:
              return bool(subscriber_has_active_subscription(subscriber_request_callback(request)))
          except AttributeError:
              return False
  ```
  
  Just missing a return and it solves the problem. We don't need a bool directly there, I just added just to follow the same patterns as the DRF (also being added to the other project :-))
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `djstripe/contrib/rest_framework/serializers.py`
  Content:
  ```
  1 """
  2 .. module:: dj-stripe.contrib.rest_framework.serializers.
  3 
  4     :synopsis: dj-stripe - Serializers to be used with the dj-stripe REST API.
  5 
  6 .. moduleauthor:: Philippe Luickx (@philippeluickx)
  7 
  8 """
  9 
  10 from rest_framework import serializers
  11 from rest_framework.serializers import ModelSerializer
  12 
  13 from djstripe.models import Subscription
  14 
  15 
  16 class SubscriptionSerializer(ModelSerializer):
  17     """A serializer used for the Subscription model."""
  18 
  19     class Meta:
  20         """Model class options."""
  21 
  22         model = Subscription
  23         exclude = ["default_tax_rates"]
  24 
  25 
  26 class CreateSubscriptionSerializer(serializers.Serializer):
  27     """A serializer used to create a Subscription."""
  28 
  29     stripe_token = serializers.CharField(max_length=200)
  30     plan = serializers.CharField(max_length=50)
  31     charge_immediately = serializers.BooleanField(required=False, allow_null=True, default=None)
  32     tax_percent = serializers.DecimalField(
  33         required=False, max_digits=5, decimal_places=2
  34     )
  35
  ```
  
  Path: `djstripe/contrib/rest_framework/permissions.py`
  Content:
  ```
  1 """
  2 .. module:: dj-stripe.contrib.rest_framework.permissions.
  3 
  4     :synopsis: dj-stripe - Permissions to be used with the dj-stripe REST API.
  5 
  6 .. moduleauthor:: @kavdev, @pydanny
  7 
  8 """
  9 from rest_framework.permissions import BasePermission
  10 
  11 from ...settings import subscriber_request_callback
  12 from ...utils import subscriber_has_active_subscription
  13 
  14 
  15 class DJStripeSubscriptionPermission(BasePermission):
  16     """
  17     A permission to be used when wanting to permit users with active subscriptions.
  18     """
  19 
  20     def has_permission(self, request, view):
  21         """
  22         Check if the subscriber has an active subscription.
  23 
  24         Returns false if:
  25             * a subscriber isn't passed through the request
  26 
  27         See ``utils.subscriber_has_active_subscription`` for more rules.
  28 
  29         """
  30         try:
  31             subscriber_has_active_subscription(subscriber_request_callback(request))
  32         except AttributeError:
  33             return False
  34
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/djstripe/contrib/rest_framework/permissions.py b/djstripe/contrib/rest_framework/permissions.py
  --- a/djstripe/contrib/rest_framework/permissions.py
  +++ b/djstripe/contrib/rest_framework/permissions.py
  @@ -17,7 +17,7 @@
       A permission to be used when wanting to permit users with active subscriptions.
       """
   
  -    def has_permission(self, request, view):
  +    def has_permission(self, request, view) -> bool:
           """
           Check if the subscriber has an active subscription.
   
  @@ -28,6 +28,8 @@
   
           """
           try:
  -            subscriber_has_active_subscription(subscriber_request_callback(request))
  +            return subscriber_has_active_subscription(
  +                subscriber_request_callback(request)
  +            )
           except AttributeError:
               return False
  diff --git a/djstripe/contrib/rest_framework/serializers.py b/djstripe/contrib/rest_framework/serializers.py
  --- a/djstripe/contrib/rest_framework/serializers.py
  +++ b/djstripe/contrib/rest_framework/serializers.py
  @@ -28,7 +28,9 @@
   
       stripe_token = serializers.CharField(max_length=200)
       plan = serializers.CharField(max_length=50)
  -    charge_immediately = serializers.BooleanField(required=False, allow_null=True, default=None)
  +    charge_immediately = serializers.BooleanField(
  +        required=False, allow_null=True, default=None
  +    )
       tax_percent = serializers.DecimalField(
           required=False, max_digits=5, decimal_places=2
       )
  
verification_info: {"golden_diff": "diff --git a/djstripe/contrib/rest_framework/permissions.py b/djstripe/contrib/rest_framework/permissions.py\n--- a/djstripe/contrib/rest_framework/permissions.py\n+++ b/djstripe/contrib/rest_framework/permissions.py\n@@ -17,7 +17,7 @@\n     A permission to be used when wanting to permit users with active subscriptions.\n     \"\"\"\n \n-    def has_permission(self, request, view):\n+    def has_permission(self, request, view) -> bool:\n         \"\"\"\n         Check if the subscriber has an active subscription.\n \n@@ -28,6 +28,8 @@\n \n         \"\"\"\n         try:\n-            subscriber_has_active_subscription(subscriber_request_callback(request))\n+            return subscriber_has_active_subscription(\n+                subscriber_request_callback(request)\n+            )\n         except AttributeError:\n             return False\ndiff --git a/djstripe/contrib/rest_framework/serializers.py b/djstripe/contrib/rest_framework/serializers.py\n--- a/djstripe/contrib/rest_framework/serializers.py\n+++ b/djstripe/contrib/rest_framework/serializers.py\n@@ -28,7 +28,9 @@\n \n     stripe_token = serializers.CharField(max_length=200)\n     plan = serializers.CharField(max_length=50)\n-    charge_immediately = serializers.BooleanField(required=False, allow_null=True, default=None)\n+    charge_immediately = serializers.BooleanField(\n+        required=False, allow_null=True, default=None\n+    )\n     tax_percent = serializers.DecimalField(\n         required=False, max_digits=5, decimal_places=2\n     )\n", "issue": "DJStripeSubscriptionPermission issue returning bool\nThis permission is not returning properly the bool.\r\n\r\n**Current behaviour**\r\n\r\n```python\r\nclass DJStripeSubscriptionPermission(BasePermission):\r\n    \"\"\"\r\n    A permission to be used when wanting to permit users with active subscriptions.\r\n    \"\"\"\r\n\r\n    def has_permission(self, request, view):\r\n        \"\"\"\r\n        Check if the subscriber has an active subscription.\r\n\r\n        Returns false if:\r\n            * a subscriber isn't passed through the request\r\n\r\n        See ``utils.subscriber_has_active_subscription`` for more rules.\r\n\r\n        \"\"\"\r\n        try:\r\n            subscriber_has_active_subscription(subscriber_request_callback(request))\r\n        except AttributeError:\r\n            return False\r\n```\r\n\r\nHere is not returning True or False except if it falls in the exception.\r\n\r\n\r\n**Expected Behaviour**\r\n\r\n\r\n```python\r\nclass DJStripeSubscriptionPermission(BasePermission):\r\n    \"\"\"\r\n    A permission to be used when wanting to permit users with active subscriptions.\r\n    \"\"\"\r\n\r\n    def has_permission(self, request, view):\r\n        \"\"\"\r\n        Check if the subscriber has an active subscription.\r\n\r\n        Returns false if:\r\n            * a subscriber isn't passed through the request\r\n\r\n        See ``utils.subscriber_has_active_subscription`` for more rules.\r\n\r\n        \"\"\"\r\n        try:\r\n            return bool(subscriber_has_active_subscription(subscriber_request_callback(request)))\r\n        except AttributeError:\r\n            return False\r\n```\r\n\r\nJust missing a return and it solves the problem. We don't need a bool directly there, I just added just to follow the same patterns as the DRF (also being added to the other project :-))\n", "before_files": [{"content": "\"\"\"\n.. module:: dj-stripe.contrib.rest_framework.serializers.\n\n    :synopsis: dj-stripe - Serializers to be used with the dj-stripe REST API.\n\n.. moduleauthor:: Philippe Luickx (@philippeluickx)\n\n\"\"\"\n\nfrom rest_framework import serializers\nfrom rest_framework.serializers import ModelSerializer\n\nfrom djstripe.models import Subscription\n\n\nclass SubscriptionSerializer(ModelSerializer):\n    \"\"\"A serializer used for the Subscription model.\"\"\"\n\n    class Meta:\n        \"\"\"Model class options.\"\"\"\n\n        model = Subscription\n        exclude = [\"default_tax_rates\"]\n\n\nclass CreateSubscriptionSerializer(serializers.Serializer):\n    \"\"\"A serializer used to create a Subscription.\"\"\"\n\n    stripe_token = serializers.CharField(max_length=200)\n    plan = serializers.CharField(max_length=50)\n    charge_immediately = serializers.BooleanField(required=False, allow_null=True, default=None)\n    tax_percent = serializers.DecimalField(\n        required=False, max_digits=5, decimal_places=2\n    )\n", "path": "djstripe/contrib/rest_framework/serializers.py"}, {"content": "\"\"\"\n.. module:: dj-stripe.contrib.rest_framework.permissions.\n\n    :synopsis: dj-stripe - Permissions to be used with the dj-stripe REST API.\n\n.. moduleauthor:: @kavdev, @pydanny\n\n\"\"\"\nfrom rest_framework.permissions import BasePermission\n\nfrom ...settings import subscriber_request_callback\nfrom ...utils import subscriber_has_active_subscription\n\n\nclass DJStripeSubscriptionPermission(BasePermission):\n    \"\"\"\n    A permission to be used when wanting to permit users with active subscriptions.\n    \"\"\"\n\n    def has_permission(self, request, view):\n        \"\"\"\n        Check if the subscriber has an active subscription.\n\n        Returns false if:\n            * a subscriber isn't passed through the request\n\n        See ``utils.subscriber_has_active_subscription`` for more rules.\n\n        \"\"\"\n        try:\n            subscriber_has_active_subscription(subscriber_request_callback(request))\n        except AttributeError:\n            return False\n", "path": "djstripe/contrib/rest_framework/permissions.py"}], "after_files": [{"content": "\"\"\"\n.. module:: dj-stripe.contrib.rest_framework.serializers.\n\n    :synopsis: dj-stripe - Serializers to be used with the dj-stripe REST API.\n\n.. moduleauthor:: Philippe Luickx (@philippeluickx)\n\n\"\"\"\n\nfrom rest_framework import serializers\nfrom rest_framework.serializers import ModelSerializer\n\nfrom djstripe.models import Subscription\n\n\nclass SubscriptionSerializer(ModelSerializer):\n    \"\"\"A serializer used for the Subscription model.\"\"\"\n\n    class Meta:\n        \"\"\"Model class options.\"\"\"\n\n        model = Subscription\n        exclude = [\"default_tax_rates\"]\n\n\nclass CreateSubscriptionSerializer(serializers.Serializer):\n    \"\"\"A serializer used to create a Subscription.\"\"\"\n\n    stripe_token = serializers.CharField(max_length=200)\n    plan = serializers.CharField(max_length=50)\n    charge_immediately = serializers.BooleanField(\n        required=False, allow_null=True, default=None\n    )\n    tax_percent = serializers.DecimalField(\n        required=False, max_digits=5, decimal_places=2\n    )\n", "path": "djstripe/contrib/rest_framework/serializers.py"}, {"content": "\"\"\"\n.. module:: dj-stripe.contrib.rest_framework.permissions.\n\n    :synopsis: dj-stripe - Permissions to be used with the dj-stripe REST API.\n\n.. moduleauthor:: @kavdev, @pydanny\n\n\"\"\"\nfrom rest_framework.permissions import BasePermission\n\nfrom ...settings import subscriber_request_callback\nfrom ...utils import subscriber_has_active_subscription\n\n\nclass DJStripeSubscriptionPermission(BasePermission):\n    \"\"\"\n    A permission to be used when wanting to permit users with active subscriptions.\n    \"\"\"\n\n    def has_permission(self, request, view) -> bool:\n        \"\"\"\n        Check if the subscriber has an active subscription.\n\n        Returns false if:\n            * a subscriber isn't passed through the request\n\n        See ``utils.subscriber_has_active_subscription`` for more rules.\n\n        \"\"\"\n        try:\n            return subscriber_has_active_subscription(\n                subscriber_request_callback(request)\n            )\n        except AttributeError:\n            return False\n", "path": "djstripe/contrib/rest_framework/permissions.py"}]}