Skip to content

Instantly share code, notes, and snippets.

@kannthu
Created July 1, 2024 13:17
Show Gist options
  • Save kannthu/6e1bdd2781d2e0a6ded30844d61f089e to your computer and use it in GitHub Desktop.
Save kannthu/6e1bdd2781d2e0a6ded30844d61f089e to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.
{
"definitions": [
{
"type": "method",
"filePath": "djstripe/managers.py",
"name": "active",
"ref": "djstripe/managers.py:24",
"definitionRange": {
"startLine": 24,
"startColumn": 4,
"endLine": 26,
"endColumn": 43
},
"language": "python",
"snippet": "def active(self):\n \"\"\"Return active Subscriptions.\"\"\"\n return self.filter(status=\"active\")",
"nameRange": {
"startLine": 24,
"startColumn": 8,
"endLine": 24,
"endColumn": 14
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/managers.py:48",
"targetRef": "djstripe/managers.py:24",
"sourceSnippetRange": {
"startLine": 48,
"startColumn": 17,
"endLine": 48,
"endColumn": 23
},
"snippet": "active"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/managers.py:65",
"targetRef": "djstripe/managers.py:24",
"sourceSnippetRange": {
"startLine": 65,
"startColumn": 22,
"endLine": 65,
"endColumn": 28
},
"snippet": "active"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/managers.py:25",
"range": {
"startLine": 25,
"startColumn": 8,
"endLine": 25,
"endColumn": 42
},
"expression": "\"\"\"Return active Subscriptions.\"\"\""
}
]
},
{
"type": "method",
"filePath": "djstripe/managers.py",
"name": "canceled",
"ref": "djstripe/managers.py:28",
"definitionRange": {
"startLine": 28,
"startColumn": 4,
"endLine": 30,
"endColumn": 45
},
"language": "python",
"snippet": "def canceled(self):\n \"\"\"Return canceled Subscriptions.\"\"\"\n return self.filter(status=\"canceled\")",
"nameRange": {
"startLine": 28,
"startColumn": 8,
"endLine": 28,
"endColumn": 16
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/managers.py:34",
"targetRef": "djstripe/managers.py:28",
"sourceSnippetRange": {
"startLine": 34,
"startColumn": 20,
"endLine": 34,
"endColumn": 28
},
"snippet": "canceled"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/managers.py:64",
"targetRef": "djstripe/managers.py:28",
"sourceSnippetRange": {
"startLine": 64,
"startColumn": 24,
"endLine": 64,
"endColumn": 32
},
"snippet": "canceled"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/managers.py:29",
"range": {
"startLine": 29,
"startColumn": 8,
"endLine": 29,
"endColumn": 44
},
"expression": "\"\"\"Return canceled Subscriptions.\"\"\""
}
]
},
{
"type": "class_property",
"filePath": "djstripe/settings.py",
"name": "ZERO_DECIMAL_CURRENCIES",
"ref": "djstripe/settings.py:21",
"definitionRange": {
"startLine": 21,
"startColumn": 4,
"endLine": 37,
"endColumn": 5
},
"language": "python",
"snippet": "ZERO_DECIMAL_CURRENCIES = {\n \"bif\",\n \"clp\",\n \"djf\",\n \"gnf\",\n \"jpy\",\n \"kmf\",\n \"krw\",\n \"mga\",\n \"pyg\",\n \"rwf\",\n \"vnd\",\n \"vuv\",\n \"xaf\",\n \"xof\",\n \"xpf\",\n }",
"nameRange": {
"startLine": 21,
"startColumn": 4,
"endLine": 21,
"endColumn": 27
},
"references": [
{
"targetRef": "djstripe/settings.py:21",
"sourceSnippetRange": {
"startLine": 21,
"startColumn": 0,
"endLine": 21,
"endColumn": 32
},
"sourceRef": "djstripe/settings.py:21",
"type": "from-search",
"snippet": " ZERO_DECIMAL_CURRENCIES = {\n"
}
],
"expressions": []
},
{
"type": "class_property",
"filePath": "djstripe/settings.py",
"name": "DEFAULT_STRIPE_API_VERSION",
"ref": "djstripe/settings.py:19",
"definitionRange": {
"startLine": 19,
"startColumn": 4,
"endLine": 19,
"endColumn": 45
},
"language": "python",
"snippet": "DEFAULT_STRIPE_API_VERSION = \"2020-08-27\"",
"nameRange": {
"startLine": 19,
"startColumn": 4,
"endLine": 19,
"endColumn": 30
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/checks.py:114",
"targetRef": "djstripe/settings.py:19",
"sourceSnippetRange": {
"startLine": 114,
"startColumn": 40,
"endLine": 114,
"endColumn": 66
},
"snippet": "DEFAULT_STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:127",
"targetRef": "djstripe/settings.py:19",
"sourceSnippetRange": {
"startLine": 127,
"startColumn": 31,
"endLine": 127,
"endColumn": 57
},
"snippet": "DEFAULT_STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:142",
"targetRef": "djstripe/settings.py:19",
"sourceSnippetRange": {
"startLine": 142,
"startColumn": 39,
"endLine": 142,
"endColumn": 65
},
"snippet": "DEFAULT_STRIPE_API_VERSION"
}
],
"expressions": []
},
{
"type": "class",
"filePath": "djstripe/exceptions.py",
"name": "ImpossibleAPIRequest",
"ref": "djstripe/exceptions.py:28",
"definitionRange": {
"startLine": 28,
"startColumn": 0,
"endLine": 33,
"endColumn": 8
},
"language": "python",
"snippet": "class ImpossibleAPIRequest(Exception):\n \"\"\"\n Raised when dj-stripe attempts to make an impossible API request\n \"\"\"\n\n pass",
"nameRange": {
"startLine": 28,
"startColumn": 6,
"endLine": 28,
"endColumn": 26
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:14",
"targetRef": "djstripe/exceptions.py:28",
"sourceSnippetRange": {
"startLine": 14,
"startColumn": 25,
"endLine": 14,
"endColumn": 45
},
"snippet": "ImpossibleAPIRequest"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:553",
"targetRef": "djstripe/exceptions.py:28",
"sourceSnippetRange": {
"startLine": 553,
"startColumn": 23,
"endLine": 553,
"endColumn": 43
},
"snippet": "ImpossibleAPIRequest"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:7",
"targetRef": "djstripe/exceptions.py:28",
"sourceSnippetRange": {
"startLine": 7,
"startColumn": 25,
"endLine": 7,
"endColumn": 45
},
"snippet": "ImpossibleAPIRequest"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:264",
"targetRef": "djstripe/exceptions.py:28",
"sourceSnippetRange": {
"startLine": 264,
"startColumn": 14,
"endLine": 264,
"endColumn": 34
},
"snippet": "ImpossibleAPIRequest"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:327",
"targetRef": "djstripe/exceptions.py:28",
"sourceSnippetRange": {
"startLine": 327,
"startColumn": 14,
"endLine": 327,
"endColumn": 34
},
"snippet": "ImpossibleAPIRequest"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:361",
"targetRef": "djstripe/exceptions.py:28",
"sourceSnippetRange": {
"startLine": 361,
"startColumn": 14,
"endLine": 361,
"endColumn": 34
},
"snippet": "ImpossibleAPIRequest"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:438",
"targetRef": "djstripe/exceptions.py:28",
"sourceSnippetRange": {
"startLine": 438,
"startColumn": 18,
"endLine": 438,
"endColumn": 38
},
"snippet": "ImpossibleAPIRequest"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/exceptions.py:28",
"range": {
"startLine": 28,
"startColumn": 26,
"endLine": 28,
"endColumn": 37
},
"name": "Exception",
"expression": "(Exception)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Exception",
"ref": "__base_types__:1823",
"definitionRange": {
"startLine": 1823,
"startColumn": 0,
"endLine": 1823,
"endColumn": 35
},
"language": "python",
"snippet": "class Exception(BaseException): ...",
"nameRange": {
"startLine": 1823,
"startColumn": 6,
"endLine": 1823,
"endColumn": 15
}
}
},
{
"type": "comment",
"ref": "djstripe/exceptions.py:29",
"range": {
"startLine": 29,
"startColumn": 4,
"endLine": 31,
"endColumn": 7
},
"expression": "\"\"\"\n Raised when dj-stripe attempts to make an impossible API request\n \"\"\""
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "__setattr__",
"ref": "djstripe/settings.py:46",
"definitionRange": {
"startLine": 46,
"startColumn": 4,
"endLine": 47,
"endColumn": 35
},
"language": "python",
"snippet": "def __setattr__(self, name, value):\n self.__dict__[name] = value",
"nameRange": {
"startLine": 46,
"startColumn": 8,
"endLine": 46,
"endColumn": 19
},
"references": [
{
"type": "from-parsing",
"sourceRef": "tests/__init__.py:113",
"targetRef": "djstripe/settings.py:46",
"sourceSnippetRange": {
"startLine": 113,
"startColumn": 8,
"endLine": 113,
"endColumn": 19
},
"snippet": "__setattr__"
},
{
"type": "from-parsing",
"sourceRef": "tests/__init__.py:142",
"targetRef": "djstripe/settings.py:46",
"sourceSnippetRange": {
"startLine": 142,
"startColumn": 17,
"endLine": 142,
"endColumn": 28
},
"snippet": "__setattr__"
},
{
"type": "from-parsing",
"sourceRef": "tests/__init__.py:173",
"targetRef": "djstripe/settings.py:46",
"sourceSnippetRange": {
"startLine": 173,
"startColumn": 8,
"endLine": 173,
"endColumn": 19
},
"snippet": "__setattr__"
},
{
"type": "from-parsing",
"sourceRef": "tests/__init__.py:1019",
"targetRef": "djstripe/settings.py:46",
"sourceSnippetRange": {
"startLine": 1019,
"startColumn": 8,
"endLine": 1019,
"endColumn": 19
},
"snippet": "__setattr__"
}
],
"expressions": []
},
{
"type": "class",
"filePath": "djstripe/exceptions.py",
"name": "MultipleSubscriptionException",
"ref": "djstripe/exceptions.py:5",
"definitionRange": {
"startLine": 5,
"startColumn": 0,
"endLine": 8,
"endColumn": 8
},
"language": "python",
"snippet": "class MultipleSubscriptionException(Exception):\n \"\"\"Raised when a Customer has multiple Subscriptions and only one is expected.\"\"\"\n\n pass",
"nameRange": {
"startLine": 5,
"startColumn": 6,
"endLine": 5,
"endColumn": 35
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:13",
"targetRef": "djstripe/exceptions.py:5",
"sourceSnippetRange": {
"startLine": 13,
"startColumn": 25,
"endLine": 13,
"endColumn": 54
},
"snippet": "MultipleSubscriptionException"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1258",
"targetRef": "djstripe/exceptions.py:5",
"sourceSnippetRange": {
"startLine": 1258,
"startColumn": 18,
"endLine": 1258,
"endColumn": 47
},
"snippet": "MultipleSubscriptionException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:13",
"targetRef": "djstripe/exceptions.py:5",
"sourceSnippetRange": {
"startLine": 13,
"startColumn": 32,
"endLine": 13,
"endColumn": 61
},
"snippet": "MultipleSubscriptionException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1719",
"targetRef": "djstripe/exceptions.py:5",
"sourceSnippetRange": {
"startLine": 1719,
"startColumn": 31,
"endLine": 1719,
"endColumn": 60
},
"snippet": "MultipleSubscriptionException"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/exceptions.py:5",
"range": {
"startLine": 5,
"startColumn": 35,
"endLine": 5,
"endColumn": 46
},
"name": "Exception",
"expression": "(Exception)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Exception",
"ref": "__base_types__:1823",
"definitionRange": {
"startLine": 1823,
"startColumn": 0,
"endLine": 1823,
"endColumn": 35
},
"language": "python",
"snippet": "class Exception(BaseException): ...",
"nameRange": {
"startLine": 1823,
"startColumn": 6,
"endLine": 1823,
"endColumn": 15
}
}
},
{
"type": "comment",
"ref": "djstripe/exceptions.py:6",
"range": {
"startLine": 6,
"startColumn": 4,
"endLine": 6,
"endColumn": 85
},
"expression": "\"\"\"Raised when a Customer has multiple Subscriptions and only one is expected.\"\"\""
}
]
},
{
"type": "class",
"filePath": "djstripe/exceptions.py",
"name": "StripeObjectManipulationException",
"ref": "djstripe/exceptions.py:11",
"definitionRange": {
"startLine": 11,
"startColumn": 0,
"endLine": 17,
"endColumn": 8
},
"language": "python",
"snippet": "class StripeObjectManipulationException(Exception):\n \"\"\"\n Raised when an attempt to manipulate a non-standalone stripe object is made\n not through its parent object.\n \"\"\"\n\n pass",
"nameRange": {
"startLine": 11,
"startColumn": 6,
"endLine": 11,
"endColumn": 39
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:7",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 7,
"startColumn": 47,
"endLine": 7,
"endColumn": 80
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:154",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 154,
"startColumn": 18,
"endLine": 154,
"endColumn": 51
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:161",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 161,
"startColumn": 18,
"endLine": 161,
"endColumn": 51
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:167",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 167,
"startColumn": 18,
"endLine": 167,
"endColumn": 51
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:13",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 13,
"startColumn": 32,
"endLine": 13,
"endColumn": 65
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:255",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 255,
"startColumn": 12,
"endLine": 255,
"endColumn": 45
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:260",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 260,
"startColumn": 12,
"endLine": 260,
"endColumn": 45
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:271",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 271,
"startColumn": 12,
"endLine": 271,
"endColumn": 45
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:276",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 276,
"startColumn": 12,
"endLine": 276,
"endColumn": 45
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:287",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 287,
"startColumn": 12,
"endLine": 287,
"endColumn": 45
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:292",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 292,
"startColumn": 12,
"endLine": 292,
"endColumn": 45
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:14",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 14,
"startColumn": 32,
"endLine": 14,
"endColumn": 65
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:232",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 232,
"startColumn": 12,
"endLine": 232,
"endColumn": 45
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:237",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 237,
"startColumn": 12,
"endLine": 237,
"endColumn": 45
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:248",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 248,
"startColumn": 12,
"endLine": 248,
"endColumn": 45
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:253",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 253,
"startColumn": 12,
"endLine": 253,
"endColumn": 45
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:264",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 264,
"startColumn": 12,
"endLine": 264,
"endColumn": 45
},
"snippet": "StripeObjectManipulationException"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:269",
"targetRef": "djstripe/exceptions.py:11",
"sourceSnippetRange": {
"startLine": 269,
"startColumn": 12,
"endLine": 269,
"endColumn": 45
},
"snippet": "StripeObjectManipulationException"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/exceptions.py:11",
"range": {
"startLine": 11,
"startColumn": 39,
"endLine": 11,
"endColumn": 50
},
"name": "Exception",
"expression": "(Exception)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Exception",
"ref": "__base_types__:1823",
"definitionRange": {
"startLine": 1823,
"startColumn": 0,
"endLine": 1823,
"endColumn": 35
},
"language": "python",
"snippet": "class Exception(BaseException): ...",
"nameRange": {
"startLine": 1823,
"startColumn": 6,
"endLine": 1823,
"endColumn": 15
}
}
},
{
"type": "comment",
"ref": "djstripe/exceptions.py:12",
"range": {
"startLine": 12,
"startColumn": 4,
"endLine": 15,
"endColumn": 7
},
"expression": "\"\"\"\n Raised when an attempt to manipulate a non-standalone stripe object is made\n not through its parent object.\n \"\"\""
}
]
},
{
"type": "class",
"filePath": "djstripe/exceptions.py",
"name": "InvalidStripeAPIKey",
"ref": "djstripe/exceptions.py:20",
"definitionRange": {
"startLine": 20,
"startColumn": 0,
"endLine": 25,
"endColumn": 8
},
"language": "python",
"snippet": "class InvalidStripeAPIKey(ValueError):\n \"\"\"\n Raised when a clearly-invalid Stripe API key is used.\n \"\"\"\n\n pass",
"nameRange": {
"startLine": 20,
"startColumn": 6,
"endLine": 20,
"endColumn": 25
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/api.py:9",
"targetRef": "djstripe/exceptions.py:20",
"sourceSnippetRange": {
"startLine": 9,
"startColumn": 25,
"endLine": 9,
"endColumn": 44
},
"snippet": "InvalidStripeAPIKey"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/api.py:27",
"targetRef": "djstripe/exceptions.py:20",
"sourceSnippetRange": {
"startLine": 27,
"startColumn": 14,
"endLine": 27,
"endColumn": 33
},
"snippet": "InvalidStripeAPIKey"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/api.py:82",
"targetRef": "djstripe/exceptions.py:20",
"sourceSnippetRange": {
"startLine": 82,
"startColumn": 19,
"endLine": 82,
"endColumn": 38
},
"snippet": "InvalidStripeAPIKey"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_apikey.py:13",
"targetRef": "djstripe/exceptions.py:20",
"sourceSnippetRange": {
"startLine": 13,
"startColumn": 32,
"endLine": 13,
"endColumn": 51
},
"snippet": "InvalidStripeAPIKey"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_apikey.py:40",
"targetRef": "djstripe/exceptions.py:20",
"sourceSnippetRange": {
"startLine": 40,
"startColumn": 23,
"endLine": 40,
"endColumn": 42
},
"snippet": "InvalidStripeAPIKey"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_apikey.py:42",
"targetRef": "djstripe/exceptions.py:20",
"sourceSnippetRange": {
"startLine": 42,
"startColumn": 23,
"endLine": 42,
"endColumn": 42
},
"snippet": "InvalidStripeAPIKey"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_apikey.py:44",
"targetRef": "djstripe/exceptions.py:20",
"sourceSnippetRange": {
"startLine": 44,
"startColumn": 23,
"endLine": 44,
"endColumn": 42
},
"snippet": "InvalidStripeAPIKey"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/exceptions.py:20",
"range": {
"startLine": 20,
"startColumn": 25,
"endLine": 20,
"endColumn": 37
},
"name": "ValueError",
"expression": "(ValueError)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "ValueError",
"ref": "__base_types__:1888",
"definitionRange": {
"startLine": 1888,
"startColumn": 0,
"endLine": 1888,
"endColumn": 32
},
"language": "python",
"snippet": "class ValueError(Exception): ...",
"nameRange": {
"startLine": 1888,
"startColumn": 6,
"endLine": 1888,
"endColumn": 16
}
}
},
{
"type": "comment",
"ref": "djstripe/exceptions.py:21",
"range": {
"startLine": 21,
"startColumn": 4,
"endLine": 23,
"endColumn": 7
},
"expression": "\"\"\"\n Raised when a clearly-invalid Stripe API key is used.\n \"\"\""
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "__delattr__",
"ref": "djstripe/settings.py:49",
"definitionRange": {
"startLine": 49,
"startColumn": 4,
"endLine": 50,
"endColumn": 31
},
"language": "python",
"snippet": "def __delattr__(self, name):\n del self.__dict__[name]",
"nameRange": {
"startLine": 49,
"startColumn": 8,
"endLine": 49,
"endColumn": 19
},
"references": [
{
"type": "from-parsing",
"sourceRef": "tests/__init__.py:116",
"targetRef": "djstripe/settings.py:49",
"sourceSnippetRange": {
"startLine": 116,
"startColumn": 8,
"endLine": 116,
"endColumn": 19
},
"snippet": "__delattr__"
},
{
"type": "from-parsing",
"sourceRef": "tests/__init__.py:176",
"targetRef": "djstripe/settings.py:49",
"sourceSnippetRange": {
"startLine": 176,
"startColumn": 8,
"endLine": 176,
"endColumn": 19
},
"snippet": "__delattr__"
}
],
"expressions": []
},
{
"type": "class",
"filePath": "djstripe/managers.py",
"name": "StripeModelManager",
"ref": "djstripe/managers.py:9",
"definitionRange": {
"startLine": 9,
"startColumn": 0,
"endLine": 12,
"endColumn": 8
},
"language": "python",
"snippet": "class StripeModelManager(models.Manager):\n \"\"\"Manager used in StripeModel.\"\"\"\n\n pass",
"nameRange": {
"startLine": 9,
"startColumn": 6,
"endLine": 9,
"endColumn": 24
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:22",
"targetRef": "djstripe/managers.py:9",
"sourceSnippetRange": {
"startLine": 22,
"startColumn": 23,
"endLine": 22,
"endColumn": 41
},
"snippet": "StripeModelManager"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:95",
"targetRef": "djstripe/managers.py:9",
"sourceSnippetRange": {
"startLine": 95,
"startColumn": 21,
"endLine": 95,
"endColumn": 39
},
"snippet": "StripeModelManager"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/managers.py:9",
"range": {
"startLine": 9,
"startColumn": 24,
"endLine": 9,
"endColumn": 40
},
"name": "Manager",
"expression": "(models.Manager)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Manager",
"ref": "__base_types__:39",
"definitionRange": {
"startLine": 39,
"startColumn": 0,
"endLine": 40,
"endColumn": 39
},
"language": "python",
"snippet": "class Manager(BaseManager[_T]):\n _queryset_class: type[QuerySet[_T]]",
"nameRange": {
"startLine": 39,
"startColumn": 6,
"endLine": 39,
"endColumn": 13
}
}
},
{
"type": "variable",
"ref": "djstripe/managers.py:9",
"range": {
"startLine": 9,
"startColumn": 25,
"endLine": 9,
"endColumn": 39
},
"name": "models",
"expression": "models.Manager",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
},
{
"type": "comment",
"ref": "djstripe/managers.py:10",
"range": {
"startLine": 10,
"startColumn": 4,
"endLine": 10,
"endColumn": 38
},
"expression": "\"\"\"Manager used in StripeModel.\"\"\""
}
]
},
{
"type": "method",
"filePath": "djstripe/managers.py",
"name": "started_during",
"ref": "djstripe/managers.py:18",
"definitionRange": {
"startLine": 18,
"startColumn": 4,
"endLine": 22,
"endColumn": 9
},
"language": "python",
"snippet": "def started_during(self, year, month):\n \"\"\"Return Subscriptions not in trial status between a certain time range.\"\"\"\n return self.exclude(status=\"trialing\").filter(\n start_date__year=year, start_date__month=month\n )",
"nameRange": {
"startLine": 18,
"startColumn": 8,
"endLine": 18,
"endColumn": 22
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/managers.py:39",
"targetRef": "djstripe/managers.py:18",
"sourceSnippetRange": {
"startLine": 39,
"startColumn": 17,
"endLine": 39,
"endColumn": 31
},
"snippet": "started_during"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/managers.py:19",
"range": {
"startLine": 19,
"startColumn": 8,
"endLine": 19,
"endColumn": 84
},
"expression": "\"\"\"Return Subscriptions not in trial status between a certain time range.\"\"\""
},
{
"type": "call",
"ref": "djstripe/managers.py:20",
"range": {
"startLine": 20,
"startColumn": 15,
"endLine": 20,
"endColumn": 46
},
"name": "exclude",
"expression": "self.exclude(status=\"trialing\")",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "exclude",
"ref": "__base_types__:139",
"definitionRange": {
"startLine": 139,
"startColumn": 4,
"endLine": 139,
"endColumn": 61
},
"language": "python",
"snippet": "def exclude(self, *args: Any, **kwargs: Any) -> Self: ...",
"nameRange": {
"startLine": 139,
"startColumn": 8,
"endLine": 139,
"endColumn": 15
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "__init__",
"ref": "djstripe/settings.py:39",
"definitionRange": {
"startLine": 39,
"startColumn": 4,
"endLine": 43,
"endColumn": 66
},
"language": "python",
"snippet": "def __init__(self):\n # Set STRIPE_API_HOST if you want to use a different Stripe API server\n # Example: https://github.com/stripe/stripe-mock\n if hasattr(settings, \"STRIPE_API_HOST\"):\n stripe.api_base = getattr(settings, \"STRIPE_API_HOST\")",
"nameRange": {
"startLine": 39,
"startColumn": 8,
"endLine": 39,
"endColumn": 16
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:236",
"targetRef": "djstripe/settings.py:39",
"sourceSnippetRange": {
"startLine": 236,
"startColumn": 20,
"endLine": 236,
"endColumn": 36
},
"snippet": "DjstripeSettings"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/settings.py:40",
"range": {
"startLine": 40,
"startColumn": 8,
"endLine": 40,
"endColumn": 78
},
"expression": "# Set STRIPE_API_HOST if you want to use a different Stripe API server"
},
{
"type": "comment",
"ref": "djstripe/settings.py:41",
"range": {
"startLine": 41,
"startColumn": 8,
"endLine": 41,
"endColumn": 56
},
"expression": "# Example: https://github.com/stripe/stripe-mock"
},
{
"type": "variable",
"ref": "djstripe/settings.py:42",
"range": {
"startLine": 42,
"startColumn": 18,
"endLine": 42,
"endColumn": 47
},
"name": "settings",
"expression": "(settings, \"STRIPE_API_HOST\")",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "settings",
"ref": "__base_types__:15",
"definitionRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 28
},
"language": "python",
"snippet": "settings: LazySettings = ...",
"nameRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 8
}
}
},
{
"type": "variable",
"ref": "djstripe/settings.py:43",
"range": {
"startLine": 43,
"startColumn": 12,
"endLine": 43,
"endColumn": 27
},
"name": "stripe",
"expression": "stripe.api_base",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "Incomplete",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 32
},
"language": "python",
"snippet": "from _typeshed import Incomplete",
"nameRange": {
"startLine": 0,
"startColumn": 22,
"endLine": 0,
"endColumn": 32
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/apps.py",
"name": "name",
"ref": "djstripe/apps.py:17",
"definitionRange": {
"startLine": 17,
"startColumn": 4,
"endLine": 17,
"endColumn": 21
},
"language": "python",
"snippet": "name = \"djstripe\"",
"nameRange": {
"startLine": 17,
"startColumn": 4,
"endLine": 17,
"endColumn": 8
},
"references": [
{
"targetRef": "djstripe/apps.py:17",
"sourceSnippetRange": {
"startLine": 17,
"startColumn": 0,
"endLine": 17,
"endColumn": 22
},
"sourceRef": "djstripe/apps.py:17",
"type": "from-search",
"snippet": " name = \"djstripe\"\n"
}
],
"expressions": []
},
{
"type": "class_property",
"filePath": "djstripe/apps.py",
"name": "default_auto_field",
"ref": "djstripe/apps.py:18",
"definitionRange": {
"startLine": 18,
"startColumn": 4,
"endLine": 18,
"endColumn": 53
},
"language": "python",
"snippet": "default_auto_field = \"django.db.models.AutoField\"",
"nameRange": {
"startLine": 18,
"startColumn": 4,
"endLine": 18,
"endColumn": 22
},
"references": [
{
"targetRef": "djstripe/apps.py:18",
"sourceSnippetRange": {
"startLine": 18,
"startColumn": 0,
"endLine": 18,
"endColumn": 54
},
"sourceRef": "djstripe/apps.py:18",
"type": "from-search",
"snippet": " default_auto_field = \"django.db.models.AutoField\"\n"
}
],
"expressions": []
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "decimal_max_digits",
"ref": "djstripe/settings.py:66",
"definitionRange": {
"startLine": 66,
"startColumn": 4,
"endLine": 67,
"endColumn": 17
},
"language": "python",
"snippet": "def decimal_max_digits(self):\n return 24",
"nameRange": {
"startLine": 66,
"startColumn": 8,
"endLine": 66,
"endColumn": 26
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1202",
"targetRef": "djstripe/settings.py:66",
"sourceSnippetRange": {
"startLine": 1202,
"startColumn": 37,
"endLine": 1202,
"endColumn": 55
},
"snippet": "decimal_max_digits"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:2280",
"targetRef": "djstripe/settings.py:66",
"sourceSnippetRange": {
"startLine": 2280,
"startColumn": 37,
"endLine": 2280,
"endColumn": 55
},
"snippet": "decimal_max_digits"
}
],
"expressions": []
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "subscriber_request_callback",
"ref": "djstripe/settings.py:53",
"definitionRange": {
"startLine": 53,
"startColumn": 4,
"endLine": 57,
"endColumn": 9
},
"language": "python",
"snippet": "def subscriber_request_callback(self):\n return self.get_callback_function(\n \"DJSTRIPE_SUBSCRIBER_MODEL_REQUEST_CALLBACK\",\n default=(lambda request: request.user),\n )",
"nameRange": {
"startLine": 53,
"startColumn": 8,
"endLine": 53,
"endColumn": 35
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/mixins.py:34",
"targetRef": "djstripe/settings.py:53",
"sourceSnippetRange": {
"startLine": 34,
"startColumn": 41,
"endLine": 34,
"endColumn": 68
},
"snippet": "subscriber_request_callback"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/settings.py:54",
"range": {
"startLine": 54,
"startColumn": 15,
"endLine": 57,
"endColumn": 9
},
"name": "get_callback_function",
"expression": "self.get_callback_function(\n \"DJSTRIPE_SUBSCRIBER_MODEL_REQUEST_CALLBACK\",\n default=(lambda request: request.user),\n )",
"definition": {
"type": "method",
"filePath": "djstripe/settings.py",
"name": "get_callback_function",
"ref": "djstripe/settings.py:129",
"definitionRange": {
"startLine": 129,
"startColumn": 4,
"endLine": 158,
"endColumn": 19
},
"language": "python",
"snippet": "def get_callback_function(self, setting_name, default=None):\n \"\"\"\n Resolve a callback function based on a setting name.\n\n If the setting value isn't set, default is returned. If the setting value\n is already a callable function, that value is used - If the setting value\n is a string, an attempt is made to import it. Anything else will result in\n a failed import causing ImportError to be raised.\n\n :param setting_name: The name of the setting to resolve a callback from.\n :type setting_name: string (``str``/``unicode``)\n :param default: The default to return if setting isn't populated.\n :type default: ``bool``\n :returns: The resolved callback function (if any).\n :type: ``callable``\n \"\"\"\n func = getattr(settings, setting_name, None)\n if not func:\n return default\n\n if callable(func):\n return func\n\n if isinstance(func, str):\n func = import_string(func)\n\n if not callable(func):\n raise ImproperlyConfigured(f\"{setting_name} must be callable.\")\n\n return func",
"nameRange": {
"startLine": 129,
"startColumn": 8,
"endLine": 129,
"endColumn": 29
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/managers.py",
"name": "canceled_during",
"ref": "djstripe/managers.py:32",
"definitionRange": {
"startLine": 32,
"startColumn": 4,
"endLine": 34,
"endColumn": 87
},
"language": "python",
"snippet": "def canceled_during(self, year, month):\n \"\"\"Return Subscriptions canceled during a certain time range.\"\"\"\n return self.canceled().filter(canceled_at__year=year, canceled_at__month=month)",
"nameRange": {
"startLine": 32,
"startColumn": 8,
"endLine": 32,
"endColumn": 23
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/managers.py:56",
"targetRef": "djstripe/managers.py:32",
"sourceSnippetRange": {
"startLine": 56,
"startColumn": 17,
"endLine": 56,
"endColumn": 32
},
"snippet": "canceled_during"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/managers.py:33",
"range": {
"startLine": 33,
"startColumn": 8,
"endLine": 33,
"endColumn": 72
},
"expression": "\"\"\"Return Subscriptions canceled during a certain time range.\"\"\""
},
{
"type": "call",
"ref": "djstripe/managers.py:34",
"range": {
"startLine": 34,
"startColumn": 15,
"endLine": 34,
"endColumn": 30
},
"name": "canceled",
"expression": "self.canceled()",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "canceled",
"ref": "djstripe/managers.py:28",
"definitionRange": {
"startLine": 28,
"startColumn": 4,
"endLine": 30,
"endColumn": 45
},
"language": "python",
"snippet": "def canceled(self):\n \"\"\"Return canceled Subscriptions.\"\"\"\n return self.filter(status=\"canceled\")",
"nameRange": {
"startLine": 28,
"startColumn": 8,
"endLine": 28,
"endColumn": 16
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "decimal_places",
"ref": "djstripe/settings.py:70",
"definitionRange": {
"startLine": 70,
"startColumn": 4,
"endLine": 71,
"endColumn": 17
},
"language": "python",
"snippet": "def decimal_places(self):\n return 12",
"nameRange": {
"startLine": 70,
"startColumn": 8,
"endLine": 70,
"endColumn": 22
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1203",
"targetRef": "djstripe/settings.py:70",
"sourceSnippetRange": {
"startLine": 1203,
"startColumn": 41,
"endLine": 1203,
"endColumn": 55
},
"snippet": "decimal_places"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:2281",
"targetRef": "djstripe/settings.py:70",
"sourceSnippetRange": {
"startLine": 2281,
"startColumn": 41,
"endLine": 2281,
"endColumn": 55
},
"snippet": "decimal_places"
}
],
"expressions": []
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "get_idempotency_key",
"ref": "djstripe/settings.py:60",
"definitionRange": {
"startLine": 60,
"startColumn": 4,
"endLine": 63,
"endColumn": 9
},
"language": "python",
"snippet": "def get_idempotency_key(self):\n return self.get_callback_function(\n \"DJSTRIPE_IDEMPOTENCY_KEY_CALLBACK\", self._get_idempotency_key\n )",
"nameRange": {
"startLine": 60,
"startColumn": 8,
"endLine": 60,
"endColumn": 27
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:886",
"targetRef": "djstripe/settings.py:60",
"sourceSnippetRange": {
"startLine": 886,
"startColumn": 48,
"endLine": 886,
"endColumn": 67
},
"snippet": "get_idempotency_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_idempotency_keys.py:12",
"targetRef": "djstripe/settings.py:60",
"sourceSnippetRange": {
"startLine": 12,
"startColumn": 33,
"endLine": 12,
"endColumn": 52
},
"snippet": "get_idempotency_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_idempotency_keys.py:13",
"targetRef": "djstripe/settings.py:60",
"sourceSnippetRange": {
"startLine": 13,
"startColumn": 33,
"endLine": 13,
"endColumn": 52
},
"snippet": "get_idempotency_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_idempotency_keys.py:16",
"targetRef": "djstripe/settings.py:60",
"sourceSnippetRange": {
"startLine": 16,
"startColumn": 33,
"endLine": 16,
"endColumn": 52
},
"snippet": "get_idempotency_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_idempotency_keys.py:19",
"targetRef": "djstripe/settings.py:60",
"sourceSnippetRange": {
"startLine": 19,
"startColumn": 33,
"endLine": 19,
"endColumn": 52
},
"snippet": "get_idempotency_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_idempotency_keys.py:30",
"targetRef": "djstripe/settings.py:60",
"sourceSnippetRange": {
"startLine": 30,
"startColumn": 40,
"endLine": 30,
"endColumn": 59
},
"snippet": "get_idempotency_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_idempotency_keys.py:37",
"targetRef": "djstripe/settings.py:60",
"sourceSnippetRange": {
"startLine": 37,
"startColumn": 38,
"endLine": 37,
"endColumn": 57
},
"snippet": "get_idempotency_key"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/settings.py:61",
"range": {
"startLine": 61,
"startColumn": 15,
"endLine": 63,
"endColumn": 9
},
"name": "get_callback_function",
"expression": "self.get_callback_function(\n \"DJSTRIPE_IDEMPOTENCY_KEY_CALLBACK\", self._get_idempotency_key\n )",
"definition": {
"type": "method",
"filePath": "djstripe/settings.py",
"name": "get_callback_function",
"ref": "djstripe/settings.py:129",
"definitionRange": {
"startLine": 129,
"startColumn": 4,
"endLine": 158,
"endColumn": 19
},
"language": "python",
"snippet": "def get_callback_function(self, setting_name, default=None):\n \"\"\"\n Resolve a callback function based on a setting name.\n\n If the setting value isn't set, default is returned. If the setting value\n is already a callable function, that value is used - If the setting value\n is a string, an attempt is made to import it. Anything else will result in\n a failed import causing ImportError to be raised.\n\n :param setting_name: The name of the setting to resolve a callback from.\n :type setting_name: string (``str``/``unicode``)\n :param default: The default to return if setting isn't populated.\n :type default: ``bool``\n :returns: The resolved callback function (if any).\n :type: ``callable``\n \"\"\"\n func = getattr(settings, setting_name, None)\n if not func:\n return default\n\n if callable(func):\n return func\n\n if isinstance(func, str):\n func = import_string(func)\n\n if not callable(func):\n raise ImproperlyConfigured(f\"{setting_name} must be callable.\")\n\n return func",
"nameRange": {
"startLine": 129,
"startColumn": 8,
"endLine": 129,
"endColumn": 29
}
}
},
{
"type": "variable",
"ref": "djstripe/settings.py:61",
"range": {
"startLine": 61,
"startColumn": 41,
"endLine": 63,
"endColumn": 9
},
"name": "_get_idempotency_key",
"expression": "(\n \"DJSTRIPE_IDEMPOTENCY_KEY_CALLBACK\", self._get_idempotency_key\n )",
"definition": {
"type": "method",
"filePath": "djstripe/settings.py",
"name": "_get_idempotency_key",
"ref": "djstripe/settings.py:160",
"definitionRange": {
"startLine": 160,
"startColumn": 4,
"endLine": 167,
"endColumn": 40
},
"language": "python",
"snippet": "def _get_idempotency_key(self, object_type, action, livemode) -> str:\n from .models import IdempotencyKey\n\n action = f\"{object_type}:{action}\"\n idempotency_key, _created = IdempotencyKey.objects.get_or_create(\n action=action, livemode=livemode\n )\n return str(idempotency_key.uuid)",
"nameRange": {
"startLine": 160,
"startColumn": 8,
"endLine": 160,
"endColumn": 28
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "WEBHOOK_EVENT_CALLBACK",
"ref": "djstripe/settings.py:77",
"definitionRange": {
"startLine": 77,
"startColumn": 4,
"endLine": 78,
"endColumn": 76
},
"language": "python",
"snippet": "def WEBHOOK_EVENT_CALLBACK(self):\n return self.get_callback_function(\"DJSTRIPE_WEBHOOK_EVENT_CALLBACK\")",
"nameRange": {
"startLine": 77,
"startColumn": 8,
"endLine": 77,
"endColumn": 30
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/checks.py:224",
"targetRef": "djstripe/settings.py:77",
"sourceSnippetRange": {
"startLine": 224,
"startColumn": 33,
"endLine": 224,
"endColumn": 55
},
"snippet": "WEBHOOK_EVENT_CALLBACK"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/webhooks.py:251",
"targetRef": "djstripe/settings.py:77",
"sourceSnippetRange": {
"startLine": 251,
"startColumn": 37,
"endLine": 251,
"endColumn": 59
},
"snippet": "WEBHOOK_EVENT_CALLBACK"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/webhooks.py:253",
"targetRef": "djstripe/settings.py:77",
"sourceSnippetRange": {
"startLine": 253,
"startColumn": 38,
"endLine": 253,
"endColumn": 60
},
"snippet": "WEBHOOK_EVENT_CALLBACK"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/settings.py:78",
"range": {
"startLine": 78,
"startColumn": 15,
"endLine": 78,
"endColumn": 76
},
"name": "get_callback_function",
"expression": "self.get_callback_function(\"DJSTRIPE_WEBHOOK_EVENT_CALLBACK\")",
"definition": {
"type": "method",
"filePath": "djstripe/settings.py",
"name": "get_callback_function",
"ref": "djstripe/settings.py:129",
"definitionRange": {
"startLine": 129,
"startColumn": 4,
"endLine": 158,
"endColumn": 19
},
"language": "python",
"snippet": "def get_callback_function(self, setting_name, default=None):\n \"\"\"\n Resolve a callback function based on a setting name.\n\n If the setting value isn't set, default is returned. If the setting value\n is already a callable function, that value is used - If the setting value\n is a string, an attempt is made to import it. Anything else will result in\n a failed import causing ImportError to be raised.\n\n :param setting_name: The name of the setting to resolve a callback from.\n :type setting_name: string (``str``/``unicode``)\n :param default: The default to return if setting isn't populated.\n :type default: ``bool``\n :returns: The resolved callback function (if any).\n :type: ``callable``\n \"\"\"\n func = getattr(settings, setting_name, None)\n if not func:\n return default\n\n if callable(func):\n return func\n\n if isinstance(func, str):\n func = import_string(func)\n\n if not callable(func):\n raise ImproperlyConfigured(f\"{setting_name} must be callable.\")\n\n return func",
"nameRange": {
"startLine": 129,
"startColumn": 8,
"endLine": 129,
"endColumn": 29
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/apps.py",
"name": "ready",
"ref": "djstripe/apps.py:20",
"definitionRange": {
"startLine": 20,
"startColumn": 4,
"endLine": 31,
"endColumn": 9
},
"language": "python",
"snippet": "def ready(self):\n import stripe\n\n from . import checks, event_handlers # noqa (register event handlers)\n\n # Set app info\n # https://stripe.com/docs/building-plugins#setappinfo\n stripe.set_app_info(\n \"dj-stripe\",\n version=__version__,\n url=\"https://github.com/dj-stripe/dj-stripe\",\n )",
"nameRange": {
"startLine": 20,
"startColumn": 8,
"endLine": 20,
"endColumn": 13
},
"references": [],
"expressions": [
{
"type": "comment",
"ref": "djstripe/apps.py:23",
"range": {
"startLine": 23,
"startColumn": 46,
"endLine": 23,
"endColumn": 78
},
"expression": "# noqa (register event handlers)"
},
{
"type": "comment",
"ref": "djstripe/apps.py:25",
"range": {
"startLine": 25,
"startColumn": 8,
"endLine": 25,
"endColumn": 22
},
"expression": "# Set app info"
},
{
"type": "comment",
"ref": "djstripe/apps.py:26",
"range": {
"startLine": 26,
"startColumn": 8,
"endLine": 26,
"endColumn": 61
},
"expression": "# https://stripe.com/docs/building-plugins#setappinfo"
},
{
"type": "call",
"ref": "djstripe/apps.py:27",
"range": {
"startLine": 27,
"startColumn": 8,
"endLine": 31,
"endColumn": 9
},
"name": "set_app_info",
"expression": "stripe.set_app_info(\n \"dj-stripe\",\n version=__version__,\n url=\"https://github.com/dj-stripe/dj-stripe\",\n )",
"definition": {
"type": "function",
"filePath": "__base_types__",
"name": "set_app_info",
"ref": "__base_types__:22",
"definitionRange": {
"startLine": 22,
"startColumn": 0,
"endLine": 24,
"endColumn": 14
},
"language": "python",
"snippet": "def set_app_info(\n name, partner_id: Incomplete | None = None, url: Incomplete | None = None, version: Incomplete | None = None\n) -> None: ...",
"nameRange": {
"startLine": 22,
"startColumn": 4,
"endLine": 22,
"endColumn": 16
}
}
},
{
"type": "variable",
"ref": "djstripe/apps.py:27",
"range": {
"startLine": 27,
"startColumn": 8,
"endLine": 27,
"endColumn": 27
},
"name": "stripe",
"expression": "stripe.set_app_info",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "Incomplete",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 32
},
"language": "python",
"snippet": "from _typeshed import Incomplete",
"nameRange": {
"startLine": 0,
"startColumn": 22,
"endLine": 0,
"endColumn": 32
}
}
},
{
"type": "variable",
"ref": "djstripe/apps.py:29",
"range": {
"startLine": 29,
"startColumn": 12,
"endLine": 29,
"endColumn": 31
},
"name": "__version__",
"expression": "version=__version__",
"definition": {
"type": "expression",
"filePath": "djstripe/apps.py",
"name": "__version__",
"ref": "djstripe/apps.py:8",
"definitionRange": {
"startLine": 8,
"startColumn": 0,
"endLine": 8,
"endColumn": 34
},
"language": "python",
"snippet": "__version__ = version(\"dj-stripe\")",
"nameRange": {
"startLine": 8,
"startColumn": 0,
"endLine": 8,
"endColumn": 11
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "SUBSCRIBER_CUSTOMER_KEY",
"ref": "djstripe/settings.py:81",
"definitionRange": {
"startLine": 81,
"startColumn": 4,
"endLine": 84,
"endColumn": 9
},
"language": "python",
"snippet": "def SUBSCRIBER_CUSTOMER_KEY(self):\n return getattr(\n settings, \"DJSTRIPE_SUBSCRIBER_CUSTOMER_KEY\", \"djstripe_subscriber\"\n )",
"nameRange": {
"startLine": 81,
"startColumn": 8,
"endLine": 81,
"endColumn": 31
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/checks.py:194",
"targetRef": "djstripe/settings.py:81",
"sourceSnippetRange": {
"startLine": 194,
"startColumn": 28,
"endLine": 194,
"endColumn": 51
},
"snippet": "SUBSCRIBER_CUSTOMER_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/event_handlers.py:123",
"targetRef": "djstripe/settings.py:81",
"sourceSnippetRange": {
"startLine": 123,
"startColumn": 43,
"endLine": 123,
"endColumn": 66
},
"snippet": "SUBSCRIBER_CUSTOMER_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/checkout.py:122",
"targetRef": "djstripe/settings.py:81",
"sourceSnippetRange": {
"startLine": 122,
"startColumn": 36,
"endLine": 122,
"endColumn": 59
},
"snippet": "SUBSCRIBER_CUSTOMER_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:901",
"targetRef": "djstripe/settings.py:81",
"sourceSnippetRange": {
"startLine": 901,
"startColumn": 43,
"endLine": 901,
"endColumn": 66
},
"snippet": "SUBSCRIBER_CUSTOMER_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1370",
"targetRef": "djstripe/settings.py:81",
"sourceSnippetRange": {
"startLine": 1370,
"startColumn": 43,
"endLine": 1370,
"endColumn": 66
},
"snippet": "SUBSCRIBER_CUSTOMER_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/views.py:63",
"targetRef": "djstripe/settings.py:81",
"sourceSnippetRange": {
"startLine": 63,
"startColumn": 51,
"endLine": 63,
"endColumn": 74
},
"snippet": "SUBSCRIBER_CUSTOMER_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_session.py:188",
"targetRef": "djstripe/settings.py:81",
"sourceSnippetRange": {
"startLine": 188,
"startColumn": 28,
"endLine": 188,
"endColumn": 51
},
"snippet": "SUBSCRIBER_CUSTOMER_KEY"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/settings.py:82",
"range": {
"startLine": 82,
"startColumn": 22,
"endLine": 84,
"endColumn": 9
},
"name": "settings",
"expression": "(\n settings, \"DJSTRIPE_SUBSCRIBER_CUSTOMER_KEY\", \"djstripe_subscriber\"\n )",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "settings",
"ref": "__base_types__:15",
"definitionRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 28
},
"language": "python",
"snippet": "settings: LazySettings = ...",
"nameRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 8
}
}
}
]
},
{
"type": "function",
"filePath": "djstripe/utils.py",
"name": "clear_expired_idempotency_keys",
"ref": "djstripe/utils.py:31",
"definitionRange": {
"startLine": 31,
"startColumn": 0,
"endLine": 35,
"endColumn": 65
},
"language": "python",
"snippet": "def clear_expired_idempotency_keys():\n from .models import IdempotencyKey\n\n threshold = timezone.now() - datetime.timedelta(hours=24)\n IdempotencyKey.objects.filter(created__lt=threshold).delete()",
"nameRange": {
"startLine": 31,
"startColumn": 4,
"endLine": 31,
"endColumn": 34
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_clear_expired_idempotency_keys.py:2",
"targetRef": "djstripe/utils.py:31",
"sourceSnippetRange": {
"startLine": 2,
"startColumn": 21,
"endLine": 2,
"endColumn": 51
},
"snippet": "clear_expired_idempotency_keys"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_clear_expired_idempotency_keys.py:9",
"targetRef": "djstripe/utils.py:31",
"sourceSnippetRange": {
"startLine": 9,
"startColumn": 8,
"endLine": 9,
"endColumn": 38
},
"snippet": "clear_expired_idempotency_keys"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_idempotency_keys.py:7",
"targetRef": "djstripe/utils.py:31",
"sourceSnippetRange": {
"startLine": 7,
"startColumn": 27,
"endLine": 7,
"endColumn": 57
},
"snippet": "clear_expired_idempotency_keys"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_idempotency_keys.py:41",
"targetRef": "djstripe/utils.py:31",
"sourceSnippetRange": {
"startLine": 41,
"startColumn": 8,
"endLine": 41,
"endColumn": 38
},
"snippet": "clear_expired_idempotency_keys"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/utils.py:34",
"range": {
"startLine": 34,
"startColumn": 16,
"endLine": 34,
"endColumn": 30
},
"name": "now",
"expression": "timezone.now()",
"definition": {
"type": "function",
"filePath": "__base_types__",
"name": "now",
"ref": "__base_types__:66",
"definitionRange": {
"startLine": 66,
"startColumn": 0,
"endLine": 66,
"endColumn": 26
},
"language": "python",
"snippet": "def now() -> datetime: ...",
"nameRange": {
"startLine": 66,
"startColumn": 4,
"endLine": 66,
"endColumn": 7
}
}
},
{
"type": "variable",
"ref": "djstripe/utils.py:34",
"range": {
"startLine": 34,
"startColumn": 16,
"endLine": 34,
"endColumn": 28
},
"name": "timezone",
"expression": "timezone.now",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "types",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 12
},
"language": "python",
"snippet": "import types",
"nameRange": {
"startLine": 0,
"startColumn": 7,
"endLine": 0,
"endColumn": 12
}
}
},
{
"type": "call",
"ref": "djstripe/utils.py:34",
"range": {
"startLine": 34,
"startColumn": 33,
"endLine": 34,
"endColumn": 61
},
"name": "timedelta",
"expression": "datetime.timedelta(hours=24)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "timedelta",
"ref": "__base_types__:472",
"definitionRange": {
"startLine": 472,
"startColumn": 0,
"endLine": 785,
"endColumn": 49
},
"language": "python",
"snippet": "class timedelta:\n \"\"\"Represent the difference between two datetime objects.\n\n Supported operators:\n\n - add, subtract timedelta\n - unary plus, minus, abs\n - compare to timedelta\n - multiply, divide by int\n\n In addition, datetime supports subtraction of two datetime objects\n returning a timedelta, and addition or subtraction of a datetime\n and a timedelta giving a datetime.\n\n Representation: (days, seconds, microseconds). Why? Because I\n felt like it.\n \"\"\"\n __slots__ = '_days', '_seconds', '_microseconds', '_hashcode'\n\n def __new__(cls, days=0, seconds=0, microseconds=0,\n milliseconds=0, minutes=0, hours=0, weeks=0):\n # Doing this efficiently and accurately in C is going to be difficult\n # and error-prone, due to ubiquitous overflow possibilities, and that\n # C double doesn't have enough bits of precision to represent\n # microseconds over 10K years faithfully. The code here tries to make\n # explicit where go-fast assumptions can be relied on, in order to\n # guide the C implementation; it's way more convoluted than speed-\n # ignoring auto-overflow-to-long idiomatic Python could be.\n\n # XXX Check that all inputs are ints or floats.\n\n # Final values, all integer.\n # s and us fit in 32-bit signed ints; d isn't bounded.\n d = s = us = 0\n\n # Normalize everything to days, seconds, microseconds.\n days += weeks*7\n seconds += minutes*60 + hours*3600\n microseconds += milliseconds*1000\n\n # Get rid of all fractions, and normalize s and us.\n # Take a deep breath <wink>.\n if isinstance(days, float):\n dayfrac, days = _math.modf(days)\n daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.))\n assert daysecondswhole == int(daysecondswhole) # can't overflow\n s = int(daysecondswhole)\n assert days == int(days)\n d = int(days)\n else:\n daysecondsfrac = 0.0\n d = days\n assert isinstance(daysecondsfrac, float)\n assert abs(daysecondsfrac) <= 1.0\n assert isinstance(d, int)\n assert abs(s) <= 24 * 3600\n # days isn't referenced again before redefinition\n\n if isinstance(seconds, float):\n secondsfrac, seconds = _math.modf(seconds)\n assert seconds == int(seconds)\n seconds = int(seconds)\n secondsfrac += daysecondsfrac\n assert abs(secondsfrac) <= 2.0\n else:\n secondsfrac = daysecondsfrac\n # daysecondsfrac isn't referenced again\n assert isinstance(secondsfrac, float)\n assert abs(secondsfrac) <= 2.0\n\n assert isinstance(seconds, int)\n days, seconds = divmod(seconds, 24*3600)\n d += days\n s += int(seconds) # can't overflow\n assert isinstance(s, int)\n assert abs(s) <= 2 * 24 * 3600\n # seconds isn't referenced again before redefinition\n\n usdouble = secondsfrac * 1e6\n assert abs(usdouble) < 2.1e6 # exact value not critical\n # secondsfrac isn't referenced again\n\n if isinstance(microseconds, float):\n microseconds = round(microseconds + usdouble)\n seconds, microseconds = divmod(microseconds, 1000000)\n days, seconds = divmod(seconds, 24*3600)\n d += days\n s += seconds\n else:\n microseconds = int(microseconds)\n seconds, microseconds = divmod(microseconds, 1000000)\n days, seconds = divmod(seconds, 24*3600)\n d += days\n s += seconds\n microseconds = round(microseconds + usdouble)\n assert isinstance(s, int)\n assert isinstance(microseconds, int)\n assert abs(s) <= 3 * 24 * 3600\n assert abs(microseconds) < 3.1e6\n\n # Just a little bit of carrying possible for microseconds and seconds.\n seconds, us = divmod(microseconds, 1000000)\n s += seconds\n days, s = divmod(s, 24*3600)\n d += days\n\n assert isinstance(d, int)\n assert isinstance(s, int) and 0 <= s < 24*3600\n assert isinstance(us, int) and 0 <= us < 1000000\n\n if abs(d) > 999999999:\n raise OverflowError(\"timedelta # of days is too large: %d\" % d)\n\n self = object.__new__(cls)\n self._days = d\n self._seconds = s\n self._microseconds = us\n self._hashcode = -1\n return self\n\n def __repr__(self):\n args = []\n if self._days:\n args.append(\"days=%d\" % self._days)\n if self._seconds:\n args.append(\"seconds=%d\" % self._seconds)\n if self._microseconds:\n args.append(\"microseconds=%d\" % self._microseconds)\n if not args:\n args.append('0')\n return \"%s.%s(%s)\" % (self.__class__.__module__,\n self.__class__.__qualname__,\n ', '.join(args))\n\n def __str__(self):\n mm, ss = divmod(self._seconds, 60)\n hh, mm = divmod(mm, 60)\n s = \"%d:%02d:%02d\" % (hh, mm, ss)\n if self._days:\n def plural(n):\n return n, abs(n) != 1 and \"s\" or \"\"\n s = (\"%d day%s, \" % plural(self._days)) + s\n if self._microseconds:\n s = s + \".%06d\" % self._microseconds\n return s\n\n def total_seconds(self):\n \"\"\"Total seconds in the duration.\"\"\"\n return ((self.days * 86400 + self.seconds) * 10**6 +\n self.microseconds) / 10**6\n\n # Read-only field accessors\n @property\n def days(self):\n \"\"\"days\"\"\"\n return self._days\n\n @property\n def seconds(self):\n \"\"\"seconds\"\"\"\n return self._seconds\n\n @property\n def microseconds(self):\n \"\"\"microseconds\"\"\"\n return self._microseconds\n\n def __add__(self, other):\n if isinstance(other, timedelta):\n # for CPython compatibility, we cannot use\n # our __class__ here, but need a real timedelta\n return timedelta(self._days + other._days,\n self._seconds + other._seconds,\n self._microseconds + other._microseconds)\n return NotImplemented\n\n __radd__ = __add__\n\n def __sub__(self, other):\n if isinstance(other, timedelta):\n # for CPython compatibility, we cannot use\n # our __class__ here, but need a real timedelta\n return timedelta(self._days - other._days,\n self._seconds - other._seconds,\n self._microseconds - other._microseconds)\n return NotImplemented\n\n def __rsub__(self, other):\n if isinstance(other, timedelta):\n return -self + other\n return NotImplemented\n\n def __neg__(self):\n # for CPython compatibility, we cannot use\n # our __class__ here, but need a real timedelta\n return timedelta(-self._days,\n -self._seconds,\n -self._microseconds)\n\n def __pos__(self):\n return self\n\n def __abs__(self):\n if self._days < 0:\n return -self\n else:\n return self\n\n def __mul__(self, other):\n if isinstance(other, int):\n # for CPython compatibility, we cannot use\n # our __class__ here, but need a real timedelta\n return timedelta(self._days * other,\n self._seconds * other,\n self._microseconds * other)\n if isinstance(other, float):\n usec = self._to_microseconds()\n a, b = other.as_integer_ratio()\n return timedelta(0, 0, _divide_and_round(usec * a, b))\n return NotImplemented\n\n __rmul__ = __mul__\n\n def _to_microseconds(self):\n return ((self._days * (24*3600) + self._seconds) * 1000000 +\n self._microseconds)\n\n def __floordiv__(self, other):\n if not isinstance(other, (int, timedelta)):\n return NotImplemented\n usec = self._to_microseconds()\n if isinstance(other, timedelta):\n return usec // other._to_microseconds()\n if isinstance(other, int):\n return timedelta(0, 0, usec // other)\n\n def __truediv__(self, other):\n if not isinstance(other, (int, float, timedelta)):\n return NotImplemented\n usec = self._to_microseconds()\n if isinstance(other, timedelta):\n return usec / other._to_microseconds()\n if isinstance(other, int):\n return timedelta(0, 0, _divide_and_round(usec, other))\n if isinstance(other, float):\n a, b = other.as_integer_ratio()\n return timedelta(0, 0, _divide_and_round(b * usec, a))\n\n def __mod__(self, other):\n if isinstance(other, timedelta):\n r = self._to_microseconds() % other._to_microseconds()\n return timedelta(0, 0, r)\n return NotImplemented\n\n def __divmod__(self, other):\n if isinstance(other, timedelta):\n q, r = divmod(self._to_microseconds(),\n other._to_microseconds())\n return q, timedelta(0, 0, r)\n return NotImplemented\n\n # Comparisons of timedelta objects with other.\n\n def __eq__(self, other):\n if isinstance(other, timedelta):\n return self._cmp(other) == 0\n else:\n return NotImplemented\n\n def __le__(self, other):\n if isinstance(other, timedelta):\n return self._cmp(other) <= 0\n else:\n return NotImplemented\n\n def __lt__(self, other):\n if isinstance(other, timedelta):\n return self._cmp(other) < 0\n else:\n return NotImplemented\n\n def __ge__(self, other):\n if isinstance(other, timedelta):\n return self._cmp(other) >= 0\n else:\n return NotImplemented\n\n def __gt__(self, other):\n if isinstance(other, timedelta):\n return self._cmp(other) > 0\n else:\n return NotImplemented\n\n def _cmp(self, other):\n assert isinstance(other, timedelta)\n return _cmp(self._getstate(), other._getstate())\n\n def __hash__(self):\n if self._hashcode == -1:\n self._hashcode = hash(self._getstate())\n return self._hashcode\n\n def __bool__(self):\n return (self._days != 0 or\n self._seconds != 0 or\n self._microseconds != 0)\n\n # Pickle support.\n\n def _getstate(self):\n return (self._days, self._seconds, self._microseconds)\n\n def __reduce__(self):\n return (self.__class__, self._getstate())",
"nameRange": {
"startLine": 472,
"startColumn": 6,
"endLine": 472,
"endColumn": 15
}
}
},
{
"type": "variable",
"ref": "djstripe/utils.py:35",
"range": {
"startLine": 35,
"startColumn": 4,
"endLine": 35,
"endColumn": 26
},
"name": "IdempotencyKey",
"expression": "IdempotencyKey.objects",
"definition": {
"type": "class",
"filePath": "djstripe/models/base.py",
"name": "IdempotencyKey",
"ref": "djstripe/models/base.py:1123",
"definitionRange": {
"startLine": 1123,
"startColumn": 0,
"endLine": 1141,
"endColumn": 66
},
"language": "python",
"snippet": "class IdempotencyKey(models.Model):\n uuid = models.UUIDField(\n max_length=36, primary_key=True, editable=False, default=uuid.uuid4\n )\n action = models.CharField(max_length=100)\n livemode = models.BooleanField(\n help_text=\"Whether the key was used in live or test mode.\"\n )\n created = models.DateTimeField(auto_now_add=True)\n\n class Meta:\n unique_together = (\"action\", \"livemode\")\n\n def __str__(self):\n return str(self.uuid)\n\n @property\n def is_expired(self) -> bool:\n return timezone.now() > self.created + timedelta(hours=24)",
"nameRange": {
"startLine": 1123,
"startColumn": 6,
"endLine": 1123,
"endColumn": 20
}
}
},
{
"type": "call",
"ref": "djstripe/utils.py:35",
"range": {
"startLine": 35,
"startColumn": 4,
"endLine": 35,
"endColumn": 65
},
"name": "delete",
"expression": "IdempotencyKey.objects.filter(created__lt=threshold).delete()",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "delete",
"ref": "__base_types__:101",
"definitionRange": {
"startLine": 101,
"startColumn": 4,
"endLine": 101,
"endColumn": 55
},
"language": "python",
"snippet": "def delete(self) -> tuple[int, dict[str, int]]: ...",
"nameRange": {
"startLine": 101,
"startColumn": 8,
"endLine": 101,
"endColumn": 14
}
}
}
]
},
{
"type": "function",
"filePath": "djstripe/utils.py",
"name": "get_friendly_currency_amount",
"ref": "djstripe/utils.py:56",
"definitionRange": {
"startLine": 56,
"startColumn": 0,
"endLine": 60,
"endColumn": 63
},
"language": "python",
"snippet": "def get_friendly_currency_amount(amount, currency: str) -> str:\n currency = currency.upper()\n sigil = CURRENCY_SIGILS.get(currency, \"\")\n amount_two_decimals = f\"{amount:.2f}\"\n return f\"{sigil}{intcomma(amount_two_decimals)} {currency}\"",
"nameRange": {
"startLine": 56,
"startColumn": 4,
"endLine": 56,
"endColumn": 32
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:26",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 26,
"startColumn": 34,
"endLine": 26,
"endColumn": 62
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:190",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 190,
"startColumn": 21,
"endLine": 190,
"endColumn": 49
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:725",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 725,
"startColumn": 17,
"endLine": 725,
"endColumn": 45
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1482",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 1482,
"startColumn": 21,
"endLine": 1482,
"endColumn": 49
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1487",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 1487,
"startColumn": 43,
"endLine": 1487,
"endColumn": 71
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1494",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 1494,
"startColumn": 47,
"endLine": 1494,
"endColumn": 75
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2103",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 2103,
"startColumn": 17,
"endLine": 2103,
"endColumn": 45
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:3",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 3,
"startColumn": 27,
"endLine": 3,
"endColumn": 55
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:185",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 185,
"startColumn": 17,
"endLine": 185,
"endColumn": 45
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:28",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 28,
"startColumn": 20,
"endLine": 28,
"endColumn": 48
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:90",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 90,
"startColumn": 17,
"endLine": 90,
"endColumn": 45
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:391",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 391,
"startColumn": 17,
"endLine": 391,
"endColumn": 45
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1486",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 1486,
"startColumn": 17,
"endLine": 1486,
"endColumn": 45
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1920",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 1920,
"startColumn": 17,
"endLine": 1920,
"endColumn": 45
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:2376",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 2376,
"startColumn": 21,
"endLine": 2376,
"endColumn": 49
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:2380",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 2380,
"startColumn": 43,
"endLine": 2380,
"endColumn": 71
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:2388",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 2388,
"startColumn": 47,
"endLine": 2388,
"endColumn": 75
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:2492",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 2492,
"startColumn": 17,
"endLine": 2492,
"endColumn": 45
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:15",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 15,
"startColumn": 4,
"endLine": 15,
"endColumn": 32
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:69",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 69,
"startColumn": 12,
"endLine": 69,
"endColumn": 40
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:72",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 72,
"startColumn": 12,
"endLine": 72,
"endColumn": 40
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:75",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 75,
"startColumn": 12,
"endLine": 75,
"endColumn": 40
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:78",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 78,
"startColumn": 12,
"endLine": 78,
"endColumn": 40
},
"snippet": "get_friendly_currency_amount"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:81",
"targetRef": "djstripe/utils.py:56",
"sourceSnippetRange": {
"startLine": 81,
"startColumn": 12,
"endLine": 81,
"endColumn": 40
},
"snippet": "get_friendly_currency_amount"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/utils.py:57",
"range": {
"startLine": 57,
"startColumn": 15,
"endLine": 57,
"endColumn": 31
},
"name": "upper",
"expression": "currency.upper()",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "upper",
"ref": "__base_types__:553",
"definitionRange": {
"startLine": 553,
"startColumn": 4,
"endLine": 553,
"endColumn": 56
},
"language": "python",
"snippet": "def upper(self: LiteralString) -> LiteralString: ...",
"nameRange": {
"startLine": 553,
"startColumn": 8,
"endLine": 553,
"endColumn": 13
}
}
},
{
"type": "call",
"ref": "djstripe/utils.py:58",
"range": {
"startLine": 58,
"startColumn": 12,
"endLine": 58,
"endColumn": 45
},
"name": "get",
"expression": "CURRENCY_SIGILS.get(currency, \"\")",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "get",
"ref": "__base_types__:1064",
"definitionRange": {
"startLine": 1064,
"startColumn": 4,
"endLine": 1064,
"endColumn": 49
},
"language": "python",
"snippet": "def get(self, key: _KT, /) -> _VT | None: ...",
"nameRange": {
"startLine": 1064,
"startColumn": 8,
"endLine": 1064,
"endColumn": 11
}
}
},
{
"type": "variable",
"ref": "djstripe/utils.py:58",
"range": {
"startLine": 58,
"startColumn": 12,
"endLine": 58,
"endColumn": 31
},
"name": "CURRENCY_SIGILS",
"expression": "CURRENCY_SIGILS.get",
"definition": {
"type": "expression",
"filePath": "djstripe/utils.py",
"name": "CURRENCY_SIGILS",
"ref": "djstripe/utils.py:53",
"definitionRange": {
"startLine": 53,
"startColumn": 0,
"endLine": 53,
"endColumn": 66
},
"language": "python",
"snippet": "CURRENCY_SIGILS = {\"CAD\": \"$\", \"EUR\": \"€\", \"GBP\": \"£\", \"USD\": \"$\"}",
"nameRange": {
"startLine": 53,
"startColumn": 0,
"endLine": 53,
"endColumn": 15
}
}
},
{
"type": "call",
"ref": "djstripe/utils.py:60",
"range": {
"startLine": 60,
"startColumn": 21,
"endLine": 60,
"endColumn": 50
},
"name": "intcomma",
"expression": "intcomma(amount_two_decimals)",
"definition": {
"type": "function",
"filePath": "__base_types__",
"name": "intcomma",
"ref": "__base_types__:10",
"definitionRange": {
"startLine": 10,
"startColumn": 0,
"endLine": 10,
"endColumn": 79
},
"language": "python",
"snippet": "def intcomma(value: str | SupportsInt | None, use_l10n: bool = ...) -> str: ...",
"nameRange": {
"startLine": 10,
"startColumn": 4,
"endLine": 10,
"endColumn": 12
}
}
}
]
},
{
"type": "class",
"filePath": "djstripe/apps.py",
"name": "DjstripeAppConfig",
"ref": "djstripe/apps.py:11",
"definitionRange": {
"startLine": 11,
"startColumn": 0,
"endLine": 31,
"endColumn": 9
},
"language": "python",
"snippet": "class DjstripeAppConfig(AppConfig):\n \"\"\"\n An AppConfig for dj-stripe which loads system checks\n and event handlers once Django is ready.\n \"\"\"\n\n name = \"djstripe\"\n default_auto_field = \"django.db.models.AutoField\"\n\n def ready(self):\n import stripe\n\n from . import checks, event_handlers # noqa (register event handlers)\n\n # Set app info\n # https://stripe.com/docs/building-plugins#setappinfo\n stripe.set_app_info(\n \"dj-stripe\",\n version=__version__,\n url=\"https://github.com/dj-stripe/dj-stripe\",\n )",
"nameRange": {
"startLine": 11,
"startColumn": 6,
"endLine": 11,
"endColumn": 23
},
"references": [
{
"targetRef": "djstripe/apps.py:11",
"sourceSnippetRange": {
"startLine": 11,
"startColumn": 0,
"endLine": 11,
"endColumn": 36
},
"sourceRef": "djstripe/apps.py:11",
"type": "from-search",
"snippet": "class DjstripeAppConfig(AppConfig):\n"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/apps.py:11",
"range": {
"startLine": 11,
"startColumn": 23,
"endLine": 11,
"endColumn": 34
},
"name": "AppConfig",
"expression": "(AppConfig)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "AppConfig",
"ref": "__base_types__:8",
"definitionRange": {
"startLine": 8,
"startColumn": 0,
"endLine": 25,
"endColumn": 32
},
"language": "python",
"snippet": "class AppConfig:\n name: str = ...\n module: Any | None = ...\n apps: Apps | None = ...\n label: str = ...\n verbose_name: str = ...\n path: str = ...\n models_module: str | None = ...\n models: dict[str, type[Model]] = ...\n def __init__(self, app_name: str, app_module: Any | None) -> None: ...\n @classmethod\n def create(cls, entry: str) -> AppConfig: ...\n def get_model(self, model_name: str, require_ready: bool = ...) -> type[Model]: ...\n def get_models(\n self, include_auto_created: bool = ..., include_swapped: bool = ...\n ) -> Iterator[type[Model]]: ...\n def import_models(self) -> None: ...\n def ready(self) -> None: ...",
"nameRange": {
"startLine": 8,
"startColumn": 6,
"endLine": 8,
"endColumn": 15
}
}
},
{
"type": "comment",
"ref": "djstripe/apps.py:12",
"range": {
"startLine": 12,
"startColumn": 4,
"endLine": 15,
"endColumn": 7
},
"expression": "\"\"\"\n An AppConfig for dj-stripe which loads system checks\n and event handlers once Django is ready.\n \"\"\""
},
{
"type": "comment",
"ref": "djstripe/apps.py:23",
"range": {
"startLine": 23,
"startColumn": 46,
"endLine": 23,
"endColumn": 78
},
"expression": "# noqa (register event handlers)"
},
{
"type": "comment",
"ref": "djstripe/apps.py:25",
"range": {
"startLine": 25,
"startColumn": 8,
"endLine": 25,
"endColumn": 22
},
"expression": "# Set app info"
},
{
"type": "comment",
"ref": "djstripe/apps.py:26",
"range": {
"startLine": 26,
"startColumn": 8,
"endLine": 26,
"endColumn": 61
},
"expression": "# https://stripe.com/docs/building-plugins#setappinfo"
},
{
"type": "call",
"ref": "djstripe/apps.py:27",
"range": {
"startLine": 27,
"startColumn": 8,
"endLine": 31,
"endColumn": 9
},
"name": "set_app_info",
"expression": "stripe.set_app_info(\n \"dj-stripe\",\n version=__version__,\n url=\"https://github.com/dj-stripe/dj-stripe\",\n )",
"definition": {
"type": "function",
"filePath": "__base_types__",
"name": "set_app_info",
"ref": "__base_types__:22",
"definitionRange": {
"startLine": 22,
"startColumn": 0,
"endLine": 24,
"endColumn": 14
},
"language": "python",
"snippet": "def set_app_info(\n name, partner_id: Incomplete | None = None, url: Incomplete | None = None, version: Incomplete | None = None\n) -> None: ...",
"nameRange": {
"startLine": 22,
"startColumn": 4,
"endLine": 22,
"endColumn": 16
}
}
},
{
"type": "variable",
"ref": "djstripe/apps.py:27",
"range": {
"startLine": 27,
"startColumn": 8,
"endLine": 27,
"endColumn": 27
},
"name": "stripe",
"expression": "stripe.set_app_info",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "Incomplete",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 32
},
"language": "python",
"snippet": "from _typeshed import Incomplete",
"nameRange": {
"startLine": 0,
"startColumn": 22,
"endLine": 0,
"endColumn": 32
}
}
},
{
"type": "variable",
"ref": "djstripe/apps.py:29",
"range": {
"startLine": 29,
"startColumn": 12,
"endLine": 29,
"endColumn": 31
},
"name": "__version__",
"expression": "version=__version__",
"definition": {
"type": "expression",
"filePath": "djstripe/apps.py",
"name": "__version__",
"ref": "djstripe/apps.py:8",
"definitionRange": {
"startLine": 8,
"startColumn": 0,
"endLine": 8,
"endColumn": 34
},
"language": "python",
"snippet": "__version__ = version(\"dj-stripe\")",
"nameRange": {
"startLine": 8,
"startColumn": 0,
"endLine": 8,
"endColumn": 11
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "TEST_API_KEY",
"ref": "djstripe/settings.py:87",
"definitionRange": {
"startLine": 87,
"startColumn": 4,
"endLine": 88,
"endColumn": 62
},
"language": "python",
"snippet": "def TEST_API_KEY(self):\n return getattr(settings, \"STRIPE_TEST_SECRET_KEY\", \"\")",
"nameRange": {
"startLine": 87,
"startColumn": 8,
"endLine": 87,
"endColumn": 20
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/checks.py:29",
"targetRef": "djstripe/settings.py:87",
"sourceSnippetRange": {
"startLine": 29,
"startColumn": 35,
"endLine": 29,
"endColumn": 47
},
"snippet": "TEST_API_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:106",
"targetRef": "djstripe/settings.py:87",
"sourceSnippetRange": {
"startLine": 106,
"startColumn": 69,
"endLine": 106,
"endColumn": 81
},
"snippet": "TEST_API_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:181",
"targetRef": "djstripe/settings.py:87",
"sourceSnippetRange": {
"startLine": 181,
"startColumn": 24,
"endLine": 181,
"endColumn": 36
},
"snippet": "TEST_API_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:81",
"targetRef": "djstripe/settings.py:87",
"sourceSnippetRange": {
"startLine": 81,
"startColumn": 43,
"endLine": 81,
"endColumn": 55
},
"snippet": "TEST_API_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:158",
"targetRef": "djstripe/settings.py:87",
"sourceSnippetRange": {
"startLine": 158,
"startColumn": 43,
"endLine": 158,
"endColumn": 55
},
"snippet": "TEST_API_KEY"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/settings.py:88",
"range": {
"startLine": 88,
"startColumn": 22,
"endLine": 88,
"endColumn": 62
},
"name": "settings",
"expression": "(settings, \"STRIPE_TEST_SECRET_KEY\", \"\")",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "settings",
"ref": "__base_types__:15",
"definitionRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 28
},
"language": "python",
"snippet": "settings: LazySettings = ...",
"nameRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 8
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "LIVE_API_KEY",
"ref": "djstripe/settings.py:91",
"definitionRange": {
"startLine": 91,
"startColumn": 4,
"endLine": 92,
"endColumn": 62
},
"language": "python",
"snippet": "def LIVE_API_KEY(self):\n return getattr(settings, \"STRIPE_LIVE_SECRET_KEY\", \"\")",
"nameRange": {
"startLine": 91,
"startColumn": 8,
"endLine": 91,
"endColumn": 20
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/checks.py:25",
"targetRef": "djstripe/settings.py:91",
"sourceSnippetRange": {
"startLine": 25,
"startColumn": 37,
"endLine": 25,
"endColumn": 49
},
"snippet": "LIVE_API_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:106",
"targetRef": "djstripe/settings.py:91",
"sourceSnippetRange": {
"startLine": 106,
"startColumn": 21,
"endLine": 106,
"endColumn": 33
},
"snippet": "LIVE_API_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:178",
"targetRef": "djstripe/settings.py:91",
"sourceSnippetRange": {
"startLine": 178,
"startColumn": 24,
"endLine": 178,
"endColumn": 36
},
"snippet": "LIVE_API_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:47",
"targetRef": "djstripe/settings.py:91",
"sourceSnippetRange": {
"startLine": 47,
"startColumn": 43,
"endLine": 47,
"endColumn": 55
},
"snippet": "LIVE_API_KEY"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/settings.py:92",
"range": {
"startLine": 92,
"startColumn": 22,
"endLine": 92,
"endColumn": 62
},
"name": "settings",
"expression": "(settings, \"STRIPE_LIVE_SECRET_KEY\", \"\")",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "settings",
"ref": "__base_types__:15",
"definitionRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 28
},
"language": "python",
"snippet": "settings: LazySettings = ...",
"nameRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 8
}
}
}
]
},
{
"type": "function",
"filePath": "djstripe/utils.py",
"name": "get_supported_currency_choices",
"ref": "djstripe/utils.py:15",
"definitionRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 28,
"endColumn": 86
},
"language": "python",
"snippet": "def get_supported_currency_choices(api_key):\n \"\"\"\n Pull a stripe account's supported currencies and returns a choices tuple of those\n supported currencies.\n\n :param api_key: The api key associated with the account from which to pull data.\n :type api_key: str\n \"\"\"\n account = stripe.Account.retrieve(api_key=api_key)\n supported_payment_currencies = stripe.CountrySpec.retrieve(\n account[\"country\"], api_key=api_key\n )[\"supported_payment_currencies\"]\n\n return [(currency, currency.upper()) for currency in supported_payment_currencies]",
"nameRange": {
"startLine": 15,
"startColumn": 4,
"endLine": 15,
"endColumn": 34
},
"references": [
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:16",
"targetRef": "djstripe/utils.py:15",
"sourceSnippetRange": {
"startLine": 16,
"startColumn": 4,
"endLine": 16,
"endColumn": 34
},
"snippet": "get_supported_currency_choices"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:54",
"targetRef": "djstripe/utils.py:15",
"sourceSnippetRange": {
"startLine": 54,
"startColumn": 27,
"endLine": 54,
"endColumn": 57
},
"snippet": "get_supported_currency_choices"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/utils.py:16",
"range": {
"startLine": 16,
"startColumn": 4,
"endLine": 22,
"endColumn": 7
},
"expression": "\"\"\"\n Pull a stripe account's supported currencies and returns a choices tuple of those\n supported currencies.\n\n :param api_key: The api key associated with the account from which to pull data.\n :type api_key: str\n \"\"\""
},
{
"type": "variable",
"ref": "djstripe/utils.py:23",
"range": {
"startLine": 23,
"startColumn": 14,
"endLine": 23,
"endColumn": 28
},
"name": "stripe",
"expression": "stripe.Account",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "Incomplete",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 32
},
"language": "python",
"snippet": "from _typeshed import Incomplete",
"nameRange": {
"startLine": 0,
"startColumn": 22,
"endLine": 0,
"endColumn": 32
}
}
},
{
"type": "call",
"ref": "djstripe/utils.py:23",
"range": {
"startLine": 23,
"startColumn": 14,
"endLine": 23,
"endColumn": 54
},
"name": "retrieve",
"expression": "stripe.Account.retrieve(api_key=api_key)",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "retrieve",
"ref": "__base_types__:16",
"definitionRange": {
"startLine": 16,
"startColumn": 4,
"endLine": 16,
"endColumn": 101
},
"language": "python",
"snippet": "def retrieve(cls, id: Incomplete | None = None, api_key: Incomplete | None = None, **params): ...",
"nameRange": {
"startLine": 16,
"startColumn": 8,
"endLine": 16,
"endColumn": 16
}
}
},
{
"type": "call",
"ref": "djstripe/utils.py:24",
"range": {
"startLine": 24,
"startColumn": 35,
"endLine": 26,
"endColumn": 5
},
"name": "retrieve",
"expression": "stripe.CountrySpec.retrieve(\n account[\"country\"], api_key=api_key\n )",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "retrieve",
"ref": "__base_types__:8",
"definitionRange": {
"startLine": 8,
"startColumn": 4,
"endLine": 8,
"endColumn": 83
},
"language": "python",
"snippet": "def retrieve(cls, id, api_key: Incomplete | None = None, **params) -> Self: ...",
"nameRange": {
"startLine": 8,
"startColumn": 8,
"endLine": 8,
"endColumn": 16
}
}
}
]
},
{
"type": "function",
"filePath": "djstripe/utils.py",
"name": "convert_tstamp",
"ref": "djstripe/utils.py:38",
"definitionRange": {
"startLine": 38,
"startColumn": 0,
"endLine": 49,
"endColumn": 56
},
"language": "python",
"snippet": "def convert_tstamp(response) -> Optional[datetime.datetime]:\n \"\"\"\n Convert a Stripe API timestamp response (unix epoch) to a native datetime.\n \"\"\"\n if response is None:\n # Allow passing None to convert_tstamp()\n return response\n\n # Overrides the set timezone to UTC - I think...\n tz = get_timezone_utc() if settings.USE_TZ else None\n\n return datetime.datetime.fromtimestamp(response, tz)",
"nameRange": {
"startLine": 38,
"startColumn": 4,
"endLine": 38,
"endColumn": 18
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/event_handlers.py:24",
"targetRef": "djstripe/utils.py:38",
"sourceSnippetRange": {
"startLine": 24,
"startColumn": 19,
"endLine": 24,
"endColumn": 33
},
"snippet": "convert_tstamp"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/event_handlers.py:163",
"targetRef": "djstripe/utils.py:38",
"sourceSnippetRange": {
"startLine": 163,
"startColumn": 28,
"endLine": 163,
"endColumn": 42
},
"snippet": "convert_tstamp"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/event_handlers.py:164",
"targetRef": "djstripe/utils.py:38",
"sourceSnippetRange": {
"startLine": 164,
"startColumn": 26,
"endLine": 164,
"endColumn": 40
},
"snippet": "convert_tstamp"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/fields.py:10",
"targetRef": "djstripe/utils.py:38",
"sourceSnippetRange": {
"startLine": 10,
"startColumn": 19,
"endLine": 10,
"endColumn": 33
},
"snippet": "convert_tstamp"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/fields.py:146",
"targetRef": "djstripe/utils.py:38",
"sourceSnippetRange": {
"startLine": 146,
"startColumn": 19,
"endLine": 146,
"endColumn": 33
},
"snippet": "convert_tstamp"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:14",
"targetRef": "djstripe/utils.py:38",
"sourceSnippetRange": {
"startLine": 14,
"startColumn": 4,
"endLine": 14,
"endColumn": 18
},
"snippet": "convert_tstamp"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:25",
"targetRef": "djstripe/utils.py:38",
"sourceSnippetRange": {
"startLine": 25,
"startColumn": 16,
"endLine": 25,
"endColumn": 30
},
"snippet": "convert_tstamp"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:36",
"targetRef": "djstripe/utils.py:38",
"sourceSnippetRange": {
"startLine": 36,
"startColumn": 16,
"endLine": 36,
"endColumn": 30
},
"snippet": "convert_tstamp"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/utils.py:39",
"range": {
"startLine": 39,
"startColumn": 4,
"endLine": 41,
"endColumn": 7
},
"expression": "\"\"\"\n Convert a Stripe API timestamp response (unix epoch) to a native datetime.\n \"\"\""
},
{
"type": "comment",
"ref": "djstripe/utils.py:43",
"range": {
"startLine": 43,
"startColumn": 8,
"endLine": 43,
"endColumn": 48
},
"expression": "# Allow passing None to convert_tstamp()"
},
{
"type": "comment",
"ref": "djstripe/utils.py:46",
"range": {
"startLine": 46,
"startColumn": 4,
"endLine": 46,
"endColumn": 52
},
"expression": "# Overrides the set timezone to UTC - I think..."
},
{
"type": "call",
"ref": "djstripe/utils.py:47",
"range": {
"startLine": 47,
"startColumn": 9,
"endLine": 47,
"endColumn": 27
},
"name": "get_timezone_utc",
"expression": "get_timezone_utc()",
"definition": {
"type": "function",
"filePath": "djstripe/utils.py",
"name": "get_timezone_utc",
"ref": "djstripe/utils.py:113",
"definitionRange": {
"startLine": 113,
"startColumn": 0,
"endLine": 124,
"endColumn": 27
},
"language": "python",
"snippet": "def get_timezone_utc():\n \"\"\"\n Returns UTC attribute in a backwards compatible way.\n\n UTC attribute has been moved from django.utils.timezone module to\n datetime.timezone class\n \"\"\"\n try:\n # Django 4+\n return datetime.timezone.utc\n except AttributeError:\n return timezone.utc",
"nameRange": {
"startLine": 113,
"startColumn": 4,
"endLine": 113,
"endColumn": 20
}
}
},
{
"type": "variable",
"ref": "djstripe/utils.py:47",
"range": {
"startLine": 47,
"startColumn": 31,
"endLine": 47,
"endColumn": 46
},
"name": "settings",
"expression": "settings.USE_TZ",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "__getattr__",
"ref": "__base_types__:9",
"definitionRange": {
"startLine": 9,
"startColumn": 4,
"endLine": 9,
"endColumn": 48
},
"language": "python",
"snippet": "def __getattr__(self, item: Any) -> Any: ...",
"nameRange": {
"startLine": 9,
"startColumn": 8,
"endLine": 9,
"endColumn": 19
}
}
},
{
"type": "call",
"ref": "djstripe/utils.py:49",
"range": {
"startLine": 49,
"startColumn": 11,
"endLine": 49,
"endColumn": 56
},
"name": "fromtimestamp",
"expression": "datetime.datetime.fromtimestamp(response, tz)",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "fromtimestamp",
"ref": "__base_types__:1711",
"definitionRange": {
"startLine": 1711,
"startColumn": 4,
"endLine": 1718,
"endColumn": 56
},
"language": "python",
"snippet": "def fromtimestamp(cls, t, tz=None):\n \"\"\"Construct a datetime from a POSIX timestamp (like time.time()).\n\n A timezone info object may be passed in as well.\n \"\"\"\n _check_tzinfo_arg(tz)\n\n return cls._fromtimestamp(t, tz is not None, tz)",
"nameRange": {
"startLine": 1711,
"startColumn": 8,
"endLine": 1711,
"endColumn": 21
}
}
}
]
},
{
"type": "class",
"filePath": "djstripe/utils.py",
"name": "QuerySetMock",
"ref": "djstripe/utils.py:63",
"definitionRange": {
"startLine": 63,
"startColumn": 0,
"endLine": 83,
"endColumn": 16
},
"language": "python",
"snippet": "class QuerySetMock(QuerySet):\n \"\"\"\n A mocked QuerySet class that does not handle updates.\n Used by UpcomingInvoice.invoiceitems (deprecated) and UpcomingInvoice.lineitems.\n \"\"\"\n\n @classmethod\n def from_iterable(cls, model, iterable):\n instance = cls(model)\n instance._result_cache = list(iterable)\n instance._prefetch_done = True\n return instance\n\n def _clone(self):\n return self.__class__.from_iterable(self.model, self._result_cache)\n\n def update(self):\n return 0\n\n def delete(self):\n return 0",
"nameRange": {
"startLine": 63,
"startColumn": 6,
"endLine": 63,
"endColumn": 18
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:26",
"targetRef": "djstripe/utils.py:63",
"sourceSnippetRange": {
"startLine": 26,
"startColumn": 20,
"endLine": 26,
"endColumn": 32
},
"snippet": "QuerySetMock"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1039",
"targetRef": "djstripe/utils.py:63",
"sourceSnippetRange": {
"startLine": 1039,
"startColumn": 15,
"endLine": 1039,
"endColumn": 27
},
"snippet": "QuerySetMock"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1054",
"targetRef": "djstripe/utils.py:63",
"sourceSnippetRange": {
"startLine": 1054,
"startColumn": 15,
"endLine": 1054,
"endColumn": 27
},
"snippet": "QuerySetMock"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1062",
"targetRef": "djstripe/utils.py:63",
"sourceSnippetRange": {
"startLine": 1062,
"startColumn": 15,
"endLine": 1062,
"endColumn": 27
},
"snippet": "QuerySetMock"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1070",
"targetRef": "djstripe/utils.py:63",
"sourceSnippetRange": {
"startLine": 1070,
"startColumn": 15,
"endLine": 1070,
"endColumn": 27
},
"snippet": "QuerySetMock"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/utils.py:63",
"range": {
"startLine": 63,
"startColumn": 18,
"endLine": 63,
"endColumn": 28
},
"name": "QuerySet",
"expression": "(QuerySet)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "QuerySet",
"ref": "__base_types__:179",
"definitionRange": {
"startLine": 179,
"startColumn": 0,
"endLine": 187,
"endColumn": 47
},
"language": "python",
"snippet": "class QuerySet(_BaseQuerySet[_T], Collection[_T], Reversible[_T], Sized):\n def __iter__(self) -> Iterator[_T]: ...\n def __aiter__(self) -> AsyncIterator[_T]: ...\n def __contains__(self, x: object) -> bool: ...\n @overload\n def __getitem__(self, i: int) -> _T: ...\n @overload\n def __getitem__(self, s: slice) -> Self: ...\n def __reversed__(self) -> Iterator[_T]: ...",
"nameRange": {
"startLine": 179,
"startColumn": 6,
"endLine": 179,
"endColumn": 14
}
}
},
{
"type": "comment",
"ref": "djstripe/utils.py:64",
"range": {
"startLine": 64,
"startColumn": 4,
"endLine": 67,
"endColumn": 7
},
"expression": "\"\"\"\n A mocked QuerySet class that does not handle updates.\n Used by UpcomingInvoice.invoiceitems (deprecated) and UpcomingInvoice.lineitems.\n \"\"\""
},
{
"type": "decorator",
"ref": "djstripe/utils.py:69",
"range": {
"startLine": 69,
"startColumn": 4,
"endLine": 69,
"endColumn": 16
},
"expression": "@classmethod"
},
{
"type": "call",
"ref": "djstripe/utils.py:71",
"range": {
"startLine": 71,
"startColumn": 19,
"endLine": 71,
"endColumn": 29
},
"name": "cls",
"expression": "cls(model)",
"definition": {
"type": "method",
"filePath": "djstripe/utils.py",
"name": "from_iterable",
"ref": "djstripe/utils.py:70",
"definitionRange": {
"startLine": 70,
"startColumn": 4,
"endLine": 74,
"endColumn": 23
},
"language": "python",
"snippet": "def from_iterable(cls, model, iterable):\n instance = cls(model)\n instance._result_cache = list(iterable)\n instance._prefetch_done = True\n return instance",
"nameRange": {
"startLine": 70,
"startColumn": 8,
"endLine": 70,
"endColumn": 21
}
}
},
{
"type": "variable",
"ref": "djstripe/utils.py:77",
"range": {
"startLine": 77,
"startColumn": 43,
"endLine": 77,
"endColumn": 75
},
"name": "model",
"expression": "(self.model, self._result_cache)",
"definition": {
"type": "class_property",
"filePath": "__base_types__",
"name": "model",
"ref": "__base_types__:25",
"definitionRange": {
"startLine": 25,
"startColumn": 4,
"endLine": 25,
"endColumn": 19
},
"language": "python",
"snippet": "model: type[_T]",
"nameRange": {
"startLine": 25,
"startColumn": 4,
"endLine": 25,
"endColumn": 9
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "STRIPE_LIVE_MODE",
"ref": "djstripe/settings.py:96",
"definitionRange": {
"startLine": 96,
"startColumn": 4,
"endLine": 97,
"endColumn": 59
},
"language": "python",
"snippet": "def STRIPE_LIVE_MODE(self):\n return getattr(settings, \"STRIPE_LIVE_MODE\", False)",
"nameRange": {
"startLine": 96,
"startColumn": 8,
"endLine": 96,
"endColumn": 24
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/checks.py:24",
"targetRef": "djstripe/settings.py:96",
"sourceSnippetRange": {
"startLine": 24,
"startColumn": 29,
"endLine": 24,
"endColumn": 45
},
"snippet": "STRIPE_LIVE_MODE"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:128",
"targetRef": "djstripe/settings.py:96",
"sourceSnippetRange": {
"startLine": 128,
"startColumn": 33,
"endLine": 128,
"endColumn": 49
},
"snippet": "STRIPE_LIVE_MODE"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:868",
"targetRef": "djstripe/settings.py:96",
"sourceSnippetRange": {
"startLine": 868,
"startColumn": 35,
"endLine": 868,
"endColumn": 51
},
"snippet": "STRIPE_LIVE_MODE"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:106",
"targetRef": "djstripe/settings.py:96",
"sourceSnippetRange": {
"startLine": 106,
"startColumn": 42,
"endLine": 106,
"endColumn": 58
},
"snippet": "STRIPE_LIVE_MODE"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:115",
"targetRef": "djstripe/settings.py:96",
"sourceSnippetRange": {
"startLine": 115,
"startColumn": 18,
"endLine": 115,
"endColumn": 34
},
"snippet": "STRIPE_LIVE_MODE"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:45",
"targetRef": "djstripe/settings.py:96",
"sourceSnippetRange": {
"startLine": 45,
"startColumn": 43,
"endLine": 45,
"endColumn": 59
},
"snippet": "STRIPE_LIVE_MODE"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:79",
"targetRef": "djstripe/settings.py:96",
"sourceSnippetRange": {
"startLine": 79,
"startColumn": 43,
"endLine": 79,
"endColumn": 59
},
"snippet": "STRIPE_LIVE_MODE"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:117",
"targetRef": "djstripe/settings.py:96",
"sourceSnippetRange": {
"startLine": 117,
"startColumn": 43,
"endLine": 117,
"endColumn": 59
},
"snippet": "STRIPE_LIVE_MODE"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:155",
"targetRef": "djstripe/settings.py:96",
"sourceSnippetRange": {
"startLine": 155,
"startColumn": 43,
"endLine": 155,
"endColumn": 59
},
"snippet": "STRIPE_LIVE_MODE"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/settings.py:97",
"range": {
"startLine": 97,
"startColumn": 22,
"endLine": 97,
"endColumn": 59
},
"name": "settings",
"expression": "(settings, \"STRIPE_LIVE_MODE\", False)",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "settings",
"ref": "__base_types__:15",
"definitionRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 28
},
"language": "python",
"snippet": "settings: LazySettings = ...",
"nameRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 8
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/managers.py",
"name": "started_plan_summary_for",
"ref": "djstripe/managers.py:36",
"definitionRange": {
"startLine": 36,
"startColumn": 4,
"endLine": 43,
"endColumn": 9
},
"language": "python",
"snippet": "def started_plan_summary_for(self, year, month):\n \"\"\"Return started_during Subscriptions with plan counts annotated.\"\"\"\n return (\n self.started_during(year, month)\n .values(\"plan\")\n .order_by()\n .annotate(count=models.Count(\"plan\"))\n )",
"nameRange": {
"startLine": 36,
"startColumn": 8,
"endLine": 36,
"endColumn": 32
},
"references": [
{
"targetRef": "djstripe/managers.py:36",
"sourceSnippetRange": {
"startLine": 36,
"startColumn": 0,
"endLine": 36,
"endColumn": 53
},
"sourceRef": "djstripe/managers.py:36",
"type": "from-search",
"snippet": " def started_plan_summary_for(self, year, month):\n"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/managers.py:37",
"range": {
"startLine": 37,
"startColumn": 8,
"endLine": 37,
"endColumn": 77
},
"expression": "\"\"\"Return started_during Subscriptions with plan counts annotated.\"\"\""
},
{
"type": "call",
"ref": "djstripe/managers.py:39",
"range": {
"startLine": 39,
"startColumn": 12,
"endLine": 39,
"endColumn": 44
},
"name": "started_during",
"expression": "self.started_during(year, month)",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "started_during",
"ref": "djstripe/managers.py:18",
"definitionRange": {
"startLine": 18,
"startColumn": 4,
"endLine": 22,
"endColumn": 9
},
"language": "python",
"snippet": "def started_during(self, year, month):\n \"\"\"Return Subscriptions not in trial status between a certain time range.\"\"\"\n return self.exclude(status=\"trialing\").filter(\n start_date__year=year, start_date__month=month\n )",
"nameRange": {
"startLine": 18,
"startColumn": 8,
"endLine": 18,
"endColumn": 22
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:39",
"range": {
"startLine": 39,
"startColumn": 12,
"endLine": 40,
"endColumn": 27
},
"name": "values",
"expression": "self.started_during(year, month)\n .values(\"plan\")",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "values",
"ref": "__base_types__:119",
"definitionRange": {
"startLine": 119,
"startColumn": 4,
"endLine": 121,
"endColumn": 48
},
"language": "python",
"snippet": "def values(\n self, *fields: str | Combinable, **expressions: Any\n ) -> ValuesQuerySet[_T, dict[str, Any]]: ...",
"nameRange": {
"startLine": 119,
"startColumn": 8,
"endLine": 119,
"endColumn": 14
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:39",
"range": {
"startLine": 39,
"startColumn": 12,
"endLine": 41,
"endColumn": 23
},
"name": "order_by",
"expression": "self.started_during(year, month)\n .values(\"plan\")\n .order_by()",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "order_by",
"ref": "__base_types__:157",
"definitionRange": {
"startLine": 157,
"startColumn": 4,
"endLine": 157,
"endColumn": 54
},
"language": "python",
"snippet": "def order_by(self, *field_names: Any) -> Self: ...",
"nameRange": {
"startLine": 157,
"startColumn": 8,
"endLine": 157,
"endColumn": 16
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:39",
"range": {
"startLine": 39,
"startColumn": 12,
"endLine": 42,
"endColumn": 49
},
"name": "annotate",
"expression": "self.started_during(year, month)\n .values(\"plan\")\n .order_by()\n .annotate(count=models.Count(\"plan\"))",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "annotate",
"ref": "__base_types__:155",
"definitionRange": {
"startLine": 155,
"startColumn": 4,
"endLine": 155,
"endColumn": 62
},
"language": "python",
"snippet": "def annotate(self, *args: Any, **kwargs: Any) -> Self: ...",
"nameRange": {
"startLine": 155,
"startColumn": 8,
"endLine": 155,
"endColumn": 16
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:42",
"range": {
"startLine": 42,
"startColumn": 28,
"endLine": 42,
"endColumn": 48
},
"name": "Count",
"expression": "models.Count(\"plan\")",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Count",
"ref": "__base_types__:17",
"definitionRange": {
"startLine": 17,
"startColumn": 0,
"endLine": 17,
"endColumn": 27
},
"language": "python",
"snippet": "class Count(Aggregate): ...",
"nameRange": {
"startLine": 17,
"startColumn": 6,
"endLine": 17,
"endColumn": 11
}
}
},
{
"type": "variable",
"ref": "djstripe/managers.py:42",
"range": {
"startLine": 42,
"startColumn": 28,
"endLine": 42,
"endColumn": 40
},
"name": "models",
"expression": "models.Count",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/managers.py",
"name": "active_plan_summary",
"ref": "djstripe/managers.py:45",
"definitionRange": {
"startLine": 45,
"startColumn": 4,
"endLine": 49,
"endColumn": 9
},
"language": "python",
"snippet": "def active_plan_summary(self):\n \"\"\"Return active Subscriptions with plan counts annotated.\"\"\"\n return (\n self.active().values(\"plan\").order_by().annotate(count=models.Count(\"plan\"))\n )",
"nameRange": {
"startLine": 45,
"startColumn": 8,
"endLine": 45,
"endColumn": 27
},
"references": [
{
"targetRef": "djstripe/managers.py:45",
"sourceSnippetRange": {
"startLine": 45,
"startColumn": 0,
"endLine": 45,
"endColumn": 35
},
"sourceRef": "djstripe/managers.py:45",
"type": "from-search",
"snippet": " def active_plan_summary(self):\n"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/managers.py:46",
"range": {
"startLine": 46,
"startColumn": 8,
"endLine": 46,
"endColumn": 69
},
"expression": "\"\"\"Return active Subscriptions with plan counts annotated.\"\"\""
},
{
"type": "call",
"ref": "djstripe/managers.py:48",
"range": {
"startLine": 48,
"startColumn": 12,
"endLine": 48,
"endColumn": 25
},
"name": "active",
"expression": "self.active()",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "active",
"ref": "djstripe/managers.py:24",
"definitionRange": {
"startLine": 24,
"startColumn": 4,
"endLine": 26,
"endColumn": 43
},
"language": "python",
"snippet": "def active(self):\n \"\"\"Return active Subscriptions.\"\"\"\n return self.filter(status=\"active\")",
"nameRange": {
"startLine": 24,
"startColumn": 8,
"endLine": 24,
"endColumn": 14
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:48",
"range": {
"startLine": 48,
"startColumn": 12,
"endLine": 48,
"endColumn": 40
},
"name": "values",
"expression": "self.active().values(\"plan\")",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "values",
"ref": "__base_types__:119",
"definitionRange": {
"startLine": 119,
"startColumn": 4,
"endLine": 121,
"endColumn": 48
},
"language": "python",
"snippet": "def values(\n self, *fields: str | Combinable, **expressions: Any\n ) -> ValuesQuerySet[_T, dict[str, Any]]: ...",
"nameRange": {
"startLine": 119,
"startColumn": 8,
"endLine": 119,
"endColumn": 14
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:48",
"range": {
"startLine": 48,
"startColumn": 12,
"endLine": 48,
"endColumn": 51
},
"name": "order_by",
"expression": "self.active().values(\"plan\").order_by()",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "order_by",
"ref": "__base_types__:157",
"definitionRange": {
"startLine": 157,
"startColumn": 4,
"endLine": 157,
"endColumn": 54
},
"language": "python",
"snippet": "def order_by(self, *field_names: Any) -> Self: ...",
"nameRange": {
"startLine": 157,
"startColumn": 8,
"endLine": 157,
"endColumn": 16
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:48",
"range": {
"startLine": 48,
"startColumn": 12,
"endLine": 48,
"endColumn": 88
},
"name": "annotate",
"expression": "self.active().values(\"plan\").order_by().annotate(count=models.Count(\"plan\"))",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "annotate",
"ref": "__base_types__:155",
"definitionRange": {
"startLine": 155,
"startColumn": 4,
"endLine": 155,
"endColumn": 62
},
"language": "python",
"snippet": "def annotate(self, *args: Any, **kwargs: Any) -> Self: ...",
"nameRange": {
"startLine": 155,
"startColumn": 8,
"endLine": 155,
"endColumn": 16
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:48",
"range": {
"startLine": 48,
"startColumn": 67,
"endLine": 48,
"endColumn": 87
},
"name": "Count",
"expression": "models.Count(\"plan\")",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Count",
"ref": "__base_types__:17",
"definitionRange": {
"startLine": 17,
"startColumn": 0,
"endLine": 17,
"endColumn": 27
},
"language": "python",
"snippet": "class Count(Aggregate): ...",
"nameRange": {
"startLine": 17,
"startColumn": 6,
"endLine": 17,
"endColumn": 11
}
}
},
{
"type": "variable",
"ref": "djstripe/managers.py:48",
"range": {
"startLine": 48,
"startColumn": 67,
"endLine": 48,
"endColumn": 79
},
"name": "models",
"expression": "models.Count",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/utils.py",
"name": "update",
"ref": "djstripe/utils.py:79",
"definitionRange": {
"startLine": 79,
"startColumn": 4,
"endLine": 80,
"endColumn": 16
},
"language": "python",
"snippet": "def update(self):\n return 0",
"nameRange": {
"startLine": 79,
"startColumn": 8,
"endLine": 79,
"endColumn": 14
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:285",
"targetRef": "djstripe/utils.py:79",
"sourceSnippetRange": {
"startLine": 285,
"startColumn": 56,
"endLine": 285,
"endColumn": 62
},
"snippet": "update"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:706",
"targetRef": "djstripe/utils.py:79",
"sourceSnippetRange": {
"startLine": 706,
"startColumn": 56,
"endLine": 706,
"endColumn": 62
},
"snippet": "update"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1512",
"targetRef": "djstripe/utils.py:79",
"sourceSnippetRange": {
"startLine": 1512,
"startColumn": 43,
"endLine": 1512,
"endColumn": 49
},
"snippet": "update"
}
],
"expressions": []
},
{
"type": "method",
"filePath": "djstripe/utils.py",
"name": "delete",
"ref": "djstripe/utils.py:82",
"definitionRange": {
"startLine": 82,
"startColumn": 4,
"endLine": 83,
"endColumn": 16
},
"language": "python",
"snippet": "def delete(self):\n return 0",
"nameRange": {
"startLine": 82,
"startColumn": 8,
"endLine": 82,
"endColumn": 14
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1167",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 1167,
"startColumn": 73,
"endLine": 1167,
"endColumn": 79
},
"snippet": "delete"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/utils.py:35",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 35,
"startColumn": 57,
"endLine": 35,
"endColumn": 63
},
"snippet": "delete"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:486",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 486,
"startColumn": 76,
"endLine": 486,
"endColumn": 82
},
"snippet": "delete"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:516",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 516,
"startColumn": 65,
"endLine": 516,
"endColumn": 71
},
"snippet": "delete"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:406",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 406,
"startColumn": 61,
"endLine": 406,
"endColumn": 67
},
"snippet": "delete"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:442",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 442,
"startColumn": 50,
"endLine": 442,
"endColumn": 56
},
"snippet": "delete"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:321",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 321,
"startColumn": 31,
"endLine": 321,
"endColumn": 37
},
"snippet": "delete"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:322",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 322,
"startColumn": 27,
"endLine": 322,
"endColumn": 33
},
"snippet": "delete"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:349",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 349,
"startColumn": 31,
"endLine": 349,
"endColumn": 37
},
"snippet": "delete"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:350",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 350,
"startColumn": 36,
"endLine": 350,
"endColumn": 42
},
"snippet": "delete"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:381",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 381,
"startColumn": 31,
"endLine": 381,
"endColumn": 37
},
"snippet": "delete"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:382",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 382,
"startColumn": 36,
"endLine": 382,
"endColumn": 42
},
"snippet": "delete"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1513",
"targetRef": "djstripe/utils.py:82",
"sourceSnippetRange": {
"startLine": 1513,
"startColumn": 43,
"endLine": 1513,
"endColumn": 49
},
"snippet": "delete"
}
],
"expressions": []
},
{
"type": "class_property",
"filePath": "djstripe/models/account.py",
"name": "stripe_class",
"ref": "djstripe/models/account.py:19",
"definitionRange": {
"startLine": 19,
"startColumn": 4,
"endLine": 19,
"endColumn": 33
},
"language": "python",
"snippet": "stripe_class = stripe.Account",
"nameRange": {
"startLine": 19,
"startColumn": 4,
"endLine": 19,
"endColumn": 16
},
"references": [
{
"targetRef": "djstripe/models/account.py:19",
"sourceSnippetRange": {
"startLine": 19,
"startColumn": 0,
"endLine": 19,
"endColumn": 34
},
"sourceRef": "djstripe/models/account.py:19",
"type": "from-search",
"snippet": " stripe_class = stripe.Account\n"
},
{
"targetRef": "djstripe/models/account.py:19",
"sourceSnippetRange": {
"startLine": 53,
"startColumn": 0,
"endLine": 53,
"endColumn": 50
},
"sourceRef": "djstripe/models/account.py:53",
"type": "from-search",
"snippet": " account_data = cls.stripe_class.retrieve(\n"
},
{
"targetRef": "djstripe/models/account.py:19",
"sourceSnippetRange": {
"startLine": 131,
"startColumn": 0,
"endLine": 131,
"endColumn": 41
},
"sourceRef": "djstripe/models/account.py:131",
"type": "from-search",
"snippet": " return self.stripe_class.reject(\n"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/models/account.py:19",
"range": {
"startLine": 19,
"startColumn": 19,
"endLine": 19,
"endColumn": 33
},
"name": "stripe",
"expression": "stripe.Account",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "Incomplete",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 32
},
"language": "python",
"snippet": "from _typeshed import Incomplete",
"nameRange": {
"startLine": 0,
"startColumn": 22,
"endLine": 0,
"endColumn": 32
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/utils.py",
"name": "_clone",
"ref": "djstripe/utils.py:76",
"definitionRange": {
"startLine": 76,
"startColumn": 4,
"endLine": 77,
"endColumn": 75
},
"language": "python",
"snippet": "def _clone(self):\n return self.__class__.from_iterable(self.model, self._result_cache)",
"nameRange": {
"startLine": 76,
"startColumn": 8,
"endLine": 76,
"endColumn": 14
},
"references": [
{
"targetRef": "djstripe/utils.py:76",
"sourceSnippetRange": {
"startLine": 76,
"startColumn": 0,
"endLine": 76,
"endColumn": 22
},
"sourceRef": "djstripe/utils.py:76",
"type": "from-search",
"snippet": " def _clone(self):\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/utils.py:77",
"range": {
"startLine": 77,
"startColumn": 15,
"endLine": 77,
"endColumn": 75
},
"name": "from_iterable",
"expression": "self.__class__.from_iterable(self.model, self._result_cache)",
"definition": {
"type": "method",
"filePath": "djstripe/utils.py",
"name": "from_iterable",
"ref": "djstripe/utils.py:70",
"definitionRange": {
"startLine": 70,
"startColumn": 4,
"endLine": 74,
"endColumn": 23
},
"language": "python",
"snippet": "def from_iterable(cls, model, iterable):\n instance = cls(model)\n instance._result_cache = list(iterable)\n instance._prefetch_done = True\n return instance",
"nameRange": {
"startLine": 70,
"startColumn": 8,
"endLine": 70,
"endColumn": 21
}
}
},
{
"type": "variable",
"ref": "djstripe/utils.py:77",
"range": {
"startLine": 77,
"startColumn": 43,
"endLine": 77,
"endColumn": 75
},
"name": "model",
"expression": "(self.model, self._result_cache)",
"definition": {
"type": "class_property",
"filePath": "__base_types__",
"name": "model",
"ref": "__base_types__:25",
"definitionRange": {
"startLine": 25,
"startColumn": 4,
"endLine": 25,
"endColumn": 19
},
"language": "python",
"snippet": "model: type[_T]",
"nameRange": {
"startLine": 25,
"startColumn": 4,
"endLine": 25,
"endColumn": 9
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/managers.py",
"name": "canceled_plan_summary_for",
"ref": "djstripe/managers.py:51",
"definitionRange": {
"startLine": 51,
"startColumn": 4,
"endLine": 60,
"endColumn": 9
},
"language": "python",
"snippet": "def canceled_plan_summary_for(self, year, month):\n \"\"\"\n Return Subscriptions canceled within a time range with plan counts annotated.\n \"\"\"\n return (\n self.canceled_during(year, month)\n .values(\"plan\")\n .order_by()\n .annotate(count=models.Count(\"plan\"))\n )",
"nameRange": {
"startLine": 51,
"startColumn": 8,
"endLine": 51,
"endColumn": 33
},
"references": [
{
"targetRef": "djstripe/managers.py:51",
"sourceSnippetRange": {
"startLine": 51,
"startColumn": 0,
"endLine": 51,
"endColumn": 54
},
"sourceRef": "djstripe/managers.py:51",
"type": "from-search",
"snippet": " def canceled_plan_summary_for(self, year, month):\n"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/managers.py:52",
"range": {
"startLine": 52,
"startColumn": 8,
"endLine": 54,
"endColumn": 11
},
"expression": "\"\"\"\n Return Subscriptions canceled within a time range with plan counts annotated.\n \"\"\""
},
{
"type": "call",
"ref": "djstripe/managers.py:56",
"range": {
"startLine": 56,
"startColumn": 12,
"endLine": 56,
"endColumn": 45
},
"name": "canceled_during",
"expression": "self.canceled_during(year, month)",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "canceled_during",
"ref": "djstripe/managers.py:32",
"definitionRange": {
"startLine": 32,
"startColumn": 4,
"endLine": 34,
"endColumn": 87
},
"language": "python",
"snippet": "def canceled_during(self, year, month):\n \"\"\"Return Subscriptions canceled during a certain time range.\"\"\"\n return self.canceled().filter(canceled_at__year=year, canceled_at__month=month)",
"nameRange": {
"startLine": 32,
"startColumn": 8,
"endLine": 32,
"endColumn": 23
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:56",
"range": {
"startLine": 56,
"startColumn": 12,
"endLine": 57,
"endColumn": 27
},
"name": "values",
"expression": "self.canceled_during(year, month)\n .values(\"plan\")",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "values",
"ref": "__base_types__:119",
"definitionRange": {
"startLine": 119,
"startColumn": 4,
"endLine": 121,
"endColumn": 48
},
"language": "python",
"snippet": "def values(\n self, *fields: str | Combinable, **expressions: Any\n ) -> ValuesQuerySet[_T, dict[str, Any]]: ...",
"nameRange": {
"startLine": 119,
"startColumn": 8,
"endLine": 119,
"endColumn": 14
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:56",
"range": {
"startLine": 56,
"startColumn": 12,
"endLine": 58,
"endColumn": 23
},
"name": "order_by",
"expression": "self.canceled_during(year, month)\n .values(\"plan\")\n .order_by()",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "order_by",
"ref": "__base_types__:157",
"definitionRange": {
"startLine": 157,
"startColumn": 4,
"endLine": 157,
"endColumn": 54
},
"language": "python",
"snippet": "def order_by(self, *field_names: Any) -> Self: ...",
"nameRange": {
"startLine": 157,
"startColumn": 8,
"endLine": 157,
"endColumn": 16
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:56",
"range": {
"startLine": 56,
"startColumn": 12,
"endLine": 59,
"endColumn": 49
},
"name": "annotate",
"expression": "self.canceled_during(year, month)\n .values(\"plan\")\n .order_by()\n .annotate(count=models.Count(\"plan\"))",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "annotate",
"ref": "__base_types__:155",
"definitionRange": {
"startLine": 155,
"startColumn": 4,
"endLine": 155,
"endColumn": 62
},
"language": "python",
"snippet": "def annotate(self, *args: Any, **kwargs: Any) -> Self: ...",
"nameRange": {
"startLine": 155,
"startColumn": 8,
"endLine": 155,
"endColumn": 16
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:59",
"range": {
"startLine": 59,
"startColumn": 28,
"endLine": 59,
"endColumn": 48
},
"name": "Count",
"expression": "models.Count(\"plan\")",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Count",
"ref": "__base_types__:17",
"definitionRange": {
"startLine": 17,
"startColumn": 0,
"endLine": 17,
"endColumn": 27
},
"language": "python",
"snippet": "class Count(Aggregate): ...",
"nameRange": {
"startLine": 17,
"startColumn": 6,
"endLine": 17,
"endColumn": 11
}
}
},
{
"type": "variable",
"ref": "djstripe/managers.py:59",
"range": {
"startLine": 59,
"startColumn": 28,
"endLine": 59,
"endColumn": 40
},
"name": "models",
"expression": "models.Count",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "STRIPE_API_VERSION",
"ref": "djstripe/settings.py:122",
"definitionRange": {
"startLine": 122,
"startColumn": 4,
"endLine": 127,
"endColumn": 57
},
"language": "python",
"snippet": "def STRIPE_API_VERSION(self) -> str:\n \"\"\"\n Get the desired API version to use for Stripe requests.\n \"\"\"\n version = getattr(settings, \"STRIPE_API_VERSION\", stripe.api_version)\n return version or self.DEFAULT_STRIPE_API_VERSION",
"nameRange": {
"startLine": 122,
"startColumn": 8,
"endLine": 122,
"endColumn": 26
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/admin/forms.py:225",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 225,
"startColumn": 37,
"endLine": 225,
"endColumn": 55
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/checks.py:115",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 115,
"startColumn": 32,
"endLine": 115,
"endColumn": 50
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_process_events.py:74",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 74,
"startColumn": 53,
"endLine": 74,
"endColumn": 71
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:158",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 158,
"startColumn": 57,
"endLine": 158,
"endColumn": 75
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:220",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 220,
"startColumn": 45,
"endLine": 220,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:486",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 486,
"startColumn": 48,
"endLine": 486,
"endColumn": 66
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:54",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 54,
"startColumn": 62,
"endLine": 54,
"endColumn": 80
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:135",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 135,
"startColumn": 45,
"endLine": 135,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/api.py:96",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 96,
"startColumn": 45,
"endLine": 96,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:83",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 83,
"startColumn": 45,
"endLine": 83,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:238",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 238,
"startColumn": 45,
"endLine": 238,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:255",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 255,
"startColumn": 45,
"endLine": 255,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:280",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 280,
"startColumn": 45,
"endLine": 280,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:305",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 305,
"startColumn": 45,
"endLine": 305,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:1047",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 1047,
"startColumn": 41,
"endLine": 1047,
"endColumn": 59
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:1114",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 1114,
"startColumn": 52,
"endLine": 1114,
"endColumn": 70
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:781",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 781,
"startColumn": 49,
"endLine": 781,
"endColumn": 67
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1982",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 1982,
"startColumn": 45,
"endLine": 1982,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2011",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 2011,
"startColumn": 45,
"endLine": 2011,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2215",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 2215,
"startColumn": 45,
"endLine": 2215,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2233",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 2233,
"startColumn": 45,
"endLine": 2233,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2435",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 2435,
"startColumn": 45,
"endLine": 2435,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:276",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 276,
"startColumn": 45,
"endLine": 276,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:302",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 302,
"startColumn": 45,
"endLine": 302,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:322",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 322,
"startColumn": 45,
"endLine": 322,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:462",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 462,
"startColumn": 45,
"endLine": 462,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:313",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 313,
"startColumn": 49,
"endLine": 313,
"endColumn": 67
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:324",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 324,
"startColumn": 49,
"endLine": 324,
"endColumn": 67
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:740",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 740,
"startColumn": 45,
"endLine": 740,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/webhooks.py:35",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 35,
"startColumn": 34,
"endLine": 35,
"endColumn": 52
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:45",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 45,
"startColumn": 45,
"endLine": 45,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:181",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 181,
"startColumn": 45,
"endLine": 181,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:202",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 202,
"startColumn": 45,
"endLine": 202,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:510",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 510,
"startColumn": 41,
"endLine": 510,
"endColumn": 59
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:251",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 251,
"startColumn": 45,
"endLine": 251,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:363",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 363,
"startColumn": 45,
"endLine": 363,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:477",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 477,
"startColumn": 53,
"endLine": 477,
"endColumn": 71
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:484",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 484,
"startColumn": 53,
"endLine": 484,
"endColumn": 71
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:676",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 676,
"startColumn": 45,
"endLine": 676,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:736",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 736,
"startColumn": 45,
"endLine": 736,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:842",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 842,
"startColumn": 45,
"endLine": 842,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:936",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 936,
"startColumn": 45,
"endLine": 936,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:204",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 204,
"startColumn": 45,
"endLine": 204,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:537",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 537,
"startColumn": 45,
"endLine": 537,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:570",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 570,
"startColumn": 45,
"endLine": 570,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:718",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 718,
"startColumn": 45,
"endLine": 718,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:748",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 748,
"startColumn": 45,
"endLine": 748,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1457",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 1457,
"startColumn": 45,
"endLine": 1457,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1472",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 1472,
"startColumn": 45,
"endLine": 1472,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1917",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 1917,
"startColumn": 45,
"endLine": 1917,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1952",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 1952,
"startColumn": 45,
"endLine": 1952,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_dispute.py:164",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 164,
"startColumn": 45,
"endLine": 164,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_dispute.py:171",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 171,
"startColumn": 45,
"endLine": 171,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:2507",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 2507,
"startColumn": 53,
"endLine": 2507,
"endColumn": 71
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:2514",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 2514,
"startColumn": 53,
"endLine": 2514,
"endColumn": 71
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_file_link.py:59",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 59,
"startColumn": 45,
"endLine": 59,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_file_upload.py:48",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 48,
"startColumn": 53,
"endLine": 48,
"endColumn": 71
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_file_upload.py:55",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 55,
"startColumn": 53,
"endLine": 55,
"endColumn": 71
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:572",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 572,
"startColumn": 45,
"endLine": 572,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoiceitem.py:261",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 261,
"startColumn": 45,
"endLine": 261,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_plan.py:50",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 50,
"startColumn": 69,
"endLine": 50,
"endColumn": 87
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_plan.py:79",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 79,
"startColumn": 45,
"endLine": 79,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_plan.py:107",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 107,
"startColumn": 45,
"endLine": 107,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_plan.py:137",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 137,
"startColumn": 45,
"endLine": 137,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_plan.py:183",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 183,
"startColumn": 45,
"endLine": 183,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:52",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 52,
"startColumn": 45,
"endLine": 52,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:81",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 81,
"startColumn": 45,
"endLine": 81,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:109",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 109,
"startColumn": 45,
"endLine": 109,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:139",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 139,
"startColumn": 45,
"endLine": 139,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:170",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 170,
"startColumn": 45,
"endLine": 170,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:143",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 143,
"startColumn": 39,
"endLine": 143,
"endColumn": 57
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:150",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 150,
"startColumn": 39,
"endLine": 150,
"endColumn": 57
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:67",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 67,
"startColumn": 41,
"endLine": 67,
"endColumn": 59
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:96",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 96,
"startColumn": 41,
"endLine": 96,
"endColumn": 59
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:148",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 148,
"startColumn": 41,
"endLine": 148,
"endColumn": 59
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription.py:1164",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 1164,
"startColumn": 45,
"endLine": 1164,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription.py:1179",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 1179,
"startColumn": 45,
"endLine": 1179,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription_schedule.py:190",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 190,
"startColumn": 45,
"endLine": 190,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription_schedule.py:220",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 220,
"startColumn": 45,
"endLine": 220,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription_schedule.py:250",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 250,
"startColumn": 45,
"endLine": 250,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_tax_id.py:167",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 167,
"startColumn": 45,
"endLine": 167,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_tax_id.py:187",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 187,
"startColumn": 45,
"endLine": 187,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_transfer_reversal.py:125",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 125,
"startColumn": 45,
"endLine": 125,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_transfer_reversal.py:154",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 154,
"startColumn": 45,
"endLine": 154,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_transfer_reversal.py:168",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 168,
"startColumn": 45,
"endLine": 168,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_usage_record_summary.py:291",
"targetRef": "djstripe/settings.py:122",
"sourceSnippetRange": {
"startLine": 291,
"startColumn": 45,
"endLine": 291,
"endColumn": 63
},
"snippet": "STRIPE_API_VERSION"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/settings.py:123",
"range": {
"startLine": 123,
"startColumn": 8,
"endLine": 125,
"endColumn": 11
},
"expression": "\"\"\"\n Get the desired API version to use for Stripe requests.\n \"\"\""
},
{
"type": "variable",
"ref": "djstripe/settings.py:126",
"range": {
"startLine": 126,
"startColumn": 25,
"endLine": 126,
"endColumn": 77
},
"name": "settings",
"expression": "(settings, \"STRIPE_API_VERSION\", stripe.api_version)",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "settings",
"ref": "__base_types__:15",
"definitionRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 28
},
"language": "python",
"snippet": "settings: LazySettings = ...",
"nameRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 8
}
}
},
{
"type": "variable",
"ref": "djstripe/settings.py:126",
"range": {
"startLine": 126,
"startColumn": 25,
"endLine": 126,
"endColumn": 77
},
"name": "api_version",
"expression": "(settings, \"STRIPE_API_VERSION\", stripe.api_version)",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "api_version",
"ref": "__base_types__:12",
"definitionRange": {
"startLine": 12,
"startColumn": 0,
"endLine": 12,
"endColumn": 16
},
"language": "python",
"snippet": "api_version: Any",
"nameRange": {
"startLine": 12,
"startColumn": 0,
"endLine": 12,
"endColumn": 11
}
}
},
{
"type": "variable",
"ref": "djstripe/settings.py:126",
"range": {
"startLine": 126,
"startColumn": 58,
"endLine": 126,
"endColumn": 76
},
"name": "stripe",
"expression": "stripe.api_version",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "Incomplete",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 32
},
"language": "python",
"snippet": "from _typeshed import Incomplete",
"nameRange": {
"startLine": 0,
"startColumn": 22,
"endLine": 0,
"endColumn": 32
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "STRIPE_SECRET_KEY",
"ref": "djstripe/settings.py:100",
"definitionRange": {
"startLine": 100,
"startColumn": 4,
"endLine": 108,
"endColumn": 32
},
"language": "python",
"snippet": "def STRIPE_SECRET_KEY(self):\n # Default secret key\n if hasattr(settings, \"STRIPE_SECRET_KEY\"):\n STRIPE_SECRET_KEY = settings.STRIPE_SECRET_KEY\n else:\n STRIPE_SECRET_KEY = (\n self.LIVE_API_KEY if self.STRIPE_LIVE_MODE else self.TEST_API_KEY\n )\n return STRIPE_SECRET_KEY",
"nameRange": {
"startLine": 100,
"startColumn": 8,
"endLine": 100,
"endColumn": 25
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/checks.py:56",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 56,
"startColumn": 33,
"endLine": 56,
"endColumn": 50
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/checks.py:71",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 71,
"startColumn": 31,
"endLine": 71,
"endColumn": 48
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_process_events.py:73",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 73,
"startColumn": 46,
"endLine": 73,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:29",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 29,
"startColumn": 34,
"endLine": 29,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:47",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 47,
"startColumn": 59,
"endLine": 47,
"endColumn": 76
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:50",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 50,
"startColumn": 29,
"endLine": 50,
"endColumn": 46
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:159",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 159,
"startColumn": 34,
"endLine": 159,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:66",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 66,
"startColumn": 48,
"endLine": 66,
"endColumn": 65
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:244",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 244,
"startColumn": 51,
"endLine": 244,
"endColumn": 68
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:319",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 319,
"startColumn": 65,
"endLine": 319,
"endColumn": 82
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:357",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 357,
"startColumn": 34,
"endLine": 357,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:468",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 468,
"startColumn": 34,
"endLine": 468,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:582",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 582,
"startColumn": 51,
"endLine": 582,
"endColumn": 68
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:601",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 601,
"startColumn": 34,
"endLine": 601,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:649",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 649,
"startColumn": 34,
"endLine": 649,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:711",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 711,
"startColumn": 34,
"endLine": 711,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:828",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 828,
"startColumn": 34,
"endLine": 828,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:849",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 849,
"startColumn": 57,
"endLine": 849,
"endColumn": 74
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:871",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 871,
"startColumn": 57,
"endLine": 871,
"endColumn": 74
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:891",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 891,
"startColumn": 67,
"endLine": 891,
"endColumn": 84
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:931",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 931,
"startColumn": 66,
"endLine": 931,
"endColumn": 83
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:974",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 974,
"startColumn": 71,
"endLine": 974,
"endColumn": 88
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:1012",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1012,
"startColumn": 65,
"endLine": 1012,
"endColumn": 82
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:1046",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1046,
"startColumn": 34,
"endLine": 1046,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:731",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 731,
"startColumn": 34,
"endLine": 731,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:816",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 816,
"startColumn": 34,
"endLine": 816,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:921",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 921,
"startColumn": 34,
"endLine": 921,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:975",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 975,
"startColumn": 51,
"endLine": 975,
"endColumn": 68
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:989",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 989,
"startColumn": 34,
"endLine": 989,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1221",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1221,
"startColumn": 34,
"endLine": 1221,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1384",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1384,
"startColumn": 34,
"endLine": 1384,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1396",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1396,
"startColumn": 48,
"endLine": 1396,
"endColumn": 65
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1464",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1464,
"startColumn": 65,
"endLine": 1464,
"endColumn": 82
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1562",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1562,
"startColumn": 48,
"endLine": 1562,
"endColumn": 65
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1753",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1753,
"startColumn": 34,
"endLine": 1753,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1856",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1856,
"startColumn": 34,
"endLine": 1856,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2134",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 2134,
"startColumn": 65,
"endLine": 2134,
"endColumn": 82
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2172",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 2172,
"startColumn": 51,
"endLine": 2172,
"endColumn": 68
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2219",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 2219,
"startColumn": 48,
"endLine": 2219,
"endColumn": 65
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2341",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 2341,
"startColumn": 51,
"endLine": 2341,
"endColumn": 68
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2410",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 2410,
"startColumn": 48,
"endLine": 2410,
"endColumn": 65
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/checkout.py:111",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 111,
"startColumn": 34,
"endLine": 111,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:199",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 199,
"startColumn": 34,
"endLine": 199,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:258",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 258,
"startColumn": 51,
"endLine": 258,
"endColumn": 68
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:308",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 308,
"startColumn": 48,
"endLine": 308,
"endColumn": 65
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:484",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 484,
"startColumn": 34,
"endLine": 484,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1327",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1327,
"startColumn": 34,
"endLine": 1327,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1366",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1366,
"startColumn": 69,
"endLine": 1366,
"endColumn": 86
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1502",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1502,
"startColumn": 34,
"endLine": 1502,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1589",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1589,
"startColumn": 69,
"endLine": 1589,
"endColumn": 86
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1608",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1608,
"startColumn": 53,
"endLine": 1608,
"endColumn": 70
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:2364",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 2364,
"startColumn": 65,
"endLine": 2364,
"endColumn": 82
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:50",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 50,
"startColumn": 63,
"endLine": 50,
"endColumn": 80
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:96",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 96,
"startColumn": 34,
"endLine": 96,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:180",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 180,
"startColumn": 51,
"endLine": 180,
"endColumn": 68
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:216",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 216,
"startColumn": 48,
"endLine": 216,
"endColumn": 65
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:544",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 544,
"startColumn": 41,
"endLine": 544,
"endColumn": 58
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:684",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 684,
"startColumn": 51,
"endLine": 684,
"endColumn": 68
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:725",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 725,
"startColumn": 48,
"endLine": 725,
"endColumn": 65
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:754",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 754,
"startColumn": 48,
"endLine": 754,
"endColumn": 65
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:868",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 868,
"startColumn": 41,
"endLine": 868,
"endColumn": 58
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/webhooks.py:79",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 79,
"startColumn": 69,
"endLine": 79,
"endColumn": 86
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:175",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 175,
"startColumn": 24,
"endLine": 175,
"endColumn": 41
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:178",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 178,
"startColumn": 45,
"endLine": 178,
"endColumn": 62
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:181",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 181,
"startColumn": 45,
"endLine": 181,
"endColumn": 62
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/management/commands/regenerate_test_fixtures.py:678",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 678,
"startColumn": 60,
"endLine": 678,
"endColumn": 77
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/views.py:21",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 21,
"startColumn": 53,
"endLine": 21,
"endColumn": 70
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/views.py:181",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 181,
"startColumn": 56,
"endLine": 181,
"endColumn": 73
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/views.py:221",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 221,
"startColumn": 64,
"endLine": 221,
"endColumn": 81
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/views.py:226",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 226,
"startColumn": 64,
"endLine": 226,
"endColumn": 81
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:44",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 44,
"startColumn": 38,
"endLine": 44,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:178",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 178,
"startColumn": 38,
"endLine": 178,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:201",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 201,
"startColumn": 38,
"endLine": 201,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:338",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 338,
"startColumn": 56,
"endLine": 338,
"endColumn": 73
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:383",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 383,
"startColumn": 56,
"endLine": 383,
"endColumn": 73
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:404",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 404,
"startColumn": 33,
"endLine": 404,
"endColumn": 50
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:445",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 445,
"startColumn": 34,
"endLine": 445,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:453",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 453,
"startColumn": 33,
"endLine": 453,
"endColumn": 50
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:41",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 41,
"startColumn": 56,
"endLine": 41,
"endColumn": 73
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:46",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 46,
"startColumn": 43,
"endLine": 46,
"endColumn": 60
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:75",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 75,
"startColumn": 56,
"endLine": 75,
"endColumn": 73
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:80",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 80,
"startColumn": 43,
"endLine": 80,
"endColumn": 60
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:111",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 111,
"startColumn": 56,
"endLine": 111,
"endColumn": 73
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:118",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 118,
"startColumn": 43,
"endLine": 118,
"endColumn": 60
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:149",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 149,
"startColumn": 56,
"endLine": 149,
"endColumn": 73
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:156",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 156,
"startColumn": 43,
"endLine": 156,
"endColumn": 60
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:247",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 247,
"startColumn": 38,
"endLine": 247,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:359",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 359,
"startColumn": 38,
"endLine": 359,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:473",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 473,
"startColumn": 46,
"endLine": 473,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:480",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 480,
"startColumn": 46,
"endLine": 480,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:672",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 672,
"startColumn": 38,
"endLine": 672,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:732",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 732,
"startColumn": 38,
"endLine": 732,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:838",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 838,
"startColumn": 38,
"endLine": 838,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:932",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 932,
"startColumn": 38,
"endLine": 932,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:198",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 198,
"startColumn": 38,
"endLine": 198,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:535",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 535,
"startColumn": 38,
"endLine": 535,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:568",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 568,
"startColumn": 38,
"endLine": 568,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:714",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 714,
"startColumn": 38,
"endLine": 714,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:744",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 744,
"startColumn": 38,
"endLine": 744,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1455",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1455,
"startColumn": 38,
"endLine": 1455,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1470",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1470,
"startColumn": 38,
"endLine": 1470,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1908",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1908,
"startColumn": 38,
"endLine": 1908,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1943",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1943,
"startColumn": 38,
"endLine": 1943,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2042",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 2042,
"startColumn": 46,
"endLine": 2042,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2049",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 2049,
"startColumn": 46,
"endLine": 2049,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2469",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 2469,
"startColumn": 46,
"endLine": 2469,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2476",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 2476,
"startColumn": 46,
"endLine": 2476,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_dispute.py:161",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 161,
"startColumn": 38,
"endLine": 161,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_dispute.py:170",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 170,
"startColumn": 38,
"endLine": 170,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event.py:75",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 75,
"startColumn": 49,
"endLine": 75,
"endColumn": 66
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event.py:139",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 139,
"startColumn": 50,
"endLine": 139,
"endColumn": 67
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_file_link.py:56",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 56,
"startColumn": 38,
"endLine": 56,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:569",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 569,
"startColumn": 38,
"endLine": 569,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1474",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1474,
"startColumn": 46,
"endLine": 1474,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1488",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1488,
"startColumn": 46,
"endLine": 1488,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1616",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1616,
"startColumn": 46,
"endLine": 1616,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1630",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1630,
"startColumn": 46,
"endLine": 1630,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1741",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1741,
"startColumn": 38,
"endLine": 1741,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoiceitem.py:260",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 260,
"startColumn": 38,
"endLine": 260,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_line_item.py:156",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 156,
"startColumn": 42,
"endLine": 156,
"endColumn": 59
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_line_item.py:161",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 161,
"startColumn": 42,
"endLine": 161,
"endColumn": 59
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_plan.py:49",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 49,
"startColumn": 62,
"endLine": 49,
"endColumn": 79
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_plan.py:78",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 78,
"startColumn": 38,
"endLine": 78,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_plan.py:106",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 106,
"startColumn": 38,
"endLine": 106,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_plan.py:136",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 136,
"startColumn": 38,
"endLine": 136,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_plan.py:182",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 182,
"startColumn": 38,
"endLine": 182,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:49",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 49,
"startColumn": 62,
"endLine": 49,
"endColumn": 79
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:80",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 80,
"startColumn": 38,
"endLine": 80,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:108",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 108,
"startColumn": 38,
"endLine": 108,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:138",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 138,
"startColumn": 38,
"endLine": 138,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:167",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 167,
"startColumn": 38,
"endLine": 167,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:44",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 44,
"startColumn": 33,
"endLine": 44,
"endColumn": 50
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:76",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 76,
"startColumn": 33,
"endLine": 76,
"endColumn": 50
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:178",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 178,
"startColumn": 30,
"endLine": 178,
"endColumn": 47
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:227",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 227,
"startColumn": 61,
"endLine": 227,
"endColumn": 78
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:235",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 235,
"startColumn": 34,
"endLine": 235,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:289",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 289,
"startColumn": 61,
"endLine": 289,
"endColumn": 78
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:297",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 297,
"startColumn": 34,
"endLine": 297,
"endColumn": 51
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription.py:1163",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1163,
"startColumn": 38,
"endLine": 1163,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription.py:1178",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 1178,
"startColumn": 38,
"endLine": 1178,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription_schedule.py:188",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 188,
"startColumn": 38,
"endLine": 188,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription_schedule.py:218",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 218,
"startColumn": 38,
"endLine": 218,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription_schedule.py:248",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 248,
"startColumn": 38,
"endLine": 248,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_tax_id.py:99",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 99,
"startColumn": 38,
"endLine": 99,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_tax_id.py:168",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 168,
"startColumn": 38,
"endLine": 168,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_tax_id.py:186",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 186,
"startColumn": 38,
"endLine": 186,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_transfer_reversal.py:124",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 124,
"startColumn": 38,
"endLine": 124,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_transfer_reversal.py:153",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 153,
"startColumn": 38,
"endLine": 153,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_transfer_reversal.py:167",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 167,
"startColumn": 38,
"endLine": 167,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_usage_record.py:173",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 173,
"startColumn": 38,
"endLine": 173,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_usage_record.py:178",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 178,
"startColumn": 55,
"endLine": 178,
"endColumn": 72
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_usage_record_summary.py:165",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 165,
"startColumn": 46,
"endLine": 165,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_usage_record_summary.py:172",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 172,
"startColumn": 46,
"endLine": 172,
"endColumn": 63
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_usage_record_summary.py:290",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 290,
"startColumn": 38,
"endLine": 290,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_webhooks.py:139",
"targetRef": "djstripe/settings.py:100",
"sourceSnippetRange": {
"startLine": 139,
"startColumn": 38,
"endLine": 139,
"endColumn": 55
},
"snippet": "STRIPE_SECRET_KEY"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/settings.py:101",
"range": {
"startLine": 101,
"startColumn": 8,
"endLine": 101,
"endColumn": 28
},
"expression": "# Default secret key"
},
{
"type": "variable",
"ref": "djstripe/settings.py:102",
"range": {
"startLine": 102,
"startColumn": 18,
"endLine": 102,
"endColumn": 49
},
"name": "settings",
"expression": "(settings, \"STRIPE_SECRET_KEY\")",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "settings",
"ref": "__base_types__:15",
"definitionRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 28
},
"language": "python",
"snippet": "settings: LazySettings = ...",
"nameRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 8
}
}
},
{
"type": "variable",
"ref": "djstripe/settings.py:103",
"range": {
"startLine": 103,
"startColumn": 12,
"endLine": 103,
"endColumn": 58
},
"name": "STRIPE_SECRET_KEY",
"expression": "STRIPE_SECRET_KEY = settings.STRIPE_SECRET_KEY",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "__getattr__",
"ref": "__base_types__:9",
"definitionRange": {
"startLine": 9,
"startColumn": 4,
"endLine": 9,
"endColumn": 48
},
"language": "python",
"snippet": "def __getattr__(self, item: Any) -> Any: ...",
"nameRange": {
"startLine": 9,
"startColumn": 8,
"endLine": 9,
"endColumn": 19
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/managers.py",
"name": "during",
"ref": "djstripe/managers.py:72",
"definitionRange": {
"startLine": 72,
"startColumn": 4,
"endLine": 74,
"endColumn": 68
},
"language": "python",
"snippet": "def during(self, year, month):\n \"\"\"Return Transfers between a certain time range.\"\"\"\n return self.filter(created__year=year, created__month=month)",
"nameRange": {
"startLine": 72,
"startColumn": 8,
"endLine": 72,
"endColumn": 14
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/managers.py:80",
"targetRef": "djstripe/managers.py:72",
"sourceSnippetRange": {
"startLine": 80,
"startColumn": 20,
"endLine": 80,
"endColumn": 26
},
"snippet": "during"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/managers.py:73",
"range": {
"startLine": 73,
"startColumn": 8,
"endLine": 73,
"endColumn": 60
},
"expression": "\"\"\"Return Transfers between a certain time range.\"\"\""
}
]
},
{
"type": "method",
"filePath": "djstripe/utils.py",
"name": "from_iterable",
"ref": "djstripe/utils.py:70",
"definitionRange": {
"startLine": 70,
"startColumn": 4,
"endLine": 74,
"endColumn": 23
},
"language": "python",
"snippet": "def from_iterable(cls, model, iterable):\n instance = cls(model)\n instance._result_cache = list(iterable)\n instance._prefetch_done = True\n return instance",
"nameRange": {
"startLine": 70,
"startColumn": 8,
"endLine": 70,
"endColumn": 21
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1039",
"targetRef": "djstripe/utils.py:70",
"sourceSnippetRange": {
"startLine": 1039,
"startColumn": 28,
"endLine": 1039,
"endColumn": 41
},
"snippet": "from_iterable"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1054",
"targetRef": "djstripe/utils.py:70",
"sourceSnippetRange": {
"startLine": 1054,
"startColumn": 28,
"endLine": 1054,
"endColumn": 41
},
"snippet": "from_iterable"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1062",
"targetRef": "djstripe/utils.py:70",
"sourceSnippetRange": {
"startLine": 1062,
"startColumn": 28,
"endLine": 1062,
"endColumn": 41
},
"snippet": "from_iterable"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1070",
"targetRef": "djstripe/utils.py:70",
"sourceSnippetRange": {
"startLine": 1070,
"startColumn": 28,
"endLine": 1070,
"endColumn": 41
},
"snippet": "from_iterable"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/utils.py:77",
"targetRef": "djstripe/utils.py:70",
"sourceSnippetRange": {
"startLine": 77,
"startColumn": 30,
"endLine": 77,
"endColumn": 43
},
"snippet": "from_iterable"
}
],
"expressions": []
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "STRIPE_PUBLIC_KEY",
"ref": "djstripe/settings.py:111",
"definitionRange": {
"startLine": 111,
"startColumn": 4,
"endLine": 119,
"endColumn": 32
},
"language": "python",
"snippet": "def STRIPE_PUBLIC_KEY(self):\n # Default public key\n if hasattr(settings, \"STRIPE_PUBLIC_KEY\"):\n STRIPE_PUBLIC_KEY = settings.STRIPE_PUBLIC_KEY\n elif self.STRIPE_LIVE_MODE:\n STRIPE_PUBLIC_KEY = getattr(settings, \"STRIPE_LIVE_PUBLIC_KEY\", \"\")\n else:\n STRIPE_PUBLIC_KEY = getattr(settings, \"STRIPE_TEST_PUBLIC_KEY\", \"\")\n return STRIPE_PUBLIC_KEY",
"nameRange": {
"startLine": 111,
"startColumn": 8,
"endLine": 111,
"endColumn": 25
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/mixins.py:19",
"targetRef": "djstripe/settings.py:111",
"sourceSnippetRange": {
"startLine": 19,
"startColumn": 55,
"endLine": 19,
"endColumn": 72
},
"snippet": "STRIPE_PUBLIC_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/views.py:47",
"targetRef": "djstripe/settings.py:111",
"sourceSnippetRange": {
"startLine": 47,
"startColumn": 48,
"endLine": 47,
"endColumn": 65
},
"snippet": "STRIPE_PUBLIC_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/views.py:151",
"targetRef": "djstripe/settings.py:111",
"sourceSnippetRange": {
"startLine": 151,
"startColumn": 48,
"endLine": 151,
"endColumn": 65
},
"snippet": "STRIPE_PUBLIC_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/views.py:262",
"targetRef": "djstripe/settings.py:111",
"sourceSnippetRange": {
"startLine": 262,
"startColumn": 69,
"endLine": 262,
"endColumn": 86
},
"snippet": "STRIPE_PUBLIC_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:119",
"targetRef": "djstripe/settings.py:111",
"sourceSnippetRange": {
"startLine": 119,
"startColumn": 43,
"endLine": 119,
"endColumn": 60
},
"snippet": "STRIPE_PUBLIC_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:157",
"targetRef": "djstripe/settings.py:111",
"sourceSnippetRange": {
"startLine": 157,
"startColumn": 43,
"endLine": 157,
"endColumn": 60
},
"snippet": "STRIPE_PUBLIC_KEY"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_mixins.py:34",
"targetRef": "djstripe/settings.py:111",
"sourceSnippetRange": {
"startLine": 34,
"startColumn": 30,
"endLine": 34,
"endColumn": 47
},
"snippet": "STRIPE_PUBLIC_KEY"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/settings.py:112",
"range": {
"startLine": 112,
"startColumn": 8,
"endLine": 112,
"endColumn": 28
},
"expression": "# Default public key"
},
{
"type": "variable",
"ref": "djstripe/settings.py:113",
"range": {
"startLine": 113,
"startColumn": 18,
"endLine": 113,
"endColumn": 49
},
"name": "settings",
"expression": "(settings, \"STRIPE_PUBLIC_KEY\")",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "settings",
"ref": "__base_types__:15",
"definitionRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 28
},
"language": "python",
"snippet": "settings: LazySettings = ...",
"nameRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 8
}
}
},
{
"type": "variable",
"ref": "djstripe/settings.py:114",
"range": {
"startLine": 114,
"startColumn": 12,
"endLine": 114,
"endColumn": 58
},
"name": "STRIPE_PUBLIC_KEY",
"expression": "STRIPE_PUBLIC_KEY = settings.STRIPE_PUBLIC_KEY",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "__getattr__",
"ref": "__base_types__:9",
"definitionRange": {
"startLine": 9,
"startColumn": 4,
"endLine": 9,
"endColumn": 48
},
"language": "python",
"snippet": "def __getattr__(self, item: Any) -> Any: ...",
"nameRange": {
"startLine": 9,
"startColumn": 8,
"endLine": 9,
"endColumn": 19
}
}
}
]
},
{
"type": "function",
"filePath": "djstripe/utils.py",
"name": "get_id_from_stripe_data",
"ref": "djstripe/utils.py:86",
"definitionRange": {
"startLine": 86,
"startColumn": 0,
"endLine": 98,
"endColumn": 19
},
"language": "python",
"snippet": "def get_id_from_stripe_data(data):\n \"\"\"\n Extract stripe id from stripe field data\n \"\"\"\n\n if isinstance(data, str):\n # data like \"sub_6lsC8pt7IcFpjA\"\n return data\n elif data:\n # data like {\"id\": sub_6lsC8pt7IcFpjA\", ...}\n return data.get(\"id\")\n else:\n return None",
"nameRange": {
"startLine": 86,
"startColumn": 4,
"endLine": 86,
"endColumn": 27
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:24",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 24,
"startColumn": 20,
"endLine": 24,
"endColumn": 43
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:333",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 333,
"startColumn": 36,
"endLine": 333,
"endColumn": 59
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:341",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 341,
"startColumn": 36,
"endLine": 341,
"endColumn": 59
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:514",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 514,
"startColumn": 18,
"endLine": 514,
"endColumn": 41
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:676",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 676,
"startColumn": 18,
"endLine": 676,
"endColumn": 41
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:737",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 737,
"startColumn": 14,
"endLine": 737,
"endColumn": 37
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:28",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 28,
"startColumn": 50,
"endLine": 28,
"endColumn": 73
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1654",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 1654,
"startColumn": 26,
"endLine": 1654,
"endColumn": 49
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1656",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 1656,
"startColumn": 26,
"endLine": 1656,
"endColumn": 49
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:16",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 16,
"startColumn": 20,
"endLine": 16,
"endColumn": 43
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:99",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 99,
"startColumn": 14,
"endLine": 99,
"endColumn": 37
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:382",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 382,
"startColumn": 13,
"endLine": 382,
"endColumn": 36
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:408",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 408,
"startColumn": 22,
"endLine": 408,
"endColumn": 45
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:467",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 467,
"startColumn": 13,
"endLine": 467,
"endColumn": 36
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:481",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 481,
"startColumn": 22,
"endLine": 481,
"endColumn": 45
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:688",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 688,
"startColumn": 22,
"endLine": 688,
"endColumn": 45
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:784",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 784,
"startColumn": 20,
"endLine": 784,
"endColumn": 43
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:838",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 838,
"startColumn": 22,
"endLine": 838,
"endColumn": 45
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/management/commands/regenerate_test_fixtures.py:9",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 9,
"startColumn": 27,
"endLine": 9,
"endColumn": 50
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/management/commands/regenerate_test_fixtures.py:699",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 699,
"startColumn": 18,
"endLine": 699,
"endColumn": 41
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/management/commands/regenerate_test_fixtures.py:751",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 751,
"startColumn": 38,
"endLine": 751,
"endColumn": 61
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/management/commands/regenerate_test_fixtures.py:755",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 755,
"startColumn": 24,
"endLine": 755,
"endColumn": 47
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/management/commands/regenerate_test_fixtures.py:764",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 764,
"startColumn": 33,
"endLine": 764,
"endColumn": 56
},
"snippet": "get_id_from_stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/management/commands/regenerate_test_fixtures.py:768",
"targetRef": "djstripe/utils.py:86",
"sourceSnippetRange": {
"startLine": 768,
"startColumn": 16,
"endLine": 768,
"endColumn": 39
},
"snippet": "get_id_from_stripe_data"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/utils.py:87",
"range": {
"startLine": 87,
"startColumn": 4,
"endLine": 89,
"endColumn": 7
},
"expression": "\"\"\"\n Extract stripe id from stripe field data\n \"\"\""
},
{
"type": "variable",
"ref": "djstripe/utils.py:91",
"range": {
"startLine": 91,
"startColumn": 17,
"endLine": 91,
"endColumn": 28
},
"name": "str",
"expression": "(data, str)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "str",
"ref": "__base_types__:431",
"definitionRange": {
"startLine": 431,
"startColumn": 0,
"endLine": 600,
"endColumn": 47
},
"language": "python",
"snippet": "class str(Sequence[str]):\n @overload\n def __new__(cls, object: object = ...) -> Self: ...\n @overload\n def __new__(cls, object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...\n @overload\n def capitalize(self: LiteralString) -> LiteralString: ...\n @overload\n def capitalize(self) -> str: ... # type: ignore[misc]\n @overload\n def casefold(self: LiteralString) -> LiteralString: ...\n @overload\n def casefold(self) -> str: ... # type: ignore[misc]\n @overload\n def center(self: LiteralString, width: SupportsIndex, fillchar: LiteralString = \" \", /) -> LiteralString: ...\n @overload\n def center(self, width: SupportsIndex, fillchar: str = \" \", /) -> str: ... # type: ignore[misc]\n def count(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...\n def encode(self, encoding: str = \"utf-8\", errors: str = \"strict\") -> bytes: ...\n def endswith(\n self, suffix: str | tuple[str, ...], start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /\n ) -> bool: ...\n @overload\n def expandtabs(self: LiteralString, tabsize: SupportsIndex = 8) -> LiteralString: ...\n @overload\n def expandtabs(self, tabsize: SupportsIndex = 8) -> str: ... # type: ignore[misc]\n def find(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...\n @overload\n def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...\n @overload\n def format(self, *args: object, **kwargs: object) -> str: ...\n def format_map(self, map: _FormatMapMapping) -> str: ...\n def index(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...\n def isalnum(self) -> bool: ...\n def isalpha(self) -> bool: ...\n def isascii(self) -> bool: ...\n def isdecimal(self) -> bool: ...\n def isdigit(self) -> bool: ...\n def isidentifier(self) -> bool: ...\n def islower(self) -> bool: ...\n def isnumeric(self) -> bool: ...\n def isprintable(self) -> bool: ...\n def isspace(self) -> bool: ...\n def istitle(self) -> bool: ...\n def isupper(self) -> bool: ...\n @overload\n def join(self: LiteralString, iterable: Iterable[LiteralString], /) -> LiteralString: ...\n @overload\n def join(self, iterable: Iterable[str], /) -> str: ... # type: ignore[misc]\n @overload\n def ljust(self: LiteralString, width: SupportsIndex, fillchar: LiteralString = \" \", /) -> LiteralString: ...\n @overload\n def ljust(self, width: SupportsIndex, fillchar: str = \" \", /) -> str: ... # type: ignore[misc]\n @overload\n def lower(self: LiteralString) -> LiteralString: ...\n @overload\n def lower(self) -> str: ... # type: ignore[misc]\n @overload\n def lstrip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...\n @overload\n def lstrip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]\n @overload\n def partition(self: LiteralString, sep: LiteralString, /) -> tuple[LiteralString, LiteralString, LiteralString]: ...\n @overload\n def partition(self, sep: str, /) -> tuple[str, str, str]: ... # type: ignore[misc]\n @overload\n def replace(self: LiteralString, old: LiteralString, new: LiteralString, count: SupportsIndex = -1, /) -> LiteralString: ...\n @overload\n def replace(self, old: str, new: str, count: SupportsIndex = -1, /) -> str: ... # type: ignore[misc]\n if sys.version_info >= (3, 9):\n @overload\n def removeprefix(self: LiteralString, prefix: LiteralString, /) -> LiteralString: ...\n @overload\n def removeprefix(self, prefix: str, /) -> str: ... # type: ignore[misc]\n @overload\n def removesuffix(self: LiteralString, suffix: LiteralString, /) -> LiteralString: ...\n @overload\n def removesuffix(self, suffix: str, /) -> str: ... # type: ignore[misc]\n\n def rfind(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...\n def rindex(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...\n @overload\n def rjust(self: LiteralString, width: SupportsIndex, fillchar: LiteralString = \" \", /) -> LiteralString: ...\n @overload\n def rjust(self, width: SupportsIndex, fillchar: str = \" \", /) -> str: ... # type: ignore[misc]\n @overload\n def rpartition(self: LiteralString, sep: LiteralString, /) -> tuple[LiteralString, LiteralString, LiteralString]: ...\n @overload\n def rpartition(self, sep: str, /) -> tuple[str, str, str]: ... # type: ignore[misc]\n @overload\n def rsplit(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...\n @overload\n def rsplit(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]\n @overload\n def rstrip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...\n @overload\n def rstrip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]\n @overload\n def split(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...\n @overload\n def split(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]\n @overload\n def splitlines(self: LiteralString, keepends: bool = False) -> list[LiteralString]: ...\n @overload\n def splitlines(self, keepends: bool = False) -> list[str]: ... # type: ignore[misc]\n def startswith(\n self, prefix: str | tuple[str, ...], start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /\n ) -> bool: ...\n @overload\n def strip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...\n @overload\n def strip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]\n @overload\n def swapcase(self: LiteralString) -> LiteralString: ...\n @overload\n def swapcase(self) -> str: ... # type: ignore[misc]\n @overload\n def title(self: LiteralString) -> LiteralString: ...\n @overload\n def title(self) -> str: ... # type: ignore[misc]\n def translate(self, table: _TranslateTable, /) -> str: ...\n @overload\n def upper(self: LiteralString) -> LiteralString: ...\n @overload\n def upper(self) -> str: ... # type: ignore[misc]\n @overload\n def zfill(self: LiteralString, width: SupportsIndex, /) -> LiteralString: ...\n @overload\n def zfill(self, width: SupportsIndex, /) -> str: ... # type: ignore[misc]\n @staticmethod\n @overload\n def maketrans(x: dict[int, _T] | dict[str, _T] | dict[str | int, _T], /) -> dict[int, _T]: ...\n @staticmethod\n @overload\n def maketrans(x: str, y: str, /) -> dict[int, int]: ...\n @staticmethod\n @overload\n def maketrans(x: str, y: str, z: str, /) -> dict[int, int | None]: ...\n @overload\n def __add__(self: LiteralString, value: LiteralString, /) -> LiteralString: ...\n @overload\n def __add__(self, value: str, /) -> str: ... # type: ignore[misc]\n # Incompatible with Sequence.__contains__\n def __contains__(self, key: str, /) -> bool: ... # type: ignore[override]\n def __eq__(self, value: object, /) -> bool: ...\n def __ge__(self, value: str, /) -> bool: ...\n def __getitem__(self, key: SupportsIndex | slice, /) -> str: ...\n def __gt__(self, value: str, /) -> bool: ...\n def __hash__(self) -> int: ...\n @overload\n def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...\n @overload\n def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]\n def __le__(self, value: str, /) -> bool: ...\n def __len__(self) -> int: ...\n def __lt__(self, value: str, /) -> bool: ...\n @overload\n def __mod__(self: LiteralString, value: LiteralString | tuple[LiteralString, ...], /) -> LiteralString: ...\n @overload\n def __mod__(self, value: Any, /) -> str: ...\n @overload\n def __mul__(self: LiteralString, value: SupportsIndex, /) -> LiteralString: ...\n @overload\n def __mul__(self, value: SupportsIndex, /) -> str: ... # type: ignore[misc]\n def __ne__(self, value: object, /) -> bool: ...\n @overload\n def __rmul__(self: LiteralString, value: SupportsIndex, /) -> LiteralString: ...\n @overload\n def __rmul__(self, value: SupportsIndex, /) -> str: ... # type: ignore[misc]\n def __getnewargs__(self) -> tuple[str]: ...",
"nameRange": {
"startLine": 431,
"startColumn": 6,
"endLine": 431,
"endColumn": 9
}
}
},
{
"type": "comment",
"ref": "djstripe/utils.py:92",
"range": {
"startLine": 92,
"startColumn": 8,
"endLine": 92,
"endColumn": 40
},
"expression": "# data like \"sub_6lsC8pt7IcFpjA\""
},
{
"type": "comment",
"ref": "djstripe/utils.py:95",
"range": {
"startLine": 95,
"startColumn": 8,
"endLine": 95,
"endColumn": 52
},
"expression": "# data like {\"id\": sub_6lsC8pt7IcFpjA\", ...}"
}
]
},
{
"type": "method",
"filePath": "djstripe/managers.py",
"name": "churn",
"ref": "djstripe/managers.py:62",
"definitionRange": {
"startLine": 62,
"startColumn": 4,
"endLine": 66,
"endColumn": 76
},
"language": "python",
"snippet": "def churn(self):\n \"\"\"Return number of canceled Subscriptions divided by active Subscriptions.\"\"\"\n canceled = self.canceled().count()\n active = self.active().count()\n return decimal.Decimal(str(canceled)) / decimal.Decimal(str(active))",
"nameRange": {
"startLine": 62,
"startColumn": 8,
"endLine": 62,
"endColumn": 13
},
"references": [
{
"targetRef": "djstripe/managers.py:62",
"sourceSnippetRange": {
"startLine": 62,
"startColumn": 0,
"endLine": 62,
"endColumn": 21
},
"sourceRef": "djstripe/managers.py:62",
"type": "from-search",
"snippet": " def churn(self):\n"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/managers.py:63",
"range": {
"startLine": 63,
"startColumn": 8,
"endLine": 63,
"endColumn": 86
},
"expression": "\"\"\"Return number of canceled Subscriptions divided by active Subscriptions.\"\"\""
},
{
"type": "call",
"ref": "djstripe/managers.py:64",
"range": {
"startLine": 64,
"startColumn": 19,
"endLine": 64,
"endColumn": 34
},
"name": "canceled",
"expression": "self.canceled()",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "canceled",
"ref": "djstripe/managers.py:28",
"definitionRange": {
"startLine": 28,
"startColumn": 4,
"endLine": 30,
"endColumn": 45
},
"language": "python",
"snippet": "def canceled(self):\n \"\"\"Return canceled Subscriptions.\"\"\"\n return self.filter(status=\"canceled\")",
"nameRange": {
"startLine": 28,
"startColumn": 8,
"endLine": 28,
"endColumn": 16
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:64",
"range": {
"startLine": 64,
"startColumn": 19,
"endLine": 64,
"endColumn": 42
},
"name": "count",
"expression": "self.canceled().count()",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "count",
"ref": "__base_types__:141",
"definitionRange": {
"startLine": 141,
"startColumn": 4,
"endLine": 141,
"endColumn": 31
},
"language": "python",
"snippet": "def count(self) -> int: ...",
"nameRange": {
"startLine": 141,
"startColumn": 8,
"endLine": 141,
"endColumn": 13
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:65",
"range": {
"startLine": 65,
"startColumn": 17,
"endLine": 65,
"endColumn": 30
},
"name": "active",
"expression": "self.active()",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "active",
"ref": "djstripe/managers.py:24",
"definitionRange": {
"startLine": 24,
"startColumn": 4,
"endLine": 26,
"endColumn": 43
},
"language": "python",
"snippet": "def active(self):\n \"\"\"Return active Subscriptions.\"\"\"\n return self.filter(status=\"active\")",
"nameRange": {
"startLine": 24,
"startColumn": 8,
"endLine": 24,
"endColumn": 14
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:66",
"range": {
"startLine": 66,
"startColumn": 15,
"endLine": 66,
"endColumn": 45
},
"name": "Decimal",
"expression": "decimal.Decimal(str(canceled))",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Decimal",
"ref": "__base_types__:69",
"definitionRange": {
"startLine": 69,
"startColumn": 0,
"endLine": 168,
"endColumn": 86
},
"language": "python",
"snippet": "class Decimal:\n def __new__(cls, value: _DecimalNew = ..., context: Context | None = ...) -> Self: ...\n @classmethod\n def from_float(cls, f: float, /) -> Self: ...\n def __bool__(self) -> bool: ...\n def compare(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def __hash__(self) -> int: ...\n def as_tuple(self) -> DecimalTuple: ...\n def as_integer_ratio(self) -> tuple[int, int]: ...\n def to_eng_string(self, context: Context | None = None) -> str: ...\n def __abs__(self) -> Decimal: ...\n def __add__(self, value: _Decimal, /) -> Decimal: ...\n def __divmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]: ...\n def __eq__(self, value: object, /) -> bool: ...\n def __floordiv__(self, value: _Decimal, /) -> Decimal: ...\n def __ge__(self, value: _ComparableNum, /) -> bool: ...\n def __gt__(self, value: _ComparableNum, /) -> bool: ...\n def __le__(self, value: _ComparableNum, /) -> bool: ...\n def __lt__(self, value: _ComparableNum, /) -> bool: ...\n def __mod__(self, value: _Decimal, /) -> Decimal: ...\n def __mul__(self, value: _Decimal, /) -> Decimal: ...\n def __neg__(self) -> Decimal: ...\n def __pos__(self) -> Decimal: ...\n def __pow__(self, value: _Decimal, mod: _Decimal | None = None, /) -> Decimal: ...\n def __radd__(self, value: _Decimal, /) -> Decimal: ...\n def __rdivmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]: ...\n def __rfloordiv__(self, value: _Decimal, /) -> Decimal: ...\n def __rmod__(self, value: _Decimal, /) -> Decimal: ...\n def __rmul__(self, value: _Decimal, /) -> Decimal: ...\n def __rsub__(self, value: _Decimal, /) -> Decimal: ...\n def __rtruediv__(self, value: _Decimal, /) -> Decimal: ...\n def __sub__(self, value: _Decimal, /) -> Decimal: ...\n def __truediv__(self, value: _Decimal, /) -> Decimal: ...\n def remainder_near(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def __float__(self) -> float: ...\n def __int__(self) -> int: ...\n def __trunc__(self) -> int: ...\n @property\n def real(self) -> Decimal: ...\n @property\n def imag(self) -> Decimal: ...\n def conjugate(self) -> Decimal: ...\n def __complex__(self) -> complex: ...\n @overload\n def __round__(self) -> int: ...\n @overload\n def __round__(self, ndigits: int, /) -> Decimal: ...\n def __floor__(self) -> int: ...\n def __ceil__(self) -> int: ...\n def fma(self, other: _Decimal, third: _Decimal, context: Context | None = None) -> Decimal: ...\n def __rpow__(self, value: _Decimal, mod: Context | None = None, /) -> Decimal: ...\n def normalize(self, context: Context | None = None) -> Decimal: ...\n def quantize(self, exp: _Decimal, rounding: str | None = None, context: Context | None = None) -> Decimal: ...\n def same_quantum(self, other: _Decimal, context: Context | None = None) -> bool: ...\n def to_integral_exact(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...\n def to_integral_value(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...\n def to_integral(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...\n def sqrt(self, context: Context | None = None) -> Decimal: ...\n def max(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def min(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def adjusted(self) -> int: ...\n def canonical(self) -> Decimal: ...\n def compare_signal(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def compare_total(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def compare_total_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def copy_abs(self) -> Decimal: ...\n def copy_negate(self) -> Decimal: ...\n def copy_sign(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def exp(self, context: Context | None = None) -> Decimal: ...\n def is_canonical(self) -> bool: ...\n def is_finite(self) -> bool: ...\n def is_infinite(self) -> bool: ...\n def is_nan(self) -> bool: ...\n def is_normal(self, context: Context | None = None) -> bool: ...\n def is_qnan(self) -> bool: ...\n def is_signed(self) -> bool: ...\n def is_snan(self) -> bool: ...\n def is_subnormal(self, context: Context | None = None) -> bool: ...\n def is_zero(self) -> bool: ...\n def ln(self, context: Context | None = None) -> Decimal: ...\n def log10(self, context: Context | None = None) -> Decimal: ...\n def logb(self, context: Context | None = None) -> Decimal: ...\n def logical_and(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def logical_invert(self, context: Context | None = None) -> Decimal: ...\n def logical_or(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def logical_xor(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def max_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def min_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def next_minus(self, context: Context | None = None) -> Decimal: ...\n def next_plus(self, context: Context | None = None) -> Decimal: ...\n def next_toward(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def number_class(self, context: Context | None = None) -> str: ...\n def radix(self) -> Decimal: ...\n def rotate(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def scaleb(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def shift(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def __reduce__(self) -> tuple[type[Self], tuple[str]]: ...\n def __copy__(self) -> Self: ...\n def __deepcopy__(self, memo: Any, /) -> Self: ...\n def __format__(self, specifier: str, context: Context | None = ..., /) -> str: ...",
"nameRange": {
"startLine": 69,
"startColumn": 6,
"endLine": 69,
"endColumn": 13
}
}
}
]
},
{
"type": "function",
"filePath": "djstripe/utils.py",
"name": "get_queryset",
"ref": "djstripe/utils.py:108",
"definitionRange": {
"startLine": 108,
"startColumn": 0,
"endLine": 110,
"endColumn": 43
},
"language": "python",
"snippet": "def get_queryset(pks, model_name):\n model = get_model(model_name)\n return model.objects.filter(pk__in=pks)",
"nameRange": {
"startLine": 108,
"startColumn": 4,
"endLine": 108,
"endColumn": 16
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/admin/views.py:41",
"targetRef": "djstripe/utils.py:108",
"sourceSnippetRange": {
"startLine": 41,
"startColumn": 23,
"endLine": 41,
"endColumn": 35
},
"snippet": "get_queryset"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/admin/views.py:60",
"targetRef": "djstripe/utils.py:108",
"sourceSnippetRange": {
"startLine": 60,
"startColumn": 25,
"endLine": 60,
"endColumn": 37
},
"snippet": "get_queryset"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/utils.py:109",
"range": {
"startLine": 109,
"startColumn": 12,
"endLine": 109,
"endColumn": 33
},
"name": "get_model",
"expression": "get_model(model_name)",
"definition": {
"type": "function",
"filePath": "djstripe/utils.py",
"name": "get_model",
"ref": "djstripe/utils.py:101",
"definitionRange": {
"startLine": 101,
"startColumn": 0,
"endLine": 105,
"endColumn": 16
},
"language": "python",
"snippet": "def get_model(model_name):\n app_label = \"djstripe\"\n app_config = apps.get_app_config(app_label)\n model = app_config.get_model(model_name)\n return model",
"nameRange": {
"startLine": 101,
"startColumn": 4,
"endLine": 101,
"endColumn": 13
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "get_default_api_key",
"ref": "djstripe/settings.py:169",
"definitionRange": {
"startLine": 169,
"startColumn": 4,
"endLine": 181,
"endColumn": 62
},
"language": "python",
"snippet": "def get_default_api_key(self, livemode) -> str:\n \"\"\"\n Returns the default API key for a value of `livemode`.\n \"\"\"\n if livemode is None:\n # Livemode is unknown. Use the default secret key.\n return self.STRIPE_SECRET_KEY\n elif livemode:\n # Livemode is true, use the live secret key\n return self.LIVE_API_KEY or self.STRIPE_SECRET_KEY\n else:\n # Livemode is false, use the test secret key\n return self.TEST_API_KEY or self.STRIPE_SECRET_KEY",
"nameRange": {
"startLine": 169,
"startColumn": 8,
"endLine": 169,
"endColumn": 27
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:152",
"targetRef": "djstripe/settings.py:169",
"sourceSnippetRange": {
"startLine": 152,
"startColumn": 33,
"endLine": 152,
"endColumn": 52
},
"snippet": "get_default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:167",
"targetRef": "djstripe/settings.py:169",
"sourceSnippetRange": {
"startLine": 167,
"startColumn": 33,
"endLine": 167,
"endColumn": 52
},
"snippet": "get_default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:1111",
"targetRef": "djstripe/settings.py:169",
"sourceSnippetRange": {
"startLine": 1111,
"startColumn": 30,
"endLine": 1111,
"endColumn": 49
},
"snippet": "get_default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/webhooks.py:229",
"targetRef": "djstripe/settings.py:169",
"sourceSnippetRange": {
"startLine": 229,
"startColumn": 33,
"endLine": 229,
"endColumn": 52
},
"snippet": "get_default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/webhooks.py:354",
"targetRef": "djstripe/settings.py:169",
"sourceSnippetRange": {
"startLine": 354,
"startColumn": 47,
"endLine": 354,
"endColumn": 66
},
"snippet": "get_default_api_key"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/settings.py:170",
"range": {
"startLine": 170,
"startColumn": 8,
"endLine": 172,
"endColumn": 11
},
"expression": "\"\"\"\n Returns the default API key for a value of `livemode`.\n \"\"\""
},
{
"type": "comment",
"ref": "djstripe/settings.py:174",
"range": {
"startLine": 174,
"startColumn": 12,
"endLine": 174,
"endColumn": 62
},
"expression": "# Livemode is unknown. Use the default secret key."
},
{
"type": "comment",
"ref": "djstripe/settings.py:177",
"range": {
"startLine": 177,
"startColumn": 12,
"endLine": 177,
"endColumn": 55
},
"expression": "# Livemode is true, use the live secret key"
},
{
"type": "comment",
"ref": "djstripe/settings.py:180",
"range": {
"startLine": 180,
"startColumn": 12,
"endLine": 180,
"endColumn": 56
},
"expression": "# Livemode is false, use the test secret key"
}
]
},
{
"type": "function",
"filePath": "djstripe/utils.py",
"name": "get_timezone_utc",
"ref": "djstripe/utils.py:113",
"definitionRange": {
"startLine": 113,
"startColumn": 0,
"endLine": 124,
"endColumn": 27
},
"language": "python",
"snippet": "def get_timezone_utc():\n \"\"\"\n Returns UTC attribute in a backwards compatible way.\n\n UTC attribute has been moved from django.utils.timezone module to\n datetime.timezone class\n \"\"\"\n try:\n # Django 4+\n return datetime.timezone.utc\n except AttributeError:\n return timezone.utc",
"nameRange": {
"startLine": 113,
"startColumn": 4,
"endLine": 113,
"endColumn": 20
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/utils.py:47",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 47,
"startColumn": 9,
"endLine": 47,
"endColumn": 25
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/__init__.py:21",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 21,
"startColumn": 27,
"endLine": 21,
"endColumn": 43
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/__init__.py:27",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 27,
"startColumn": 52,
"endLine": 27,
"endColumn": 68
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_fields.py:12",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 12,
"startColumn": 27,
"endLine": 12,
"endColumn": 43
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_fields.py:36",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 36,
"startColumn": 26,
"endLine": 36,
"endColumn": 42
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_fields.py:45",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 45,
"startColumn": 52,
"endLine": 45,
"endColumn": 68
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:13",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 13,
"startColumn": 27,
"endLine": 13,
"endColumn": 43
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:28",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 28,
"startColumn": 60,
"endLine": 28,
"endColumn": 76
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:29",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 29,
"startColumn": 59,
"endLine": 29,
"endColumn": 75
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:31",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 31,
"startColumn": 40,
"endLine": 31,
"endColumn": 56
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:193",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 193,
"startColumn": 58,
"endLine": 193,
"endColumn": 74
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:203",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 203,
"startColumn": 57,
"endLine": 203,
"endColumn": 73
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:214",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 214,
"startColumn": 58,
"endLine": 214,
"endColumn": 74
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:225",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 225,
"startColumn": 58,
"endLine": 225,
"endColumn": 74
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:236",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 236,
"startColumn": 57,
"endLine": 236,
"endColumn": 73
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:246",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 246,
"startColumn": 59,
"endLine": 246,
"endColumn": 75
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:256",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 256,
"startColumn": 59,
"endLine": 256,
"endColumn": 75
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:266",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 266,
"startColumn": 57,
"endLine": 266,
"endColumn": 73
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:17",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 17,
"startColumn": 4,
"endLine": 17,
"endColumn": 20
},
"snippet": "get_timezone_utc"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_utils.py:27",
"targetRef": "djstripe/utils.py:113",
"sourceSnippetRange": {
"startLine": 27,
"startColumn": 59,
"endLine": 27,
"endColumn": 75
},
"snippet": "get_timezone_utc"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/utils.py:114",
"range": {
"startLine": 114,
"startColumn": 4,
"endLine": 119,
"endColumn": 7
},
"expression": "\"\"\"\n Returns UTC attribute in a backwards compatible way.\n\n UTC attribute has been moved from django.utils.timezone module to\n datetime.timezone class\n \"\"\""
},
{
"type": "comment",
"ref": "djstripe/utils.py:121",
"range": {
"startLine": 121,
"startColumn": 8,
"endLine": 121,
"endColumn": 19
},
"expression": "# Django 4+"
},
{
"type": "variable",
"ref": "djstripe/utils.py:124",
"range": {
"startLine": 124,
"startColumn": 15,
"endLine": 124,
"endColumn": 27
},
"name": "timezone",
"expression": "timezone.utc",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "types",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 12
},
"language": "python",
"snippet": "import types",
"nameRange": {
"startLine": 0,
"startColumn": 7,
"endLine": 0,
"endColumn": 12
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "_create_from_stripe_object",
"ref": "djstripe/models/account.py:22",
"definitionRange": {
"startLine": 22,
"startColumn": 4,
"endLine": 44,
"endColumn": 9
},
"language": "python",
"snippet": "def _create_from_stripe_object(\n cls,\n data,\n current_ids=None,\n pending_relations=None,\n save=True,\n stripe_account=None,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n ):\n \"\"\"\n Set the stripe_account to the id of the Account instance being created.\n\n This ensures that the foreign-key relations that may exist in stripe are\n fetched using the appropriate connected account ID.\n \"\"\"\n return super()._create_from_stripe_object(\n data=data,\n current_ids=current_ids,\n pending_relations=pending_relations,\n save=save,\n stripe_account=data[\"id\"] if not stripe_account else stripe_account,\n api_key=api_key,\n )",
"nameRange": {
"startLine": 22,
"startColumn": 8,
"endLine": 22,
"endColumn": 34
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:37",
"targetRef": "djstripe/models/account.py:22",
"sourceSnippetRange": {
"startLine": 37,
"startColumn": 23,
"endLine": 37,
"endColumn": 49
},
"snippet": "_create_from_stripe_object"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:642",
"targetRef": "djstripe/models/account.py:22",
"sourceSnippetRange": {
"startLine": 642,
"startColumn": 8,
"endLine": 642,
"endColumn": 34
},
"snippet": "_create_from_stripe_object"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:805",
"targetRef": "djstripe/models/account.py:22",
"sourceSnippetRange": {
"startLine": 805,
"startColumn": 24,
"endLine": 805,
"endColumn": 50
},
"snippet": "_create_from_stripe_object"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:792",
"targetRef": "djstripe/models/account.py:22",
"sourceSnippetRange": {
"startLine": 792,
"startColumn": 31,
"endLine": 792,
"endColumn": 57
},
"snippet": "_create_from_stripe_object"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1618",
"targetRef": "djstripe/models/account.py:22",
"sourceSnippetRange": {
"startLine": 1618,
"startColumn": 22,
"endLine": 1618,
"endColumn": 48
},
"snippet": "_create_from_stripe_object"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:435",
"targetRef": "djstripe/models/account.py:22",
"sourceSnippetRange": {
"startLine": 435,
"startColumn": 12,
"endLine": 435,
"endColumn": 38
},
"snippet": "_create_from_stripe_object"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:966",
"targetRef": "djstripe/models/account.py:22",
"sourceSnippetRange": {
"startLine": 966,
"startColumn": 20,
"endLine": 966,
"endColumn": 46
},
"snippet": "_create_from_stripe_object"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event.py:120",
"targetRef": "djstripe/models/account.py:22",
"sourceSnippetRange": {
"startLine": 120,
"startColumn": 47,
"endLine": 120,
"endColumn": 73
},
"snippet": "_create_from_stripe_object"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/models/account.py:29",
"range": {
"startLine": 29,
"startColumn": 16,
"endLine": 29,
"endColumn": 51
},
"name": "djstripe_settings",
"expression": "djstripe_settings.STRIPE_SECRET_KEY",
"definition": {
"type": "expression",
"filePath": "djstripe/settings.py",
"name": "djstripe_settings",
"ref": "djstripe/settings.py:236",
"definitionRange": {
"startLine": 236,
"startColumn": 0,
"endLine": 236,
"endColumn": 38
},
"language": "python",
"snippet": "djstripe_settings = DjstripeSettings()",
"nameRange": {
"startLine": 236,
"startColumn": 0,
"endLine": 236,
"endColumn": 17
}
}
},
{
"type": "comment",
"ref": "djstripe/models/account.py:31",
"range": {
"startLine": 31,
"startColumn": 8,
"endLine": 36,
"endColumn": 11
},
"expression": "\"\"\"\n Set the stripe_account to the id of the Account instance being created.\n\n This ensures that the foreign-key relations that may exist in stripe are\n fetched using the appropriate connected account ID.\n \"\"\""
},
{
"type": "call",
"ref": "djstripe/models/account.py:37",
"range": {
"startLine": 37,
"startColumn": 15,
"endLine": 44,
"endColumn": 9
},
"name": "_create_from_stripe_object",
"expression": "super()._create_from_stripe_object(\n data=data,\n current_ids=current_ids,\n pending_relations=pending_relations,\n save=save,\n stripe_account=data[\"id\"] if not stripe_account else stripe_account,\n api_key=api_key,\n )",
"definition": {
"type": "method",
"filePath": "djstripe/models/base.py",
"name": "_create_from_stripe_object",
"ref": "djstripe/models/base.py:642",
"definitionRange": {
"startLine": 642,
"startColumn": 4,
"endLine": 699,
"endColumn": 23
},
"language": "python",
"snippet": "def _create_from_stripe_object(\n cls,\n data,\n current_ids=None,\n pending_relations=None,\n save=True,\n stripe_account=None,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n ):\n \"\"\"\n Instantiates a model instance using the provided data object received\n from Stripe, and saves it to the database if specified.\n\n :param data: The data dictionary received from the Stripe API.\n :type data: dict\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n :param pending_relations: list of tuples of relations to be attached post-save\n :type pending_relations: list\n :param save: If True, the object is saved after instantiation.\n :type save: bool\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n :returns: The instantiated object.\n \"\"\"\n stripe_data = cls._stripe_object_to_record(\n data,\n current_ids=current_ids,\n pending_relations=pending_relations,\n stripe_account=stripe_account,\n api_key=api_key,\n )\n try:\n id_ = get_id_from_stripe_data(stripe_data)\n if id_ is not None:\n instance = cls.stripe_objects.get(id=id_)\n else:\n # Raise error on purpose to resume the _create_from_stripe_object flow\n raise cls.DoesNotExist\n\n except cls.DoesNotExist:\n # try to create iff instance doesn't already exist in the DB\n # TODO dictionary unpacking will not work if cls has any ManyToManyField\n instance = cls(**stripe_data)\n\n instance._attach_objects_hook(\n cls, data, api_key=api_key, current_ids=current_ids\n )\n\n if save:\n instance.save()\n\n instance._attach_objects_post_save_hook(\n cls, data, api_key=api_key, pending_relations=pending_relations\n )\n\n return instance",
"nameRange": {
"startLine": 642,
"startColumn": 8,
"endLine": 642,
"endColumn": 34
}
}
}
]
},
{
"type": "function",
"filePath": "djstripe/utils.py",
"name": "get_model",
"ref": "djstripe/utils.py:101",
"definitionRange": {
"startLine": 101,
"startColumn": 0,
"endLine": 105,
"endColumn": 16
},
"language": "python",
"snippet": "def get_model(model_name):\n app_label = \"djstripe\"\n app_config = apps.get_app_config(app_label)\n model = app_config.get_model(model_name)\n return model",
"nameRange": {
"startLine": 101,
"startColumn": 4,
"endLine": 101,
"endColumn": 13
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/admin/forms.py:29",
"targetRef": "djstripe/utils.py:101",
"sourceSnippetRange": {
"startLine": 29,
"startColumn": 22,
"endLine": 29,
"endColumn": 31
},
"snippet": "get_model"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/admin/views.py:28",
"targetRef": "djstripe/utils.py:101",
"sourceSnippetRange": {
"startLine": 28,
"startColumn": 22,
"endLine": 28,
"endColumn": 31
},
"snippet": "get_model"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/admin/views.py:56",
"targetRef": "djstripe/utils.py:101",
"sourceSnippetRange": {
"startLine": 56,
"startColumn": 22,
"endLine": 56,
"endColumn": 31
},
"snippet": "get_model"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/utils.py:109",
"targetRef": "djstripe/utils.py:101",
"sourceSnippetRange": {
"startLine": 109,
"startColumn": 12,
"endLine": 109,
"endColumn": 21
},
"snippet": "get_model"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/utils.py:103",
"range": {
"startLine": 103,
"startColumn": 17,
"endLine": 103,
"endColumn": 47
},
"name": "get_app_config",
"expression": "apps.get_app_config(app_label)",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "get_app_config",
"ref": "__base_types__:25",
"definitionRange": {
"startLine": 25,
"startColumn": 4,
"endLine": 25,
"endColumn": 62
},
"language": "python",
"snippet": "def get_app_config(self, app_label: str) -> AppConfig: ...",
"nameRange": {
"startLine": 25,
"startColumn": 8,
"endLine": 25,
"endColumn": 22
}
}
},
{
"type": "variable",
"ref": "djstripe/utils.py:103",
"range": {
"startLine": 103,
"startColumn": 17,
"endLine": 103,
"endColumn": 36
},
"name": "apps",
"expression": "apps.get_app_config",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "apps",
"ref": "__base_types__:48",
"definitionRange": {
"startLine": 48,
"startColumn": 0,
"endLine": 48,
"endColumn": 10
},
"language": "python",
"snippet": "apps: Apps",
"nameRange": {
"startLine": 48,
"startColumn": 0,
"endLine": 48,
"endColumn": 4
}
}
},
{
"type": "call",
"ref": "djstripe/utils.py:104",
"range": {
"startLine": 104,
"startColumn": 12,
"endLine": 104,
"endColumn": 44
},
"name": "get_model",
"expression": "app_config.get_model(model_name)",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "get_model",
"ref": "__base_types__:20",
"definitionRange": {
"startLine": 20,
"startColumn": 4,
"endLine": 20,
"endColumn": 87
},
"language": "python",
"snippet": "def get_model(self, model_name: str, require_ready: bool = ...) -> type[Model]: ...",
"nameRange": {
"startLine": 20,
"startColumn": 8,
"endLine": 20,
"endColumn": 17
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "get_or_retrieve_for_api_key",
"ref": "djstripe/models/account.py:60",
"definitionRange": {
"startLine": 60,
"startColumn": 4,
"endLine": 66,
"endColumn": 57
},
"language": "python",
"snippet": "def get_or_retrieve_for_api_key(cls, api_key: str):\n with transaction.atomic():\n apikey_instance, _ = APIKey.objects.get_or_create_by_api_key(api_key)\n if not apikey_instance.djstripe_owner_account:\n apikey_instance.refresh_account()\n\n return apikey_instance.djstripe_owner_account",
"nameRange": {
"startLine": 60,
"startColumn": 8,
"endLine": 60,
"endColumn": 35
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:348",
"targetRef": "djstripe/models/account.py:60",
"sourceSnippetRange": {
"startLine": 348,
"startColumn": 23,
"endLine": 348,
"endColumn": 50
},
"snippet": "get_or_retrieve_for_api_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:994",
"targetRef": "djstripe/models/account.py:60",
"sourceSnippetRange": {
"startLine": 994,
"startColumn": 30,
"endLine": 994,
"endColumn": 57
},
"snippet": "get_or_retrieve_for_api_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:1025",
"targetRef": "djstripe/models/account.py:60",
"sourceSnippetRange": {
"startLine": 1025,
"startColumn": 34,
"endLine": 1025,
"endColumn": 61
},
"snippet": "get_or_retrieve_for_api_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_apikey.py:147",
"targetRef": "djstripe/models/account.py:60",
"sourceSnippetRange": {
"startLine": 147,
"startColumn": 26,
"endLine": 147,
"endColumn": 53
},
"snippet": "get_or_retrieve_for_api_key"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/account.py:61",
"range": {
"startLine": 61,
"startColumn": 13,
"endLine": 61,
"endColumn": 33
},
"name": "atomic",
"expression": "transaction.atomic()",
"definition": {
"type": "function",
"filePath": "__base_types__",
"name": "atomic",
"ref": "__base_types__:41",
"definitionRange": {
"startLine": 41,
"startColumn": 0,
"endLine": 41,
"endColumn": 32
},
"language": "python",
"snippet": "def atomic(using: _C) -> _C: ...",
"nameRange": {
"startLine": 41,
"startColumn": 4,
"endLine": 41,
"endColumn": 10
}
}
},
{
"type": "variable",
"ref": "djstripe/models/account.py:61",
"range": {
"startLine": 61,
"startColumn": 13,
"endLine": 61,
"endColumn": 31
},
"name": "transaction",
"expression": "transaction.atomic",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "Callable",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 46
},
"language": "python",
"snippet": "from collections.abc import Callable, Iterator",
"nameRange": {
"startLine": 0,
"startColumn": 28,
"endLine": 0,
"endColumn": 36
}
}
},
{
"type": "variable",
"ref": "djstripe/models/account.py:62",
"range": {
"startLine": 62,
"startColumn": 33,
"endLine": 62,
"endColumn": 47
},
"name": "APIKey",
"expression": "APIKey.objects",
"definition": {
"type": "class",
"filePath": "djstripe/models/api.py",
"name": "APIKey",
"ref": "djstripe/models/api.py:47",
"definitionRange": {
"startLine": 47,
"startColumn": 0,
"endLine": 126,
"endColumn": 50
},
"language": "python",
"snippet": "class APIKey(StripeModel):\n object = \"api_key\"\n\n id = models.CharField(max_length=255, default=generate_api_key_id, editable=False)\n type = StripeEnumField(enum=APIKeyType)\n name = models.CharField(\n \"Key name\",\n max_length=100,\n blank=True,\n help_text=\"An optional name to identify the key.\",\n )\n secret = models.CharField(\n max_length=128,\n validators=[RegexValidator(regex=API_KEY_REGEX)],\n unique=True,\n help_text=\"The value of the key.\",\n )\n\n livemode = models.BooleanField(\n help_text=\"Whether the key is valid for live or test mode.\"\n )\n description = None\n metadata = None\n objects = APIKeyManager()\n\n def get_stripe_dashboard_url(self):\n return self._get_base_stripe_dashboard_url() + \"apikeys\"\n\n def __str__(self):\n return self.name or self.secret_redacted\n\n def clean(self):\n if self.livemode is None or self.type is None:\n try:\n self.type, self.livemode = get_api_key_details_by_prefix(self.secret)\n except InvalidStripeAPIKey as e:\n raise ValidationError(str(e))\n\n def refresh_account(self, commit=True):\n from .account import Account\n\n if self.type not in (\n APIKeyType.secret,\n APIKeyType.restricted,\n ):\n return\n\n account_data = Account.stripe_class.retrieve(\n api_key=self.secret,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n )\n # NOTE: Do not immediately use _get_or_create_from_stripe_object() here.\n # Account needs to exist for things to work. Make a stub if necessary.\n account, created = Account.objects.get_or_create(\n id=account_data[\"id\"],\n )\n if created:\n # If it's just been created, now we can sync the account.\n Account.sync_from_stripe_data(account_data, api_key=self.secret)\n self.djstripe_owner_account = account\n if commit:\n try:\n # for non-existent accounts, due to djstripe_owner_account search for the\n # accounts themselves, trigerred by this method, the APIKey gets created before this method\n # can \"commit\". This results in an Integrity Error\n with transaction.atomic():\n self.save()\n except IntegrityError:\n pass\n\n @property\n def secret_redacted(self) -> str:\n \"\"\"\n Returns a redacted version of the secret, suitable for display purposes.\n\n Same algorithm used on the Stripe dashboard.\n \"\"\"\n secret_prefix, _, secret_part = self.secret.rpartition(\"_\")\n secret_part = secret_part[-4:]\n return f\"{secret_prefix}_...{secret_part}\"",
"nameRange": {
"startLine": 47,
"startColumn": 6,
"endLine": 47,
"endColumn": 12
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "default_api_key",
"ref": "djstripe/models/account.py:78",
"definitionRange": {
"startLine": 78,
"startColumn": 4,
"endLine": 79,
"endColumn": 41
},
"language": "python",
"snippet": "def default_api_key(self) -> str:\n return self.get_default_api_key()",
"nameRange": {
"startLine": 78,
"startColumn": 8,
"endLine": 78,
"endColumn": 23
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/event_handlers.py:526",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 526,
"startColumn": 61,
"endLine": 526,
"endColumn": 76
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/event_handlers.py:532",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 532,
"startColumn": 67,
"endLine": 532,
"endColumn": 82
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:125",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 125,
"startColumn": 34,
"endLine": 125,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:162",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 162,
"startColumn": 8,
"endLine": 162,
"endColumn": 23
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:182",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 182,
"startColumn": 34,
"endLine": 182,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:229",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 229,
"startColumn": 34,
"endLine": 229,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:270",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 270,
"startColumn": 34,
"endLine": 270,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:295",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 295,
"startColumn": 34,
"endLine": 295,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:807",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 807,
"startColumn": 53,
"endLine": 807,
"endColumn": 68
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1598",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1598,
"startColumn": 48,
"endLine": 1598,
"endColumn": 63
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1678",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1678,
"startColumn": 46,
"endLine": 1678,
"endColumn": 61
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1972",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1972,
"startColumn": 34,
"endLine": 1972,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2001",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 2001,
"startColumn": 34,
"endLine": 2001,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2203",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 2203,
"startColumn": 34,
"endLine": 2203,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:292",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 292,
"startColumn": 34,
"endLine": 292,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:445",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 445,
"startColumn": 34,
"endLine": 445,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:476",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 476,
"startColumn": 42,
"endLine": 476,
"endColumn": 57
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:994",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 994,
"startColumn": 48,
"endLine": 994,
"endColumn": 63
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1034",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1034,
"startColumn": 48,
"endLine": 1034,
"endColumn": 63
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1111",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1111,
"startColumn": 45,
"endLine": 1111,
"endColumn": 60
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1139",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1139,
"startColumn": 69,
"endLine": 1139,
"endColumn": 84
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1306",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1306,
"startColumn": 42,
"endLine": 1306,
"endColumn": 57
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1395",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1395,
"startColumn": 48,
"endLine": 1395,
"endColumn": 63
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1400",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1400,
"startColumn": 48,
"endLine": 1400,
"endColumn": 63
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1407",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1407,
"startColumn": 48,
"endLine": 1407,
"endColumn": 63
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1414",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1414,
"startColumn": 48,
"endLine": 1414,
"endColumn": 63
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1662",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1662,
"startColumn": 29,
"endLine": 1662,
"endColumn": 44
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1940",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1940,
"startColumn": 34,
"endLine": 1940,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1952",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1952,
"startColumn": 34,
"endLine": 1952,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1967",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 1967,
"startColumn": 34,
"endLine": 1967,
"endColumn": 49
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:707",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 707,
"startColumn": 23,
"endLine": 707,
"endColumn": 38
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:719",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 719,
"startColumn": 47,
"endLine": 719,
"endColumn": 62
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:720",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 720,
"startColumn": 29,
"endLine": 720,
"endColumn": 44
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/webhooks.py:228",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 228,
"startColumn": 27,
"endLine": 228,
"endColumn": 42
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:43",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 43,
"startColumn": 37,
"endLine": 43,
"endColumn": 52
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:77",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 77,
"startColumn": 37,
"endLine": 77,
"endColumn": 52
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:113",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 113,
"startColumn": 37,
"endLine": 113,
"endColumn": 52
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_api_keys.py:151",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 151,
"startColumn": 37,
"endLine": 151,
"endColumn": 52
},
"snippet": "default_api_key"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_views.py:368",
"targetRef": "djstripe/models/account.py:78",
"sourceSnippetRange": {
"startLine": 368,
"startColumn": 36,
"endLine": 368,
"endColumn": 51
},
"snippet": "default_api_key"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/account.py:79",
"range": {
"startLine": 79,
"startColumn": 15,
"endLine": 79,
"endColumn": 41
},
"name": "get_default_api_key",
"expression": "self.get_default_api_key()",
"definition": {
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "get_default_api_key",
"ref": "djstripe/models/account.py:139",
"definitionRange": {
"startLine": 139,
"startColumn": 4,
"endLine": 152,
"endColumn": 62
},
"language": "python",
"snippet": "def get_default_api_key(self, livemode: bool = None) -> str:\n if livemode is None:\n livemode = self.livemode\n api_key = APIKey.objects.filter(\n djstripe_owner_account=self, type=APIKeyType.secret\n ).first()\n else:\n api_key = APIKey.objects.filter(\n djstripe_owner_account=self, type=APIKeyType.secret, livemode=livemode\n ).first()\n\n if api_key:\n return api_key.secret\n return djstripe_settings.get_default_api_key(livemode)",
"nameRange": {
"startLine": 139,
"startColumn": 8,
"endLine": 139,
"endColumn": 27
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "get_subscriber_model_string",
"ref": "djstripe/settings.py:183",
"definitionRange": {
"startLine": 183,
"startColumn": 4,
"endLine": 185,
"endColumn": 103
},
"language": "python",
"snippet": "def get_subscriber_model_string(self) -> str:\n \"\"\"Get the configured subscriber model as a module path string.\"\"\"\n return getattr(settings, \"DJSTRIPE_SUBSCRIBER_MODEL\", settings.AUTH_USER_MODEL) # type: ignore",
"nameRange": {
"startLine": 183,
"startColumn": 8,
"endLine": 183,
"endColumn": 35
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:826",
"targetRef": "djstripe/settings.py:183",
"sourceSnippetRange": {
"startLine": 826,
"startColumn": 26,
"endLine": 826,
"endColumn": 53
},
"snippet": "get_subscriber_model_string"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:198",
"targetRef": "djstripe/settings.py:183",
"sourceSnippetRange": {
"startLine": 198,
"startColumn": 26,
"endLine": 198,
"endColumn": 53
},
"snippet": "get_subscriber_model_string"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/settings.py:184",
"range": {
"startLine": 184,
"startColumn": 8,
"endLine": 184,
"endColumn": 74
},
"expression": "\"\"\"Get the configured subscriber model as a module path string.\"\"\""
},
{
"type": "variable",
"ref": "djstripe/settings.py:185",
"range": {
"startLine": 185,
"startColumn": 22,
"endLine": 185,
"endColumn": 87
},
"name": "settings",
"expression": "(settings, \"DJSTRIPE_SUBSCRIBER_MODEL\", settings.AUTH_USER_MODEL)",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "settings",
"ref": "__base_types__:15",
"definitionRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 28
},
"language": "python",
"snippet": "settings: LazySettings = ...",
"nameRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 8
}
}
},
{
"type": "variable",
"ref": "djstripe/settings.py:185",
"range": {
"startLine": 185,
"startColumn": 22,
"endLine": 185,
"endColumn": 87
},
"name": "AUTH_USER_MODEL",
"expression": "(settings, \"DJSTRIPE_SUBSCRIBER_MODEL\", settings.AUTH_USER_MODEL)",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "__getattr__",
"ref": "__base_types__:9",
"definitionRange": {
"startLine": 9,
"startColumn": 4,
"endLine": 9,
"endColumn": 48
},
"language": "python",
"snippet": "def __getattr__(self, item: Any) -> Any: ...",
"nameRange": {
"startLine": 9,
"startColumn": 8,
"endLine": 9,
"endColumn": 19
}
}
},
{
"type": "comment",
"ref": "djstripe/settings.py:185",
"range": {
"startLine": 185,
"startColumn": 89,
"endLine": 185,
"endColumn": 103
},
"expression": "# type: ignore"
}
]
},
{
"type": "method",
"filePath": "djstripe/managers.py",
"name": "during",
"ref": "djstripe/managers.py:86",
"definitionRange": {
"startLine": 86,
"startColumn": 4,
"endLine": 88,
"endColumn": 68
},
"language": "python",
"snippet": "def during(self, year, month):\n \"\"\"Return Charges between a certain time range based on `created`.\"\"\"\n return self.filter(created__year=year, created__month=month)",
"nameRange": {
"startLine": 86,
"startColumn": 8,
"endLine": 86,
"endColumn": 14
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/managers.py:96",
"targetRef": "djstripe/managers.py:86",
"sourceSnippetRange": {
"startLine": 96,
"startColumn": 17,
"endLine": 96,
"endColumn": 23
},
"snippet": "during"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/managers.py:87",
"range": {
"startLine": 87,
"startColumn": 8,
"endLine": 87,
"endColumn": 77
},
"expression": "\"\"\"Return Charges between a certain time range based on `created`.\"\"\""
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "get_callback_function",
"ref": "djstripe/settings.py:129",
"definitionRange": {
"startLine": 129,
"startColumn": 4,
"endLine": 158,
"endColumn": 19
},
"language": "python",
"snippet": "def get_callback_function(self, setting_name, default=None):\n \"\"\"\n Resolve a callback function based on a setting name.\n\n If the setting value isn't set, default is returned. If the setting value\n is already a callable function, that value is used - If the setting value\n is a string, an attempt is made to import it. Anything else will result in\n a failed import causing ImportError to be raised.\n\n :param setting_name: The name of the setting to resolve a callback from.\n :type setting_name: string (``str``/``unicode``)\n :param default: The default to return if setting isn't populated.\n :type default: ``bool``\n :returns: The resolved callback function (if any).\n :type: ``callable``\n \"\"\"\n func = getattr(settings, setting_name, None)\n if not func:\n return default\n\n if callable(func):\n return func\n\n if isinstance(func, str):\n func = import_string(func)\n\n if not callable(func):\n raise ImproperlyConfigured(f\"{setting_name} must be callable.\")\n\n return func",
"nameRange": {
"startLine": 129,
"startColumn": 8,
"endLine": 129,
"endColumn": 29
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:54",
"targetRef": "djstripe/settings.py:129",
"sourceSnippetRange": {
"startLine": 54,
"startColumn": 20,
"endLine": 54,
"endColumn": 41
},
"snippet": "get_callback_function"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:61",
"targetRef": "djstripe/settings.py:129",
"sourceSnippetRange": {
"startLine": 61,
"startColumn": 20,
"endLine": 61,
"endColumn": 41
},
"snippet": "get_callback_function"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:78",
"targetRef": "djstripe/settings.py:129",
"sourceSnippetRange": {
"startLine": 78,
"startColumn": 20,
"endLine": 78,
"endColumn": 41
},
"snippet": "get_callback_function"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:223",
"targetRef": "djstripe/settings.py:129",
"sourceSnippetRange": {
"startLine": 223,
"startColumn": 24,
"endLine": 223,
"endColumn": 45
},
"snippet": "get_callback_function"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:96",
"targetRef": "djstripe/settings.py:129",
"sourceSnippetRange": {
"startLine": 96,
"startColumn": 42,
"endLine": 96,
"endColumn": 63
},
"snippet": "get_callback_function"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:104",
"targetRef": "djstripe/settings.py:129",
"sourceSnippetRange": {
"startLine": 104,
"startColumn": 42,
"endLine": 104,
"endColumn": 63
},
"snippet": "get_callback_function"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:113",
"targetRef": "djstripe/settings.py:129",
"sourceSnippetRange": {
"startLine": 113,
"startColumn": 39,
"endLine": 113,
"endColumn": 60
},
"snippet": "get_callback_function"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:119",
"targetRef": "djstripe/settings.py:129",
"sourceSnippetRange": {
"startLine": 119,
"startColumn": 39,
"endLine": 119,
"endColumn": 60
},
"snippet": "get_callback_function"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:125",
"targetRef": "djstripe/settings.py:129",
"sourceSnippetRange": {
"startLine": 125,
"startColumn": 39,
"endLine": 125,
"endColumn": 60
},
"snippet": "get_callback_function"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/settings.py:130",
"range": {
"startLine": 130,
"startColumn": 8,
"endLine": 144,
"endColumn": 11
},
"expression": "\"\"\"\n Resolve a callback function based on a setting name.\n\n If the setting value isn't set, default is returned. If the setting value\n is already a callable function, that value is used - If the setting value\n is a string, an attempt is made to import it. Anything else will result in\n a failed import causing ImportError to be raised.\n\n :param setting_name: The name of the setting to resolve a callback from.\n :type setting_name: string (``str``/``unicode``)\n :param default: The default to return if setting isn't populated.\n :type default: ``bool``\n :returns: The resolved callback function (if any).\n :type: ``callable``\n \"\"\""
},
{
"type": "variable",
"ref": "djstripe/settings.py:145",
"range": {
"startLine": 145,
"startColumn": 22,
"endLine": 145,
"endColumn": 52
},
"name": "settings",
"expression": "(settings, setting_name, None)",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "settings",
"ref": "__base_types__:15",
"definitionRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 28
},
"language": "python",
"snippet": "settings: LazySettings = ...",
"nameRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 8
}
}
},
{
"type": "variable",
"ref": "djstripe/settings.py:152",
"range": {
"startLine": 152,
"startColumn": 21,
"endLine": 152,
"endColumn": 32
},
"name": "str",
"expression": "(func, str)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "str",
"ref": "__base_types__:431",
"definitionRange": {
"startLine": 431,
"startColumn": 0,
"endLine": 600,
"endColumn": 47
},
"language": "python",
"snippet": "class str(Sequence[str]):\n @overload\n def __new__(cls, object: object = ...) -> Self: ...\n @overload\n def __new__(cls, object: ReadableBuffer, encoding: str = ..., errors: str = ...) -> Self: ...\n @overload\n def capitalize(self: LiteralString) -> LiteralString: ...\n @overload\n def capitalize(self) -> str: ... # type: ignore[misc]\n @overload\n def casefold(self: LiteralString) -> LiteralString: ...\n @overload\n def casefold(self) -> str: ... # type: ignore[misc]\n @overload\n def center(self: LiteralString, width: SupportsIndex, fillchar: LiteralString = \" \", /) -> LiteralString: ...\n @overload\n def center(self, width: SupportsIndex, fillchar: str = \" \", /) -> str: ... # type: ignore[misc]\n def count(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...\n def encode(self, encoding: str = \"utf-8\", errors: str = \"strict\") -> bytes: ...\n def endswith(\n self, suffix: str | tuple[str, ...], start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /\n ) -> bool: ...\n @overload\n def expandtabs(self: LiteralString, tabsize: SupportsIndex = 8) -> LiteralString: ...\n @overload\n def expandtabs(self, tabsize: SupportsIndex = 8) -> str: ... # type: ignore[misc]\n def find(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...\n @overload\n def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ...\n @overload\n def format(self, *args: object, **kwargs: object) -> str: ...\n def format_map(self, map: _FormatMapMapping) -> str: ...\n def index(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...\n def isalnum(self) -> bool: ...\n def isalpha(self) -> bool: ...\n def isascii(self) -> bool: ...\n def isdecimal(self) -> bool: ...\n def isdigit(self) -> bool: ...\n def isidentifier(self) -> bool: ...\n def islower(self) -> bool: ...\n def isnumeric(self) -> bool: ...\n def isprintable(self) -> bool: ...\n def isspace(self) -> bool: ...\n def istitle(self) -> bool: ...\n def isupper(self) -> bool: ...\n @overload\n def join(self: LiteralString, iterable: Iterable[LiteralString], /) -> LiteralString: ...\n @overload\n def join(self, iterable: Iterable[str], /) -> str: ... # type: ignore[misc]\n @overload\n def ljust(self: LiteralString, width: SupportsIndex, fillchar: LiteralString = \" \", /) -> LiteralString: ...\n @overload\n def ljust(self, width: SupportsIndex, fillchar: str = \" \", /) -> str: ... # type: ignore[misc]\n @overload\n def lower(self: LiteralString) -> LiteralString: ...\n @overload\n def lower(self) -> str: ... # type: ignore[misc]\n @overload\n def lstrip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...\n @overload\n def lstrip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]\n @overload\n def partition(self: LiteralString, sep: LiteralString, /) -> tuple[LiteralString, LiteralString, LiteralString]: ...\n @overload\n def partition(self, sep: str, /) -> tuple[str, str, str]: ... # type: ignore[misc]\n @overload\n def replace(self: LiteralString, old: LiteralString, new: LiteralString, count: SupportsIndex = -1, /) -> LiteralString: ...\n @overload\n def replace(self, old: str, new: str, count: SupportsIndex = -1, /) -> str: ... # type: ignore[misc]\n if sys.version_info >= (3, 9):\n @overload\n def removeprefix(self: LiteralString, prefix: LiteralString, /) -> LiteralString: ...\n @overload\n def removeprefix(self, prefix: str, /) -> str: ... # type: ignore[misc]\n @overload\n def removesuffix(self: LiteralString, suffix: LiteralString, /) -> LiteralString: ...\n @overload\n def removesuffix(self, suffix: str, /) -> str: ... # type: ignore[misc]\n\n def rfind(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...\n def rindex(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...\n @overload\n def rjust(self: LiteralString, width: SupportsIndex, fillchar: LiteralString = \" \", /) -> LiteralString: ...\n @overload\n def rjust(self, width: SupportsIndex, fillchar: str = \" \", /) -> str: ... # type: ignore[misc]\n @overload\n def rpartition(self: LiteralString, sep: LiteralString, /) -> tuple[LiteralString, LiteralString, LiteralString]: ...\n @overload\n def rpartition(self, sep: str, /) -> tuple[str, str, str]: ... # type: ignore[misc]\n @overload\n def rsplit(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...\n @overload\n def rsplit(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]\n @overload\n def rstrip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...\n @overload\n def rstrip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]\n @overload\n def split(self: LiteralString, sep: LiteralString | None = None, maxsplit: SupportsIndex = -1) -> list[LiteralString]: ...\n @overload\n def split(self, sep: str | None = None, maxsplit: SupportsIndex = -1) -> list[str]: ... # type: ignore[misc]\n @overload\n def splitlines(self: LiteralString, keepends: bool = False) -> list[LiteralString]: ...\n @overload\n def splitlines(self, keepends: bool = False) -> list[str]: ... # type: ignore[misc]\n def startswith(\n self, prefix: str | tuple[str, ...], start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /\n ) -> bool: ...\n @overload\n def strip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString: ...\n @overload\n def strip(self, chars: str | None = None, /) -> str: ... # type: ignore[misc]\n @overload\n def swapcase(self: LiteralString) -> LiteralString: ...\n @overload\n def swapcase(self) -> str: ... # type: ignore[misc]\n @overload\n def title(self: LiteralString) -> LiteralString: ...\n @overload\n def title(self) -> str: ... # type: ignore[misc]\n def translate(self, table: _TranslateTable, /) -> str: ...\n @overload\n def upper(self: LiteralString) -> LiteralString: ...\n @overload\n def upper(self) -> str: ... # type: ignore[misc]\n @overload\n def zfill(self: LiteralString, width: SupportsIndex, /) -> LiteralString: ...\n @overload\n def zfill(self, width: SupportsIndex, /) -> str: ... # type: ignore[misc]\n @staticmethod\n @overload\n def maketrans(x: dict[int, _T] | dict[str, _T] | dict[str | int, _T], /) -> dict[int, _T]: ...\n @staticmethod\n @overload\n def maketrans(x: str, y: str, /) -> dict[int, int]: ...\n @staticmethod\n @overload\n def maketrans(x: str, y: str, z: str, /) -> dict[int, int | None]: ...\n @overload\n def __add__(self: LiteralString, value: LiteralString, /) -> LiteralString: ...\n @overload\n def __add__(self, value: str, /) -> str: ... # type: ignore[misc]\n # Incompatible with Sequence.__contains__\n def __contains__(self, key: str, /) -> bool: ... # type: ignore[override]\n def __eq__(self, value: object, /) -> bool: ...\n def __ge__(self, value: str, /) -> bool: ...\n def __getitem__(self, key: SupportsIndex | slice, /) -> str: ...\n def __gt__(self, value: str, /) -> bool: ...\n def __hash__(self) -> int: ...\n @overload\n def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...\n @overload\n def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]\n def __le__(self, value: str, /) -> bool: ...\n def __len__(self) -> int: ...\n def __lt__(self, value: str, /) -> bool: ...\n @overload\n def __mod__(self: LiteralString, value: LiteralString | tuple[LiteralString, ...], /) -> LiteralString: ...\n @overload\n def __mod__(self, value: Any, /) -> str: ...\n @overload\n def __mul__(self: LiteralString, value: SupportsIndex, /) -> LiteralString: ...\n @overload\n def __mul__(self, value: SupportsIndex, /) -> str: ... # type: ignore[misc]\n def __ne__(self, value: object, /) -> bool: ...\n @overload\n def __rmul__(self: LiteralString, value: SupportsIndex, /) -> LiteralString: ...\n @overload\n def __rmul__(self, value: SupportsIndex, /) -> str: ... # type: ignore[misc]\n def __getnewargs__(self) -> tuple[str]: ...",
"nameRange": {
"startLine": 431,
"startColumn": 6,
"endLine": 431,
"endColumn": 9
}
}
},
{
"type": "call",
"ref": "djstripe/settings.py:153",
"range": {
"startLine": 153,
"startColumn": 19,
"endLine": 153,
"endColumn": 38
},
"name": "import_string",
"expression": "import_string(func)",
"definition": {
"type": "function",
"filePath": "__base_types__",
"name": "import_string",
"ref": "__base_types__:2",
"definitionRange": {
"startLine": 2,
"startColumn": 0,
"endLine": 2,
"endColumn": 47
},
"language": "python",
"snippet": "def import_string(dotted_path: str) -> Any: ...",
"nameRange": {
"startLine": 2,
"startColumn": 4,
"endLine": 2,
"endColumn": 17
}
}
},
{
"type": "call",
"ref": "djstripe/settings.py:156",
"range": {
"startLine": 156,
"startColumn": 18,
"endLine": 156,
"endColumn": 75
},
"name": "ImproperlyConfigured",
"expression": "ImproperlyConfigured(f\"{setting_name} must be callable.\")",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "ImproperlyConfigured",
"ref": "__base_types__:24",
"definitionRange": {
"startLine": 24,
"startColumn": 0,
"endLine": 24,
"endColumn": 42
},
"language": "python",
"snippet": "class ImproperlyConfigured(Exception): ...",
"nameRange": {
"startLine": 24,
"startColumn": 6,
"endLine": 24,
"endColumn": 26
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "stripe_class",
"ref": "djstripe/models/base.py:30",
"definitionRange": {
"startLine": 30,
"startColumn": 4,
"endLine": 30,
"endColumn": 49
},
"language": "python",
"snippet": "stripe_class: Type[APIResource] = APIResource",
"nameRange": {
"startLine": 30,
"startColumn": 4,
"endLine": 30,
"endColumn": 16
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_process_events.py:71",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 71,
"startColumn": 29,
"endLine": 71,
"endColumn": 41
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:111",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 111,
"startColumn": 17,
"endLine": 111,
"endColumn": 29
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:114",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 114,
"startColumn": 29,
"endLine": 114,
"endColumn": 41
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:156",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 156,
"startColumn": 48,
"endLine": 156,
"endColumn": 60
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:218",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 218,
"startColumn": 45,
"endLine": 218,
"endColumn": 57
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:491",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 491,
"startColumn": 35,
"endLine": 491,
"endColumn": 47
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:501",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 501,
"startColumn": 40,
"endLine": 501,
"endColumn": 52
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:53",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 53,
"startColumn": 27,
"endLine": 53,
"endColumn": 39
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:131",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 131,
"startColumn": 20,
"endLine": 131,
"endColumn": 32
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/api.py:94",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 94,
"startColumn": 31,
"endLine": 94,
"endColumn": 43
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:81",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 81,
"startColumn": 19,
"endLine": 81,
"endColumn": 31
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:235",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 235,
"startColumn": 20,
"endLine": 235,
"endColumn": 32
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:253",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 253,
"startColumn": 19,
"endLine": 253,
"endColumn": 31
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:276",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 276,
"startColumn": 20,
"endLine": 276,
"endColumn": 32
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:301",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 301,
"startColumn": 20,
"endLine": 301,
"endColumn": 32
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:576",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 576,
"startColumn": 39,
"endLine": 576,
"endColumn": 51
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:1113",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 1113,
"startColumn": 19,
"endLine": 1113,
"endColumn": 31
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:776",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 776,
"startColumn": 42,
"endLine": 776,
"endColumn": 54
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1422",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 1422,
"startColumn": 26,
"endLine": 1422,
"endColumn": 38
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1978",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 1978,
"startColumn": 44,
"endLine": 1978,
"endColumn": 56
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2007",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 2007,
"startColumn": 44,
"endLine": 2007,
"endColumn": 56
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:737",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 737,
"startColumn": 24,
"endLine": 737,
"endColumn": 36
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/webhooks.py:357",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 357,
"startColumn": 28,
"endLine": 357,
"endColumn": 40
},
"snippet": "stripe_class"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:506",
"targetRef": "djstripe/models/base.py:30",
"sourceSnippetRange": {
"startLine": 506,
"startColumn": 12,
"endLine": 506,
"endColumn": 24
},
"snippet": "stripe_class"
}
],
"expressions": []
},
{
"type": "method",
"filePath": "djstripe/views.py",
"name": "post",
"ref": "djstripe/views.py:30",
"definitionRange": {
"startLine": 30,
"startColumn": 4,
"endLine": 55,
"endColumn": 44
},
"language": "python",
"snippet": "def post(self, request, uuid):\n # https://stripe.com/docs/webhooks/signatures\n if \"stripe-signature\" not in request.headers:\n # Do not even attempt to process/store the event if there is\n # no signature in the headers so we avoid overfilling the db.\n logger.error(\"HTTP_STRIPE_SIGNATURE is missing\")\n return HttpResponseBadRequest()\n\n # If the UUID is invalid, this will throw a 404.\n # Note that this happens after the HTTP_STRIPE_SIGNATURE check on purpose.\n webhook_endpoint = get_object_or_404(WebhookEndpoint, djstripe_uuid=uuid)\n\n trigger = WebhookEventTrigger.from_request(\n request, webhook_endpoint=webhook_endpoint\n )\n\n if trigger.is_test_event:\n # Since we don't do signature verification, we have to skip trigger.valid\n return HttpResponse(\"Test webhook successfully received and discarded!\")\n\n if not trigger.valid:\n # Webhook Event did not validate, return 400\n logger.error(\"Trigger object did not validate\")\n return HttpResponseBadRequest()\n\n return HttpResponse(str(trigger.id))",
"nameRange": {
"startLine": 30,
"startColumn": 8,
"endLine": 30,
"endColumn": 12
},
"references": [
{
"targetRef": "djstripe/views.py:30",
"sourceSnippetRange": {
"startLine": 30,
"startColumn": 0,
"endLine": 30,
"endColumn": 35
},
"sourceRef": "djstripe/views.py:30",
"type": "from-search",
"snippet": " def post(self, request, uuid):\n"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/views.py:31",
"range": {
"startLine": 31,
"startColumn": 8,
"endLine": 31,
"endColumn": 53
},
"expression": "# https://stripe.com/docs/webhooks/signatures"
},
{
"type": "comment",
"ref": "djstripe/views.py:33",
"range": {
"startLine": 33,
"startColumn": 12,
"endLine": 33,
"endColumn": 72
},
"expression": "# Do not even attempt to process/store the event if there is"
},
{
"type": "comment",
"ref": "djstripe/views.py:34",
"range": {
"startLine": 34,
"startColumn": 12,
"endLine": 34,
"endColumn": 73
},
"expression": "# no signature in the headers so we avoid overfilling the db."
},
{
"type": "call",
"ref": "djstripe/views.py:35",
"range": {
"startLine": 35,
"startColumn": 12,
"endLine": 35,
"endColumn": 60
},
"name": "error",
"expression": "logger.error(\"HTTP_STRIPE_SIGNATURE is missing\")",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "error",
"ref": "__base_types__:1464",
"definitionRange": {
"startLine": 1464,
"startColumn": 4,
"endLine": 1474,
"endColumn": 49
},
"language": "python",
"snippet": "def error(self, msg, *args, **kwargs):\n \"\"\"\n Log 'msg % args' with severity 'ERROR'.\n\n To pass exception information, use the keyword argument exc_info with\n a true value, e.g.\n\n logger.error(\"Houston, we have a %s\", \"major problem\", exc_info=1)\n \"\"\"\n if self.isEnabledFor(ERROR):\n self._log(ERROR, msg, args, **kwargs)",
"nameRange": {
"startLine": 1464,
"startColumn": 8,
"endLine": 1464,
"endColumn": 13
}
}
},
{
"type": "variable",
"ref": "djstripe/views.py:35",
"range": {
"startLine": 35,
"startColumn": 12,
"endLine": 35,
"endColumn": 24
},
"name": "logger",
"expression": "logger.error",
"definition": {
"type": "expression",
"filePath": "djstripe/views.py",
"name": "logger",
"ref": "djstripe/views.py:14",
"definitionRange": {
"startLine": 14,
"startColumn": 0,
"endLine": 14,
"endColumn": 36
},
"language": "python",
"snippet": "logger = logging.getLogger(__name__)",
"nameRange": {
"startLine": 14,
"startColumn": 0,
"endLine": 14,
"endColumn": 6
}
}
},
{
"type": "call",
"ref": "djstripe/views.py:36",
"range": {
"startLine": 36,
"startColumn": 19,
"endLine": 36,
"endColumn": 43
},
"name": "HttpResponseBadRequest",
"expression": "HttpResponseBadRequest()",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "HttpResponseBadRequest",
"ref": "__base_types__:137",
"definitionRange": {
"startLine": 137,
"startColumn": 0,
"endLine": 137,
"endColumn": 47
},
"language": "python",
"snippet": "class HttpResponseBadRequest(HttpResponse): ...",
"nameRange": {
"startLine": 137,
"startColumn": 6,
"endLine": 137,
"endColumn": 28
}
}
},
{
"type": "comment",
"ref": "djstripe/views.py:38",
"range": {
"startLine": 38,
"startColumn": 8,
"endLine": 38,
"endColumn": 56
},
"expression": "# If the UUID is invalid, this will throw a 404."
},
{
"type": "comment",
"ref": "djstripe/views.py:39",
"range": {
"startLine": 39,
"startColumn": 8,
"endLine": 39,
"endColumn": 82
},
"expression": "# Note that this happens after the HTTP_STRIPE_SIGNATURE check on purpose."
},
{
"type": "call",
"ref": "djstripe/views.py:40",
"range": {
"startLine": 40,
"startColumn": 27,
"endLine": 40,
"endColumn": 81
},
"name": "get_object_or_404",
"expression": "get_object_or_404(WebhookEndpoint, djstripe_uuid=uuid)",
"definition": {
"type": "function",
"filePath": "__base_types__",
"name": "get_object_or_404",
"ref": "__base_types__:55",
"definitionRange": {
"startLine": 55,
"startColumn": 0,
"endLine": 57,
"endColumn": 12
},
"language": "python",
"snippet": "def get_object_or_404(\n klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any\n) -> _T: ...",
"nameRange": {
"startLine": 55,
"startColumn": 4,
"endLine": 55,
"endColumn": 21
}
}
},
{
"type": "variable",
"ref": "djstripe/views.py:40",
"range": {
"startLine": 40,
"startColumn": 44,
"endLine": 40,
"endColumn": 81
},
"name": "WebhookEndpoint",
"expression": "(WebhookEndpoint, djstripe_uuid=uuid)",
"definition": {
"type": "class",
"filePath": "djstripe/models/webhooks.py",
"name": "WebhookEndpoint",
"ref": "djstripe/models/webhooks.py:24",
"definitionRange": {
"startLine": 24,
"startColumn": 0,
"endLine": 97,
"endColumn": 72
},
"language": "python",
"snippet": "class WebhookEndpoint(StripeModel):\n stripe_class = stripe.WebhookEndpoint\n stripe_dashboard_item_name = \"webhooks\"\n\n api_version = models.CharField(\n max_length=64,\n blank=True,\n help_text=(\n \"The API version events are rendered as for this webhook endpoint. Defaults\"\n \" to the configured Stripe API Version.\"\n ),\n default=djstripe_settings.STRIPE_API_VERSION,\n )\n enabled_events = JSONField(\n help_text=(\n \"The list of events to enable for this endpoint. ['*'] indicates that all\"\n \" events are enabled, except those that require explicit selection.\"\n )\n )\n secret = models.CharField(\n max_length=256,\n blank=True,\n editable=False,\n help_text=\"The endpoint's secret, used to generate webhook signatures.\",\n )\n status = StripeEnumField(\n enum=WebhookEndpointStatus,\n help_text=\"The status of the webhook. It can be enabled or disabled.\",\n )\n url = models.URLField(help_text=\"The URL of the webhook endpoint.\", max_length=2048)\n application = models.CharField(\n max_length=255,\n blank=True,\n help_text=\"The ID of the associated Connect application.\",\n )\n\n djstripe_uuid = models.UUIDField(\n unique=True,\n default=uuid4,\n help_text=\"A UUID specific to dj-stripe generated for the endpoint\",\n )\n djstripe_tolerance = models.PositiveSmallIntegerField(\n help_text=\"Controls the milliseconds tolerance which wards against replay attacks. Leave this to its default value unless you know what you're doing.\",\n default=stripe.Webhook.DEFAULT_TOLERANCE,\n )\n djstripe_validation_method = StripeEnumField(\n enum=WebhookEndpointValidation,\n help_text=\"Controls the webhook validation method.\",\n default=WebhookEndpointValidation.verify_signature,\n )\n\n def __str__(self):\n return self.url or str(self.djstripe_uuid)\n\n def _attach_objects_hook(\n self, cls, data, current_ids=None, api_key=djstripe_settings.STRIPE_SECRET_KEY\n ):\n \"\"\"\n Gets called by this object's create and sync methods just before save.\n Use this to populate fields before the model is saved.\n \"\"\"\n super()._attach_objects_hook(\n cls, data, current_ids=current_ids, api_key=api_key\n )\n self.djstripe_uuid = data.get(\"metadata\", {}).get(\"djstripe_uuid\")\n\n djstripe_tolerance = data.get(\"djstripe_tolerance\")\n # As djstripe_tolerance can be set to 0\n if djstripe_tolerance is not None:\n self.djstripe_tolerance = djstripe_tolerance\n\n djstripe_validation_method = data.get(\"djstripe_validation_method\")\n if djstripe_validation_method:\n self.djstripe_validation_method = djstripe_validation_method",
"nameRange": {
"startLine": 24,
"startColumn": 6,
"endLine": 24,
"endColumn": 21
}
}
},
{
"type": "call",
"ref": "djstripe/views.py:42",
"range": {
"startLine": 42,
"startColumn": 18,
"endLine": 44,
"endColumn": 9
},
"name": "from_request",
"expression": "WebhookEventTrigger.from_request(\n request, webhook_endpoint=webhook_endpoint\n )",
"definition": {
"type": "method",
"filePath": "djstripe/models/webhooks.py",
"name": "from_request",
"ref": "djstripe/models/webhooks.py:194",
"definitionRange": {
"startLine": 194,
"startColumn": 4,
"endLine": 279,
"endColumn": 18
},
"language": "python",
"snippet": "def from_request(cls, request, *, webhook_endpoint: WebhookEndpoint):\n \"\"\"\n Create, validate and process a WebhookEventTrigger given a Django\n request object.\n\n The process is three-fold:\n 1. Create a WebhookEventTrigger object from a Django request.\n 2. Validate the WebhookEventTrigger as a Stripe event using the API.\n 3. If valid, process it into an Event object (and child resource).\n \"\"\"\n\n try:\n body = request.body.decode(request.encoding or \"utf-8\")\n except Exception:\n body = \"(error decoding body)\"\n\n ip = get_remote_ip(request)\n\n try:\n data = json.loads(body)\n except json.JSONDecodeError:\n data = {}\n\n stripe_account = StripeModel._find_owner_account(data=data)\n secret = webhook_endpoint.secret\n\n obj = cls.objects.create(\n headers=dict(request.headers),\n body=body,\n remote_ip=ip,\n stripe_trigger_account=stripe_account,\n webhook_endpoint=webhook_endpoint,\n )\n api_key = (\n stripe_account.default_api_key\n or djstripe_settings.get_default_api_key(obj.livemode)\n )\n\n try:\n # Validate the webhook first\n signals.webhook_pre_validate.send(sender=cls, instance=obj)\n\n # Default to per Webhook Endpoint Tolerance\n obj.valid = obj.validate(\n secret=secret,\n api_key=api_key,\n )\n\n # send post webhook validate signal\n signals.webhook_post_validate.send(\n sender=cls, instance=obj, valid=obj.valid\n )\n\n if obj.valid:\n signals.webhook_pre_process.send(sender=cls, instance=obj)\n\n # todo this should be moved to per webhook endpoint callback\n if djstripe_settings.WEBHOOK_EVENT_CALLBACK:\n # If WEBHOOK_EVENT_CALLBACK, pass it for processing\n djstripe_settings.WEBHOOK_EVENT_CALLBACK(obj, api_key=api_key)\n else:\n # Process the item (do not save it, it'll get saved below)\n obj.process(save=False, api_key=api_key)\n signals.webhook_post_process.send(\n sender=cls, instance=obj, api_key=api_key\n )\n except Exception as e:\n max_length = cls._meta.get_field(\"exception\").max_length\n obj.exception = str(e)[:max_length]\n obj.traceback = format_exc()\n\n # Send the exception as the webhook_processing_error signal\n signals.webhook_processing_error.send(\n sender=cls,\n instance=obj,\n api_key=api_key,\n exception=e,\n data=getattr(e, \"http_body\", \"\"),\n )\n\n # re-raise the exception so Django sees it\n raise e\n finally:\n obj.save()\n\n return obj",
"nameRange": {
"startLine": 194,
"startColumn": 8,
"endLine": 194,
"endColumn": 20
}
}
},
{
"type": "variable",
"ref": "djstripe/views.py:42",
"range": {
"startLine": 42,
"startColumn": 18,
"endLine": 42,
"endColumn": 50
},
"name": "WebhookEventTrigger",
"expression": "WebhookEventTrigger.from_request",
"definition": {
"type": "class",
"filePath": "djstripe/models/webhooks.py",
"name": "WebhookEventTrigger",
"ref": "djstripe/models/webhooks.py:132",
"definitionRange": {
"startLine": 132,
"startColumn": 0,
"endLine": 375,
"endColumn": 25
},
"language": "python",
"snippet": "class WebhookEventTrigger(models.Model):\n \"\"\"\n An instance of a request that reached the server endpoint for Stripe webhooks.\n\n Webhook Events are initially **UNTRUSTED**, as it is possible for any web entity to\n post any data to our webhook url. Data posted may be valid Stripe information,\n garbage, or even malicious.\n The 'valid' flag in this model monitors this.\n \"\"\"\n\n id = models.BigAutoField(primary_key=True)\n remote_ip = models.GenericIPAddressField(\n help_text=\"IP address of the request client.\"\n )\n headers = JSONField()\n body = models.TextField(blank=True)\n valid = models.BooleanField(\n default=False,\n help_text=\"Whether or not the webhook event has passed validation\",\n )\n processed = models.BooleanField(\n default=False,\n help_text=\"Whether or not the webhook event has been successfully processed\",\n )\n exception = models.CharField(max_length=128, blank=True)\n traceback = models.TextField(\n blank=True, help_text=\"Traceback if an exception was thrown during processing\"\n )\n event = StripeForeignKey(\n \"Event\",\n on_delete=models.SET_NULL,\n null=True,\n blank=True,\n help_text=\"Event object contained in the (valid) Webhook\",\n )\n djstripe_version = models.CharField(\n max_length=32,\n default=_get_version, # Needs to be a callable, otherwise it's a db default.\n help_text=\"The version of dj-stripe when the webhook was received\",\n )\n created = models.DateTimeField(auto_now_add=True)\n updated = models.DateTimeField(auto_now=True)\n stripe_trigger_account = StripeForeignKey(\n \"djstripe.Account\",\n on_delete=models.CASCADE,\n to_field=\"id\",\n null=True,\n blank=True,\n help_text=\"The Stripe Account this object belongs to.\",\n )\n webhook_endpoint = StripeForeignKey(\n \"WebhookEndpoint\",\n on_delete=models.SET_NULL,\n null=True,\n blank=True,\n help_text=\"The endpoint this webhook was received on\",\n )\n\n def __str__(self):\n return f\"id={self.id}, valid={self.valid}, processed={self.processed}\"\n\n @classmethod\n def from_request(cls, request, *, webhook_endpoint: WebhookEndpoint):\n \"\"\"\n Create, validate and process a WebhookEventTrigger given a Django\n request object.\n\n The process is three-fold:\n 1. Create a WebhookEventTrigger object from a Django request.\n 2. Validate the WebhookEventTrigger as a Stripe event using the API.\n 3. If valid, process it into an Event object (and child resource).\n \"\"\"\n\n try:\n body = request.body.decode(request.encoding or \"utf-8\")\n except Exception:\n body = \"(error decoding body)\"\n\n ip = get_remote_ip(request)\n\n try:\n data = json.loads(body)\n except json.JSONDecodeError:\n data = {}\n\n stripe_account = StripeModel._find_owner_account(data=data)\n secret = webhook_endpoint.secret\n\n obj = cls.objects.create(\n headers=dict(request.headers),\n body=body,\n remote_ip=ip,\n stripe_trigger_account=stripe_account,\n webhook_endpoint=webhook_endpoint,\n )\n api_key = (\n stripe_account.default_api_key\n or djstripe_settings.get_default_api_key(obj.livemode)\n )\n\n try:\n # Validate the webhook first\n signals.webhook_pre_validate.send(sender=cls, instance=obj)\n\n # Default to per Webhook Endpoint Tolerance\n obj.valid = obj.validate(\n secret=secret,\n api_key=api_key,\n )\n\n # send post webhook validate signal\n signals.webhook_post_validate.send(\n sender=cls, instance=obj, valid=obj.valid\n )\n\n if obj.valid:\n signals.webhook_pre_process.send(sender=cls, instance=obj)\n\n # todo this should be moved to per webhook endpoint callback\n if djstripe_settings.WEBHOOK_EVENT_CALLBACK:\n # If WEBHOOK_EVENT_CALLBACK, pass it for processing\n djstripe_settings.WEBHOOK_EVENT_CALLBACK(obj, api_key=api_key)\n else:\n # Process the item (do not save it, it'll get saved below)\n obj.process(save=False, api_key=api_key)\n signals.webhook_post_process.send(\n sender=cls, instance=obj, api_key=api_key\n )\n except Exception as e:\n max_length = cls._meta.get_field(\"exception\").max_length\n obj.exception = str(e)[:max_length]\n obj.traceback = format_exc()\n\n # Send the exception as the webhook_processing_error signal\n signals.webhook_processing_error.send(\n sender=cls,\n instance=obj,\n api_key=api_key,\n exception=e,\n data=getattr(e, \"http_body\", \"\"),\n )\n\n # re-raise the exception so Django sees it\n raise e\n finally:\n obj.save()\n\n return obj\n\n @cached_property\n def json_body(self):\n try:\n return json.loads(self.body)\n except ValueError:\n return {}\n\n @property\n def is_test_event(self):\n event_id = self.json_body.get(\"id\")\n return event_id and event_id.endswith(\"_00000000000000\")\n\n def verify_signature(self, secret: str, tolerance: int) -> bool:\n if not secret:\n raise ValueError(\"Cannot verify event signature without a secret\")\n\n # HTTP headers are case-insensitive, but we store them as a dict.\n headers = CaseInsensitiveMapping(self.headers)\n signature = headers.get(\"stripe-signature\")\n\n try:\n stripe.WebhookSignature.verify_header(\n self.body, signature, secret, tolerance\n )\n except stripe.error.SignatureVerificationError:\n logger.exception(\"Failed to verify header\")\n return False\n else:\n return True\n\n def validate(\n self,\n api_key: str,\n secret: str,\n ):\n \"\"\"\n The original contents of the Event message must be confirmed by\n refetching it and comparing the fetched data with the original data.\n\n This function makes an API call to Stripe to redownload the Event data\n and returns whether or not it matches the WebhookEventTrigger data.\n \"\"\"\n\n local_data = self.json_body\n if \"id\" not in local_data or \"livemode\" not in local_data:\n logger.error(\n '\"id\" not in json body or \"livemode\" not in json body(%s)', local_data\n )\n return False\n\n if self.is_test_event:\n logger.info(\"Test webhook received and discarded: %s\", local_data)\n return False\n\n validation_method = self.webhook_endpoint.djstripe_validation_method\n\n if validation_method == WebhookEndpointValidation.none:\n # validation disabled\n warnings.warn(\"WEBHOOK VALIDATION is disabled.\")\n return True\n elif validation_method == WebhookEndpointValidation.verify_signature:\n if settings.DEBUG:\n # In debug mode, allow overriding the webhook secret with\n # the x-djstripe-webhook-secret header.\n # (used for stripe cli webhook forwarding)\n headers = CaseInsensitiveMapping(self.headers)\n local_secret = headers.get(\"x-djstripe-webhook-secret\")\n secret = local_secret if local_secret else secret\n return self.verify_signature(\n secret=secret, tolerance=self.webhook_endpoint.djstripe_tolerance\n )\n\n livemode = local_data[\"livemode\"]\n api_key = api_key or djstripe_settings.get_default_api_key(livemode)\n\n # Retrieve the event using the api_version specified in itself\n remote_data = Event.stripe_class.retrieve(\n id=local_data[\"id\"],\n api_key=api_key,\n stripe_version=local_data[\"api_version\"],\n )\n\n return local_data[\"data\"] == remote_data[\"data\"]\n\n def process(self, save=True, api_key: str = None):\n # Reset traceback and exception in case of reprocessing\n self.exception = \"\"\n self.traceback = \"\"\n\n self.event = Event.process(self.json_body, api_key=api_key)\n self.processed = True\n if save:\n self.save()\n\n return self.event",
"nameRange": {
"startLine": 132,
"startColumn": 6,
"endLine": 132,
"endColumn": 25
}
}
},
{
"type": "expression",
"ref": "djstripe/views.py:46",
"range": {
"startLine": 46,
"startColumn": 8,
"endLine": 48,
"endColumn": 84
},
"name": "is_test_event",
"expression": "if trigger.is_test_event:\n # Since we don't do signature verification, we have to skip trigger.valid\n return HttpResponse(\"Test webhook successfully received and discarded!\")",
"definition": {
"type": "method",
"filePath": "djstripe/models/webhooks.py",
"name": "is_test_event",
"ref": "djstripe/models/webhooks.py:289",
"definitionRange": {
"startLine": 289,
"startColumn": 4,
"endLine": 291,
"endColumn": 64
},
"language": "python",
"snippet": "def is_test_event(self):\n event_id = self.json_body.get(\"id\")\n return event_id and event_id.endswith(\"_00000000000000\")",
"nameRange": {
"startLine": 289,
"startColumn": 8,
"endLine": 289,
"endColumn": 21
}
}
},
{
"type": "comment",
"ref": "djstripe/views.py:47",
"range": {
"startLine": 47,
"startColumn": 12,
"endLine": 47,
"endColumn": 85
},
"expression": "# Since we don't do signature verification, we have to skip trigger.valid"
},
{
"type": "call",
"ref": "djstripe/views.py:48",
"range": {
"startLine": 48,
"startColumn": 19,
"endLine": 48,
"endColumn": 84
},
"name": "HttpResponse",
"expression": "HttpResponse(\"Test webhook successfully received and discarded!\")",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "HttpResponse",
"ref": "__base_types__:72",
"definitionRange": {
"startLine": 72,
"startColumn": 0,
"endLine": 99,
"endColumn": 30
},
"language": "python",
"snippet": "class HttpResponse(HttpResponseBase, Iterable[bytes]):\n csrf_cookie_set: bool\n redirect_chain: list[tuple[str, int]]\n sameorigin: bool\n test_server_port: str\n test_was_secure_request: bool\n xframe_options_exempt: bool\n streaming: bool\n def __init__(self, content: Any = ..., *args: Any, **kwargs: Any) -> None: ...\n def serialize(self) -> bytes: ...\n @property\n def content(self) -> bytes: ...\n def __iter__(self) -> Iterator[bytes]: ...\n def write(self, content: str | bytes) -> None: ...\n def tell(self) -> int: ...\n def getvalue(self) -> bytes: ...\n def writable(self) -> bool: ...\n def writelines(self, lines: Iterable[str | bytes]) -> None: ...\n\n # Attributes assigned by monkey-patching in test client ClientHandler.__call__()\n wsgi_request: WSGIRequest\n # Attributes assigned by monkey-patching in test client Client.request()\n client: Client\n request: dict[str, Any]\n templates: list[Template]\n context: Context\n resolver_match: ResolverMatch\n def json(self) -> Any: ...",
"nameRange": {
"startLine": 72,
"startColumn": 6,
"endLine": 72,
"endColumn": 18
}
}
},
{
"type": "comment",
"ref": "djstripe/views.py:51",
"range": {
"startLine": 51,
"startColumn": 12,
"endLine": 51,
"endColumn": 56
},
"expression": "# Webhook Event did not validate, return 400"
},
{
"type": "variable",
"ref": "djstripe/views.py:55",
"range": {
"startLine": 55,
"startColumn": 31,
"endLine": 55,
"endColumn": 43
},
"name": "id",
"expression": "(trigger.id)",
"definition": {
"type": "class_property",
"filePath": "djstripe/models/webhooks.py",
"name": "id",
"ref": "djstripe/models/webhooks.py:142",
"definitionRange": {
"startLine": 142,
"startColumn": 4,
"endLine": 142,
"endColumn": 46
},
"language": "python",
"snippet": "id = models.BigAutoField(primary_key=True)",
"nameRange": {
"startLine": 142,
"startColumn": 4,
"endLine": 142,
"endColumn": 6
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "__str__",
"ref": "djstripe/models/account.py:68",
"definitionRange": {
"startLine": 68,
"startColumn": 4,
"endLine": 75,
"endColumn": 9
},
"language": "python",
"snippet": "def __str__(self):\n settings = self.stripe_data.get(\"settings\") or {}\n business_profile = self.stripe_data.get(\"business_profile\") or {}\n return (\n settings.get(\"dashboard\", {}).get(\"display_name\")\n or business_profile.get(\"name\")\n or super().__str__()\n )",
"nameRange": {
"startLine": 68,
"startColumn": 8,
"endLine": 68,
"endColumn": 15
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:74",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 74,
"startColumn": 23,
"endLine": 74,
"endColumn": 30
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/api.py:75",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 75,
"startColumn": 8,
"endLine": 75,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:1119",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 1119,
"startColumn": 8,
"endLine": 1119,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:1136",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 1136,
"startColumn": 8,
"endLine": 1136,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:180",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 180,
"startColumn": 8,
"endLine": 180,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:723",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 723,
"startColumn": 8,
"endLine": 723,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1240",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 1240,
"startColumn": 8,
"endLine": 1240,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1469",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 1469,
"startColumn": 8,
"endLine": 1469,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2102",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 2102,
"startColumn": 8,
"endLine": 2102,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2130",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 2130,
"startColumn": 8,
"endLine": 2130,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2165",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 2165,
"startColumn": 8,
"endLine": 2165,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2298",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 2298,
"startColumn": 8,
"endLine": 2298,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2337",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 2337,
"startColumn": 8,
"endLine": 2337,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2406",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 2406,
"startColumn": 8,
"endLine": 2406,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:184",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 184,
"startColumn": 8,
"endLine": 184,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:254",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 254,
"startColumn": 8,
"endLine": 254,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:89",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 89,
"startColumn": 8,
"endLine": 89,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:390",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 390,
"startColumn": 8,
"endLine": 390,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:664",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 664,
"startColumn": 8,
"endLine": 664,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:834",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 834,
"startColumn": 8,
"endLine": 834,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1485",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 1485,
"startColumn": 8,
"endLine": 1485,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1585",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 1585,
"startColumn": 8,
"endLine": 1585,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1698",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 1698,
"startColumn": 8,
"endLine": 1698,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1725",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 1725,
"startColumn": 8,
"endLine": 1725,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1917",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 1917,
"startColumn": 8,
"endLine": 1917,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:2064",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 2064,
"startColumn": 8,
"endLine": 2064,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:2214",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 2214,
"startColumn": 8,
"endLine": 2214,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:2369",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 2369,
"startColumn": 8,
"endLine": 2369,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:2491",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 2491,
"startColumn": 8,
"endLine": 2491,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:510",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 510,
"startColumn": 8,
"endLine": 510,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:674",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 674,
"startColumn": 8,
"endLine": 674,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:852",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 852,
"startColumn": 8,
"endLine": 852,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/sigma.py:49",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 49,
"startColumn": 8,
"endLine": 49,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/webhooks.py:75",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 75,
"startColumn": 8,
"endLine": 75,
"endColumn": 15
},
"snippet": "__str__"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/webhooks.py:190",
"targetRef": "djstripe/models/account.py:68",
"sourceSnippetRange": {
"startLine": 190,
"startColumn": 8,
"endLine": 190,
"endColumn": 15
},
"snippet": "__str__"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/account.py:72",
"range": {
"startLine": 72,
"startColumn": 12,
"endLine": 72,
"endColumn": 41
},
"name": "get",
"expression": "settings.get(\"dashboard\", {})",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "get",
"ref": "__base_types__:1064",
"definitionRange": {
"startLine": 1064,
"startColumn": 4,
"endLine": 1064,
"endColumn": 49
},
"language": "python",
"snippet": "def get(self, key: _KT, /) -> _VT | None: ...",
"nameRange": {
"startLine": 1064,
"startColumn": 8,
"endLine": 1064,
"endColumn": 11
}
}
},
{
"type": "call",
"ref": "djstripe/models/account.py:74",
"range": {
"startLine": 74,
"startColumn": 15,
"endLine": 74,
"endColumn": 32
},
"name": "__str__",
"expression": "super().__str__()",
"definition": {
"type": "method",
"filePath": "djstripe/models/base.py",
"name": "__str__",
"ref": "djstripe/models/base.py:1119",
"definitionRange": {
"startLine": 1119,
"startColumn": 4,
"endLine": 1120,
"endColumn": 32
},
"language": "python",
"snippet": "def __str__(self):\n return f\"<id={self.id}>\"",
"nameRange": {
"startLine": 1119,
"startColumn": 8,
"endLine": 1119,
"endColumn": 15
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/managers.py",
"name": "paid_totals_for",
"ref": "djstripe/managers.py:76",
"definitionRange": {
"startLine": 76,
"startColumn": 4,
"endLine": 80,
"endColumn": 84
},
"language": "python",
"snippet": "def paid_totals_for(self, year, month):\n \"\"\"\n Return paid Transfers during a certain year, month with total amounts annotated.\n \"\"\"\n return self.during(year, month).aggregate(total_amount=models.Sum(\"amount\"))",
"nameRange": {
"startLine": 76,
"startColumn": 8,
"endLine": 76,
"endColumn": 23
},
"references": [
{
"targetRef": "djstripe/managers.py:76",
"sourceSnippetRange": {
"startLine": 76,
"startColumn": 0,
"endLine": 76,
"endColumn": 44
},
"sourceRef": "djstripe/managers.py:76",
"type": "from-search",
"snippet": " def paid_totals_for(self, year, month):\n"
},
{
"targetRef": "djstripe/managers.py:76",
"sourceSnippetRange": {
"startLine": 90,
"startColumn": 0,
"endLine": 90,
"endColumn": 44
},
"sourceRef": "djstripe/managers.py:90",
"type": "from-search",
"snippet": " def paid_totals_for(self, year, month):\n"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/managers.py:77",
"range": {
"startLine": 77,
"startColumn": 8,
"endLine": 79,
"endColumn": 11
},
"expression": "\"\"\"\n Return paid Transfers during a certain year, month with total amounts annotated.\n \"\"\""
},
{
"type": "call",
"ref": "djstripe/managers.py:80",
"range": {
"startLine": 80,
"startColumn": 15,
"endLine": 80,
"endColumn": 39
},
"name": "during",
"expression": "self.during(year, month)",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "during",
"ref": "djstripe/managers.py:72",
"definitionRange": {
"startLine": 72,
"startColumn": 4,
"endLine": 74,
"endColumn": 68
},
"language": "python",
"snippet": "def during(self, year, month):\n \"\"\"Return Transfers between a certain time range.\"\"\"\n return self.filter(created__year=year, created__month=month)",
"nameRange": {
"startLine": 72,
"startColumn": 8,
"endLine": 72,
"endColumn": 14
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:80",
"range": {
"startLine": 80,
"startColumn": 15,
"endLine": 80,
"endColumn": 84
},
"name": "aggregate",
"expression": "self.during(year, month).aggregate(total_amount=models.Sum(\"amount\"))",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "aggregate",
"ref": "__base_types__:45",
"definitionRange": {
"startLine": 45,
"startColumn": 4,
"endLine": 45,
"endColumn": 73
},
"language": "python",
"snippet": "def aggregate(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...",
"nameRange": {
"startLine": 45,
"startColumn": 8,
"endLine": 45,
"endColumn": 17
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:80",
"range": {
"startLine": 80,
"startColumn": 63,
"endLine": 80,
"endColumn": 83
},
"name": "Sum",
"expression": "models.Sum(\"amount\")",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Sum",
"ref": "__base_types__:21",
"definitionRange": {
"startLine": 21,
"startColumn": 0,
"endLine": 21,
"endColumn": 25
},
"language": "python",
"snippet": "class Sum(Aggregate): ...",
"nameRange": {
"startLine": 21,
"startColumn": 6,
"endLine": 21,
"endColumn": 9
}
}
},
{
"type": "variable",
"ref": "djstripe/managers.py:80",
"range": {
"startLine": 80,
"startColumn": 63,
"endLine": 80,
"endColumn": 73
},
"name": "models",
"expression": "models.Sum",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "_get_idempotency_key",
"ref": "djstripe/settings.py:160",
"definitionRange": {
"startLine": 160,
"startColumn": 4,
"endLine": 167,
"endColumn": 40
},
"language": "python",
"snippet": "def _get_idempotency_key(self, object_type, action, livemode) -> str:\n from .models import IdempotencyKey\n\n action = f\"{object_type}:{action}\"\n idempotency_key, _created = IdempotencyKey.objects.get_or_create(\n action=action, livemode=livemode\n )\n return str(idempotency_key.uuid)",
"nameRange": {
"startLine": 160,
"startColumn": 8,
"endLine": 160,
"endColumn": 28
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/settings.py:62",
"targetRef": "djstripe/settings.py:160",
"sourceSnippetRange": {
"startLine": 62,
"startColumn": 54,
"endLine": 62,
"endColumn": 74
},
"snippet": "_get_idempotency_key"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/settings.py:164",
"range": {
"startLine": 164,
"startColumn": 36,
"endLine": 164,
"endColumn": 58
},
"name": "IdempotencyKey",
"expression": "IdempotencyKey.objects",
"definition": {
"type": "class",
"filePath": "djstripe/models/base.py",
"name": "IdempotencyKey",
"ref": "djstripe/models/base.py:1123",
"definitionRange": {
"startLine": 1123,
"startColumn": 0,
"endLine": 1141,
"endColumn": 66
},
"language": "python",
"snippet": "class IdempotencyKey(models.Model):\n uuid = models.UUIDField(\n max_length=36, primary_key=True, editable=False, default=uuid.uuid4\n )\n action = models.CharField(max_length=100)\n livemode = models.BooleanField(\n help_text=\"Whether the key was used in live or test mode.\"\n )\n created = models.DateTimeField(auto_now_add=True)\n\n class Meta:\n unique_together = (\"action\", \"livemode\")\n\n def __str__(self):\n return str(self.uuid)\n\n @property\n def is_expired(self) -> bool:\n return timezone.now() > self.created + timedelta(hours=24)",
"nameRange": {
"startLine": 1123,
"startColumn": 6,
"endLine": 1123,
"endColumn": 20
}
}
},
{
"type": "call",
"ref": "djstripe/settings.py:164",
"range": {
"startLine": 164,
"startColumn": 36,
"endLine": 166,
"endColumn": 9
},
"name": "get_or_create",
"expression": "IdempotencyKey.objects.get_or_create(\n action=action, livemode=livemode\n )",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "get_or_create",
"ref": "__base_types__:75",
"definitionRange": {
"startLine": 75,
"startColumn": 4,
"endLine": 77,
"endColumn": 29
},
"language": "python",
"snippet": "def get_or_create(\n self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any\n ) -> tuple[_T, bool]: ...",
"nameRange": {
"startLine": 75,
"startColumn": 8,
"endLine": 75,
"endColumn": 21
}
}
},
{
"type": "variable",
"ref": "djstripe/settings.py:167",
"range": {
"startLine": 167,
"startColumn": 18,
"endLine": 167,
"endColumn": 40
},
"name": "uuid",
"expression": "(idempotency_key.uuid)",
"definition": {
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "uuid",
"ref": "djstripe/models/base.py:1124",
"definitionRange": {
"startLine": 1124,
"startColumn": 4,
"endLine": 1126,
"endColumn": 5
},
"language": "python",
"snippet": "uuid = models.UUIDField(\n max_length=36, primary_key=True, editable=False, default=uuid.uuid4\n )",
"nameRange": {
"startLine": 1124,
"startColumn": 4,
"endLine": 1124,
"endColumn": 8
}
}
}
]
},
{
"type": "class",
"filePath": "djstripe/managers.py",
"name": "TransferManager",
"ref": "djstripe/managers.py:69",
"definitionRange": {
"startLine": 69,
"startColumn": 0,
"endLine": 80,
"endColumn": 84
},
"language": "python",
"snippet": "class TransferManager(models.Manager):\n \"\"\"Manager used by models.Transfer.\"\"\"\n\n def during(self, year, month):\n \"\"\"Return Transfers between a certain time range.\"\"\"\n return self.filter(created__year=year, created__month=month)\n\n def paid_totals_for(self, year, month):\n \"\"\"\n Return paid Transfers during a certain year, month with total amounts annotated.\n \"\"\"\n return self.during(year, month).aggregate(total_amount=models.Sum(\"amount\"))",
"nameRange": {
"startLine": 69,
"startColumn": 6,
"endLine": 69,
"endColumn": 21
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:15",
"targetRef": "djstripe/managers.py:69",
"sourceSnippetRange": {
"startLine": 15,
"startColumn": 23,
"endLine": 15,
"endColumn": 38
},
"snippet": "TransferManager"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:114",
"targetRef": "djstripe/managers.py:69",
"sourceSnippetRange": {
"startLine": 114,
"startColumn": 14,
"endLine": 114,
"endColumn": 29
},
"snippet": "TransferManager"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/managers.py:69",
"range": {
"startLine": 69,
"startColumn": 21,
"endLine": 69,
"endColumn": 37
},
"name": "Manager",
"expression": "(models.Manager)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Manager",
"ref": "__base_types__:39",
"definitionRange": {
"startLine": 39,
"startColumn": 0,
"endLine": 40,
"endColumn": 39
},
"language": "python",
"snippet": "class Manager(BaseManager[_T]):\n _queryset_class: type[QuerySet[_T]]",
"nameRange": {
"startLine": 39,
"startColumn": 6,
"endLine": 39,
"endColumn": 13
}
}
},
{
"type": "variable",
"ref": "djstripe/managers.py:69",
"range": {
"startLine": 69,
"startColumn": 22,
"endLine": 69,
"endColumn": 36
},
"name": "models",
"expression": "models.Manager",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
},
{
"type": "comment",
"ref": "djstripe/managers.py:70",
"range": {
"startLine": 70,
"startColumn": 4,
"endLine": 70,
"endColumn": 42
},
"expression": "\"\"\"Manager used by models.Transfer.\"\"\""
},
{
"type": "comment",
"ref": "djstripe/managers.py:73",
"range": {
"startLine": 73,
"startColumn": 8,
"endLine": 73,
"endColumn": 60
},
"expression": "\"\"\"Return Transfers between a certain time range.\"\"\""
},
{
"type": "variable",
"ref": "djstripe/managers.py:74",
"range": {
"startLine": 74,
"startColumn": 27,
"endLine": 74,
"endColumn": 45
},
"name": "year",
"expression": "created__year=year",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "during",
"ref": "djstripe/managers.py:72",
"definitionRange": {
"startLine": 72,
"startColumn": 4,
"endLine": 74,
"endColumn": 68
},
"language": "python",
"snippet": "def during(self, year, month):\n \"\"\"Return Transfers between a certain time range.\"\"\"\n return self.filter(created__year=year, created__month=month)",
"nameRange": {
"startLine": 72,
"startColumn": 8,
"endLine": 72,
"endColumn": 14
}
}
},
{
"type": "comment",
"ref": "djstripe/managers.py:77",
"range": {
"startLine": 77,
"startColumn": 8,
"endLine": 79,
"endColumn": 11
},
"expression": "\"\"\"\n Return paid Transfers during a certain year, month with total amounts annotated.\n \"\"\""
},
{
"type": "variable",
"ref": "djstripe/managers.py:80",
"range": {
"startLine": 80,
"startColumn": 26,
"endLine": 80,
"endColumn": 39
},
"name": "year",
"expression": "(year, month)",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "paid_totals_for",
"ref": "djstripe/managers.py:76",
"definitionRange": {
"startLine": 76,
"startColumn": 4,
"endLine": 80,
"endColumn": 84
},
"language": "python",
"snippet": "def paid_totals_for(self, year, month):\n \"\"\"\n Return paid Transfers during a certain year, month with total amounts annotated.\n \"\"\"\n return self.during(year, month).aggregate(total_amount=models.Sum(\"amount\"))",
"nameRange": {
"startLine": 76,
"startColumn": 8,
"endLine": 76,
"endColumn": 23
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:80",
"range": {
"startLine": 80,
"startColumn": 15,
"endLine": 80,
"endColumn": 84
},
"name": "aggregate",
"expression": "self.during(year, month).aggregate(total_amount=models.Sum(\"amount\"))",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "aggregate",
"ref": "__base_types__:45",
"definitionRange": {
"startLine": 45,
"startColumn": 4,
"endLine": 45,
"endColumn": 73
},
"language": "python",
"snippet": "def aggregate(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...",
"nameRange": {
"startLine": 45,
"startColumn": 8,
"endLine": 45,
"endColumn": 17
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:80",
"range": {
"startLine": 80,
"startColumn": 63,
"endLine": 80,
"endColumn": 83
},
"name": "Sum",
"expression": "models.Sum(\"amount\")",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Sum",
"ref": "__base_types__:21",
"definitionRange": {
"startLine": 21,
"startColumn": 0,
"endLine": 21,
"endColumn": 25
},
"language": "python",
"snippet": "class Sum(Aggregate): ...",
"nameRange": {
"startLine": 21,
"startColumn": 6,
"endLine": 21,
"endColumn": 9
}
}
}
]
},
{
"type": "class",
"filePath": "djstripe/views.py",
"name": "ProcessWebhookView",
"ref": "djstripe/views.py:18",
"definitionRange": {
"startLine": 18,
"startColumn": 0,
"endLine": 55,
"endColumn": 44
},
"language": "python",
"snippet": "class ProcessWebhookView(View):\n \"\"\"\n A Stripe Webhook handler view.\n\n This will create a WebhookEventTrigger instance, verify it,\n then attempt to process it.\n\n If the webhook cannot be verified, returns HTTP 400.\n\n If an exception happens during processing, returns HTTP 500.\n \"\"\"\n\n def post(self, request, uuid):\n # https://stripe.com/docs/webhooks/signatures\n if \"stripe-signature\" not in request.headers:\n # Do not even attempt to process/store the event if there is\n # no signature in the headers so we avoid overfilling the db.\n logger.error(\"HTTP_STRIPE_SIGNATURE is missing\")\n return HttpResponseBadRequest()\n\n # If the UUID is invalid, this will throw a 404.\n # Note that this happens after the HTTP_STRIPE_SIGNATURE check on purpose.\n webhook_endpoint = get_object_or_404(WebhookEndpoint, djstripe_uuid=uuid)\n\n trigger = WebhookEventTrigger.from_request(\n request, webhook_endpoint=webhook_endpoint\n )\n\n if trigger.is_test_event:\n # Since we don't do signature verification, we have to skip trigger.valid\n return HttpResponse(\"Test webhook successfully received and discarded!\")\n\n if not trigger.valid:\n # Webhook Event did not validate, return 400\n logger.error(\"Trigger object did not validate\")\n return HttpResponseBadRequest()\n\n return HttpResponse(str(trigger.id))",
"nameRange": {
"startLine": 18,
"startColumn": 6,
"endLine": 18,
"endColumn": 24
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/urls.py:20",
"targetRef": "djstripe/views.py:18",
"sourceSnippetRange": {
"startLine": 20,
"startColumn": 14,
"endLine": 20,
"endColumn": 32
},
"snippet": "ProcessWebhookView"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/views.py:18",
"range": {
"startLine": 18,
"startColumn": 24,
"endLine": 18,
"endColumn": 30
},
"name": "View",
"expression": "(View)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "View",
"ref": "__base_types__:8",
"definitionRange": {
"startLine": 8,
"startColumn": 0,
"endLine": 25,
"endColumn": 31
},
"language": "python",
"snippet": "class View:\n http_method_names: list[str] = ...\n request: http.HttpRequest = ...\n args: Any = ...\n kwargs: Any = ...\n def __init__(self, **kwargs: Any) -> None: ...\n @classmethod\n def as_view(cls, **initkwargs: Any) -> Callable[..., http.HttpResponse]: ...\n def setup(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> None: ...\n def dispatch(\n self, request: http.HttpRequest, *args: Any, **kwargs: Any\n ) -> http.HttpResponse: ...\n def http_method_not_allowed(\n self, request: http.HttpRequest, *args: Any, **kwargs: Any\n ) -> http.HttpResponse: ...\n def options(\n self, request: http.HttpRequest, *args: Any, **kwargs: Any\n ) -> http.HttpResponse: ...",
"nameRange": {
"startLine": 8,
"startColumn": 6,
"endLine": 8,
"endColumn": 10
}
}
},
{
"type": "comment",
"ref": "djstripe/views.py:19",
"range": {
"startLine": 19,
"startColumn": 4,
"endLine": 28,
"endColumn": 7
},
"expression": "\"\"\"\n A Stripe Webhook handler view.\n\n This will create a WebhookEventTrigger instance, verify it,\n then attempt to process it.\n\n If the webhook cannot be verified, returns HTTP 400.\n\n If an exception happens during processing, returns HTTP 500.\n \"\"\""
},
{
"type": "comment",
"ref": "djstripe/views.py:31",
"range": {
"startLine": 31,
"startColumn": 8,
"endLine": 31,
"endColumn": 53
},
"expression": "# https://stripe.com/docs/webhooks/signatures"
},
{
"type": "variable",
"ref": "djstripe/views.py:32",
"range": {
"startLine": 32,
"startColumn": 37,
"endLine": 32,
"endColumn": 52
},
"name": "request",
"expression": "request.headers",
"definition": {
"type": "method",
"filePath": "djstripe/views.py",
"name": "post",
"ref": "djstripe/views.py:30",
"definitionRange": {
"startLine": 30,
"startColumn": 4,
"endLine": 55,
"endColumn": 44
},
"language": "python",
"snippet": "def post(self, request, uuid):\n # https://stripe.com/docs/webhooks/signatures\n if \"stripe-signature\" not in request.headers:\n # Do not even attempt to process/store the event if there is\n # no signature in the headers so we avoid overfilling the db.\n logger.error(\"HTTP_STRIPE_SIGNATURE is missing\")\n return HttpResponseBadRequest()\n\n # If the UUID is invalid, this will throw a 404.\n # Note that this happens after the HTTP_STRIPE_SIGNATURE check on purpose.\n webhook_endpoint = get_object_or_404(WebhookEndpoint, djstripe_uuid=uuid)\n\n trigger = WebhookEventTrigger.from_request(\n request, webhook_endpoint=webhook_endpoint\n )\n\n if trigger.is_test_event:\n # Since we don't do signature verification, we have to skip trigger.valid\n return HttpResponse(\"Test webhook successfully received and discarded!\")\n\n if not trigger.valid:\n # Webhook Event did not validate, return 400\n logger.error(\"Trigger object did not validate\")\n return HttpResponseBadRequest()\n\n return HttpResponse(str(trigger.id))",
"nameRange": {
"startLine": 30,
"startColumn": 8,
"endLine": 30,
"endColumn": 12
}
}
},
{
"type": "comment",
"ref": "djstripe/views.py:33",
"range": {
"startLine": 33,
"startColumn": 12,
"endLine": 33,
"endColumn": 72
},
"expression": "# Do not even attempt to process/store the event if there is"
},
{
"type": "comment",
"ref": "djstripe/views.py:34",
"range": {
"startLine": 34,
"startColumn": 12,
"endLine": 34,
"endColumn": 73
},
"expression": "# no signature in the headers so we avoid overfilling the db."
},
{
"type": "call",
"ref": "djstripe/views.py:35",
"range": {
"startLine": 35,
"startColumn": 12,
"endLine": 35,
"endColumn": 60
},
"name": "error",
"expression": "logger.error(\"HTTP_STRIPE_SIGNATURE is missing\")",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "error",
"ref": "__base_types__:1464",
"definitionRange": {
"startLine": 1464,
"startColumn": 4,
"endLine": 1474,
"endColumn": 49
},
"language": "python",
"snippet": "def error(self, msg, *args, **kwargs):\n \"\"\"\n Log 'msg % args' with severity 'ERROR'.\n\n To pass exception information, use the keyword argument exc_info with\n a true value, e.g.\n\n logger.error(\"Houston, we have a %s\", \"major problem\", exc_info=1)\n \"\"\"\n if self.isEnabledFor(ERROR):\n self._log(ERROR, msg, args, **kwargs)",
"nameRange": {
"startLine": 1464,
"startColumn": 8,
"endLine": 1464,
"endColumn": 13
}
}
},
{
"type": "variable",
"ref": "djstripe/views.py:35",
"range": {
"startLine": 35,
"startColumn": 12,
"endLine": 35,
"endColumn": 24
},
"name": "logger",
"expression": "logger.error",
"definition": {
"type": "expression",
"filePath": "djstripe/views.py",
"name": "logger",
"ref": "djstripe/views.py:14",
"definitionRange": {
"startLine": 14,
"startColumn": 0,
"endLine": 14,
"endColumn": 36
},
"language": "python",
"snippet": "logger = logging.getLogger(__name__)",
"nameRange": {
"startLine": 14,
"startColumn": 0,
"endLine": 14,
"endColumn": 6
}
}
},
{
"type": "call",
"ref": "djstripe/views.py:36",
"range": {
"startLine": 36,
"startColumn": 19,
"endLine": 36,
"endColumn": 43
},
"name": "HttpResponseBadRequest",
"expression": "HttpResponseBadRequest()",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "HttpResponseBadRequest",
"ref": "__base_types__:137",
"definitionRange": {
"startLine": 137,
"startColumn": 0,
"endLine": 137,
"endColumn": 47
},
"language": "python",
"snippet": "class HttpResponseBadRequest(HttpResponse): ...",
"nameRange": {
"startLine": 137,
"startColumn": 6,
"endLine": 137,
"endColumn": 28
}
}
},
{
"type": "comment",
"ref": "djstripe/views.py:38",
"range": {
"startLine": 38,
"startColumn": 8,
"endLine": 38,
"endColumn": 56
},
"expression": "# If the UUID is invalid, this will throw a 404."
},
{
"type": "comment",
"ref": "djstripe/views.py:39",
"range": {
"startLine": 39,
"startColumn": 8,
"endLine": 39,
"endColumn": 82
},
"expression": "# Note that this happens after the HTTP_STRIPE_SIGNATURE check on purpose."
},
{
"type": "call",
"ref": "djstripe/views.py:40",
"range": {
"startLine": 40,
"startColumn": 27,
"endLine": 40,
"endColumn": 81
},
"name": "get_object_or_404",
"expression": "get_object_or_404(WebhookEndpoint, djstripe_uuid=uuid)",
"definition": {
"type": "function",
"filePath": "__base_types__",
"name": "get_object_or_404",
"ref": "__base_types__:55",
"definitionRange": {
"startLine": 55,
"startColumn": 0,
"endLine": 57,
"endColumn": 12
},
"language": "python",
"snippet": "def get_object_or_404(\n klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any\n) -> _T: ...",
"nameRange": {
"startLine": 55,
"startColumn": 4,
"endLine": 55,
"endColumn": 21
}
}
},
{
"type": "variable",
"ref": "djstripe/views.py:40",
"range": {
"startLine": 40,
"startColumn": 44,
"endLine": 40,
"endColumn": 81
},
"name": "WebhookEndpoint",
"expression": "(WebhookEndpoint, djstripe_uuid=uuid)",
"definition": {
"type": "class",
"filePath": "djstripe/models/webhooks.py",
"name": "WebhookEndpoint",
"ref": "djstripe/models/webhooks.py:24",
"definitionRange": {
"startLine": 24,
"startColumn": 0,
"endLine": 97,
"endColumn": 72
},
"language": "python",
"snippet": "class WebhookEndpoint(StripeModel):\n stripe_class = stripe.WebhookEndpoint\n stripe_dashboard_item_name = \"webhooks\"\n\n api_version = models.CharField(\n max_length=64,\n blank=True,\n help_text=(\n \"The API version events are rendered as for this webhook endpoint. Defaults\"\n \" to the configured Stripe API Version.\"\n ),\n default=djstripe_settings.STRIPE_API_VERSION,\n )\n enabled_events = JSONField(\n help_text=(\n \"The list of events to enable for this endpoint. ['*'] indicates that all\"\n \" events are enabled, except those that require explicit selection.\"\n )\n )\n secret = models.CharField(\n max_length=256,\n blank=True,\n editable=False,\n help_text=\"The endpoint's secret, used to generate webhook signatures.\",\n )\n status = StripeEnumField(\n enum=WebhookEndpointStatus,\n help_text=\"The status of the webhook. It can be enabled or disabled.\",\n )\n url = models.URLField(help_text=\"The URL of the webhook endpoint.\", max_length=2048)\n application = models.CharField(\n max_length=255,\n blank=True,\n help_text=\"The ID of the associated Connect application.\",\n )\n\n djstripe_uuid = models.UUIDField(\n unique=True,\n default=uuid4,\n help_text=\"A UUID specific to dj-stripe generated for the endpoint\",\n )\n djstripe_tolerance = models.PositiveSmallIntegerField(\n help_text=\"Controls the milliseconds tolerance which wards against replay attacks. Leave this to its default value unless you know what you're doing.\",\n default=stripe.Webhook.DEFAULT_TOLERANCE,\n )\n djstripe_validation_method = StripeEnumField(\n enum=WebhookEndpointValidation,\n help_text=\"Controls the webhook validation method.\",\n default=WebhookEndpointValidation.verify_signature,\n )\n\n def __str__(self):\n return self.url or str(self.djstripe_uuid)\n\n def _attach_objects_hook(\n self, cls, data, current_ids=None, api_key=djstripe_settings.STRIPE_SECRET_KEY\n ):\n \"\"\"\n Gets called by this object's create and sync methods just before save.\n Use this to populate fields before the model is saved.\n \"\"\"\n super()._attach_objects_hook(\n cls, data, current_ids=current_ids, api_key=api_key\n )\n self.djstripe_uuid = data.get(\"metadata\", {}).get(\"djstripe_uuid\")\n\n djstripe_tolerance = data.get(\"djstripe_tolerance\")\n # As djstripe_tolerance can be set to 0\n if djstripe_tolerance is not None:\n self.djstripe_tolerance = djstripe_tolerance\n\n djstripe_validation_method = data.get(\"djstripe_validation_method\")\n if djstripe_validation_method:\n self.djstripe_validation_method = djstripe_validation_method",
"nameRange": {
"startLine": 24,
"startColumn": 6,
"endLine": 24,
"endColumn": 21
}
}
},
{
"type": "call",
"ref": "djstripe/views.py:42",
"range": {
"startLine": 42,
"startColumn": 18,
"endLine": 44,
"endColumn": 9
},
"name": "from_request",
"expression": "WebhookEventTrigger.from_request(\n request, webhook_endpoint=webhook_endpoint\n )",
"definition": {
"type": "method",
"filePath": "djstripe/models/webhooks.py",
"name": "from_request",
"ref": "djstripe/models/webhooks.py:194",
"definitionRange": {
"startLine": 194,
"startColumn": 4,
"endLine": 279,
"endColumn": 18
},
"language": "python",
"snippet": "def from_request(cls, request, *, webhook_endpoint: WebhookEndpoint):\n \"\"\"\n Create, validate and process a WebhookEventTrigger given a Django\n request object.\n\n The process is three-fold:\n 1. Create a WebhookEventTrigger object from a Django request.\n 2. Validate the WebhookEventTrigger as a Stripe event using the API.\n 3. If valid, process it into an Event object (and child resource).\n \"\"\"\n\n try:\n body = request.body.decode(request.encoding or \"utf-8\")\n except Exception:\n body = \"(error decoding body)\"\n\n ip = get_remote_ip(request)\n\n try:\n data = json.loads(body)\n except json.JSONDecodeError:\n data = {}\n\n stripe_account = StripeModel._find_owner_account(data=data)\n secret = webhook_endpoint.secret\n\n obj = cls.objects.create(\n headers=dict(request.headers),\n body=body,\n remote_ip=ip,\n stripe_trigger_account=stripe_account,\n webhook_endpoint=webhook_endpoint,\n )\n api_key = (\n stripe_account.default_api_key\n or djstripe_settings.get_default_api_key(obj.livemode)\n )\n\n try:\n # Validate the webhook first\n signals.webhook_pre_validate.send(sender=cls, instance=obj)\n\n # Default to per Webhook Endpoint Tolerance\n obj.valid = obj.validate(\n secret=secret,\n api_key=api_key,\n )\n\n # send post webhook validate signal\n signals.webhook_post_validate.send(\n sender=cls, instance=obj, valid=obj.valid\n )\n\n if obj.valid:\n signals.webhook_pre_process.send(sender=cls, instance=obj)\n\n # todo this should be moved to per webhook endpoint callback\n if djstripe_settings.WEBHOOK_EVENT_CALLBACK:\n # If WEBHOOK_EVENT_CALLBACK, pass it for processing\n djstripe_settings.WEBHOOK_EVENT_CALLBACK(obj, api_key=api_key)\n else:\n # Process the item (do not save it, it'll get saved below)\n obj.process(save=False, api_key=api_key)\n signals.webhook_post_process.send(\n sender=cls, instance=obj, api_key=api_key\n )\n except Exception as e:\n max_length = cls._meta.get_field(\"exception\").max_length\n obj.exception = str(e)[:max_length]\n obj.traceback = format_exc()\n\n # Send the exception as the webhook_processing_error signal\n signals.webhook_processing_error.send(\n sender=cls,\n instance=obj,\n api_key=api_key,\n exception=e,\n data=getattr(e, \"http_body\", \"\"),\n )\n\n # re-raise the exception so Django sees it\n raise e\n finally:\n obj.save()\n\n return obj",
"nameRange": {
"startLine": 194,
"startColumn": 8,
"endLine": 194,
"endColumn": 20
}
}
},
{
"type": "variable",
"ref": "djstripe/views.py:42",
"range": {
"startLine": 42,
"startColumn": 18,
"endLine": 42,
"endColumn": 50
},
"name": "WebhookEventTrigger",
"expression": "WebhookEventTrigger.from_request",
"definition": {
"type": "class",
"filePath": "djstripe/models/webhooks.py",
"name": "WebhookEventTrigger",
"ref": "djstripe/models/webhooks.py:132",
"definitionRange": {
"startLine": 132,
"startColumn": 0,
"endLine": 375,
"endColumn": 25
},
"language": "python",
"snippet": "class WebhookEventTrigger(models.Model):\n \"\"\"\n An instance of a request that reached the server endpoint for Stripe webhooks.\n\n Webhook Events are initially **UNTRUSTED**, as it is possible for any web entity to\n post any data to our webhook url. Data posted may be valid Stripe information,\n garbage, or even malicious.\n The 'valid' flag in this model monitors this.\n \"\"\"\n\n id = models.BigAutoField(primary_key=True)\n remote_ip = models.GenericIPAddressField(\n help_text=\"IP address of the request client.\"\n )\n headers = JSONField()\n body = models.TextField(blank=True)\n valid = models.BooleanField(\n default=False,\n help_text=\"Whether or not the webhook event has passed validation\",\n )\n processed = models.BooleanField(\n default=False,\n help_text=\"Whether or not the webhook event has been successfully processed\",\n )\n exception = models.CharField(max_length=128, blank=True)\n traceback = models.TextField(\n blank=True, help_text=\"Traceback if an exception was thrown during processing\"\n )\n event = StripeForeignKey(\n \"Event\",\n on_delete=models.SET_NULL,\n null=True,\n blank=True,\n help_text=\"Event object contained in the (valid) Webhook\",\n )\n djstripe_version = models.CharField(\n max_length=32,\n default=_get_version, # Needs to be a callable, otherwise it's a db default.\n help_text=\"The version of dj-stripe when the webhook was received\",\n )\n created = models.DateTimeField(auto_now_add=True)\n updated = models.DateTimeField(auto_now=True)\n stripe_trigger_account = StripeForeignKey(\n \"djstripe.Account\",\n on_delete=models.CASCADE,\n to_field=\"id\",\n null=True,\n blank=True,\n help_text=\"The Stripe Account this object belongs to.\",\n )\n webhook_endpoint = StripeForeignKey(\n \"WebhookEndpoint\",\n on_delete=models.SET_NULL,\n null=True,\n blank=True,\n help_text=\"The endpoint this webhook was received on\",\n )\n\n def __str__(self):\n return f\"id={self.id}, valid={self.valid}, processed={self.processed}\"\n\n @classmethod\n def from_request(cls, request, *, webhook_endpoint: WebhookEndpoint):\n \"\"\"\n Create, validate and process a WebhookEventTrigger given a Django\n request object.\n\n The process is three-fold:\n 1. Create a WebhookEventTrigger object from a Django request.\n 2. Validate the WebhookEventTrigger as a Stripe event using the API.\n 3. If valid, process it into an Event object (and child resource).\n \"\"\"\n\n try:\n body = request.body.decode(request.encoding or \"utf-8\")\n except Exception:\n body = \"(error decoding body)\"\n\n ip = get_remote_ip(request)\n\n try:\n data = json.loads(body)\n except json.JSONDecodeError:\n data = {}\n\n stripe_account = StripeModel._find_owner_account(data=data)\n secret = webhook_endpoint.secret\n\n obj = cls.objects.create(\n headers=dict(request.headers),\n body=body,\n remote_ip=ip,\n stripe_trigger_account=stripe_account,\n webhook_endpoint=webhook_endpoint,\n )\n api_key = (\n stripe_account.default_api_key\n or djstripe_settings.get_default_api_key(obj.livemode)\n )\n\n try:\n # Validate the webhook first\n signals.webhook_pre_validate.send(sender=cls, instance=obj)\n\n # Default to per Webhook Endpoint Tolerance\n obj.valid = obj.validate(\n secret=secret,\n api_key=api_key,\n )\n\n # send post webhook validate signal\n signals.webhook_post_validate.send(\n sender=cls, instance=obj, valid=obj.valid\n )\n\n if obj.valid:\n signals.webhook_pre_process.send(sender=cls, instance=obj)\n\n # todo this should be moved to per webhook endpoint callback\n if djstripe_settings.WEBHOOK_EVENT_CALLBACK:\n # If WEBHOOK_EVENT_CALLBACK, pass it for processing\n djstripe_settings.WEBHOOK_EVENT_CALLBACK(obj, api_key=api_key)\n else:\n # Process the item (do not save it, it'll get saved below)\n obj.process(save=False, api_key=api_key)\n signals.webhook_post_process.send(\n sender=cls, instance=obj, api_key=api_key\n )\n except Exception as e:\n max_length = cls._meta.get_field(\"exception\").max_length\n obj.exception = str(e)[:max_length]\n obj.traceback = format_exc()\n\n # Send the exception as the webhook_processing_error signal\n signals.webhook_processing_error.send(\n sender=cls,\n instance=obj,\n api_key=api_key,\n exception=e,\n data=getattr(e, \"http_body\", \"\"),\n )\n\n # re-raise the exception so Django sees it\n raise e\n finally:\n obj.save()\n\n return obj\n\n @cached_property\n def json_body(self):\n try:\n return json.loads(self.body)\n except ValueError:\n return {}\n\n @property\n def is_test_event(self):\n event_id = self.json_body.get(\"id\")\n return event_id and event_id.endswith(\"_00000000000000\")\n\n def verify_signature(self, secret: str, tolerance: int) -> bool:\n if not secret:\n raise ValueError(\"Cannot verify event signature without a secret\")\n\n # HTTP headers are case-insensitive, but we store them as a dict.\n headers = CaseInsensitiveMapping(self.headers)\n signature = headers.get(\"stripe-signature\")\n\n try:\n stripe.WebhookSignature.verify_header(\n self.body, signature, secret, tolerance\n )\n except stripe.error.SignatureVerificationError:\n logger.exception(\"Failed to verify header\")\n return False\n else:\n return True\n\n def validate(\n self,\n api_key: str,\n secret: str,\n ):\n \"\"\"\n The original contents of the Event message must be confirmed by\n refetching it and comparing the fetched data with the original data.\n\n This function makes an API call to Stripe to redownload the Event data\n and returns whether or not it matches the WebhookEventTrigger data.\n \"\"\"\n\n local_data = self.json_body\n if \"id\" not in local_data or \"livemode\" not in local_data:\n logger.error(\n '\"id\" not in json body or \"livemode\" not in json body(%s)', local_data\n )\n return False\n\n if self.is_test_event:\n logger.info(\"Test webhook received and discarded: %s\", local_data)\n return False\n\n validation_method = self.webhook_endpoint.djstripe_validation_method\n\n if validation_method == WebhookEndpointValidation.none:\n # validation disabled\n warnings.warn(\"WEBHOOK VALIDATION is disabled.\")\n return True\n elif validation_method == WebhookEndpointValidation.verify_signature:\n if settings.DEBUG:\n # In debug mode, allow overriding the webhook secret with\n # the x-djstripe-webhook-secret header.\n # (used for stripe cli webhook forwarding)\n headers = CaseInsensitiveMapping(self.headers)\n local_secret = headers.get(\"x-djstripe-webhook-secret\")\n secret = local_secret if local_secret else secret\n return self.verify_signature(\n secret=secret, tolerance=self.webhook_endpoint.djstripe_tolerance\n )\n\n livemode = local_data[\"livemode\"]\n api_key = api_key or djstripe_settings.get_default_api_key(livemode)\n\n # Retrieve the event using the api_version specified in itself\n remote_data = Event.stripe_class.retrieve(\n id=local_data[\"id\"],\n api_key=api_key,\n stripe_version=local_data[\"api_version\"],\n )\n\n return local_data[\"data\"] == remote_data[\"data\"]\n\n def process(self, save=True, api_key: str = None):\n # Reset traceback and exception in case of reprocessing\n self.exception = \"\"\n self.traceback = \"\"\n\n self.event = Event.process(self.json_body, api_key=api_key)\n self.processed = True\n if save:\n self.save()\n\n return self.event",
"nameRange": {
"startLine": 132,
"startColumn": 6,
"endLine": 132,
"endColumn": 25
}
}
},
{
"type": "expression",
"ref": "djstripe/views.py:46",
"range": {
"startLine": 46,
"startColumn": 8,
"endLine": 48,
"endColumn": 84
},
"name": "is_test_event",
"expression": "if trigger.is_test_event:\n # Since we don't do signature verification, we have to skip trigger.valid\n return HttpResponse(\"Test webhook successfully received and discarded!\")",
"definition": {
"type": "method",
"filePath": "djstripe/models/webhooks.py",
"name": "is_test_event",
"ref": "djstripe/models/webhooks.py:289",
"definitionRange": {
"startLine": 289,
"startColumn": 4,
"endLine": 291,
"endColumn": 64
},
"language": "python",
"snippet": "def is_test_event(self):\n event_id = self.json_body.get(\"id\")\n return event_id and event_id.endswith(\"_00000000000000\")",
"nameRange": {
"startLine": 289,
"startColumn": 8,
"endLine": 289,
"endColumn": 21
}
}
},
{
"type": "comment",
"ref": "djstripe/views.py:47",
"range": {
"startLine": 47,
"startColumn": 12,
"endLine": 47,
"endColumn": 85
},
"expression": "# Since we don't do signature verification, we have to skip trigger.valid"
},
{
"type": "call",
"ref": "djstripe/views.py:48",
"range": {
"startLine": 48,
"startColumn": 19,
"endLine": 48,
"endColumn": 84
},
"name": "HttpResponse",
"expression": "HttpResponse(\"Test webhook successfully received and discarded!\")",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "HttpResponse",
"ref": "__base_types__:72",
"definitionRange": {
"startLine": 72,
"startColumn": 0,
"endLine": 99,
"endColumn": 30
},
"language": "python",
"snippet": "class HttpResponse(HttpResponseBase, Iterable[bytes]):\n csrf_cookie_set: bool\n redirect_chain: list[tuple[str, int]]\n sameorigin: bool\n test_server_port: str\n test_was_secure_request: bool\n xframe_options_exempt: bool\n streaming: bool\n def __init__(self, content: Any = ..., *args: Any, **kwargs: Any) -> None: ...\n def serialize(self) -> bytes: ...\n @property\n def content(self) -> bytes: ...\n def __iter__(self) -> Iterator[bytes]: ...\n def write(self, content: str | bytes) -> None: ...\n def tell(self) -> int: ...\n def getvalue(self) -> bytes: ...\n def writable(self) -> bool: ...\n def writelines(self, lines: Iterable[str | bytes]) -> None: ...\n\n # Attributes assigned by monkey-patching in test client ClientHandler.__call__()\n wsgi_request: WSGIRequest\n # Attributes assigned by monkey-patching in test client Client.request()\n client: Client\n request: dict[str, Any]\n templates: list[Template]\n context: Context\n resolver_match: ResolverMatch\n def json(self) -> Any: ...",
"nameRange": {
"startLine": 72,
"startColumn": 6,
"endLine": 72,
"endColumn": 18
}
}
},
{
"type": "comment",
"ref": "djstripe/views.py:51",
"range": {
"startLine": 51,
"startColumn": 12,
"endLine": 51,
"endColumn": 56
},
"expression": "# Webhook Event did not validate, return 400"
},
{
"type": "variable",
"ref": "djstripe/views.py:55",
"range": {
"startLine": 55,
"startColumn": 31,
"endLine": 55,
"endColumn": 43
},
"name": "id",
"expression": "(trigger.id)",
"definition": {
"type": "class_property",
"filePath": "djstripe/models/webhooks.py",
"name": "id",
"ref": "djstripe/models/webhooks.py:142",
"definitionRange": {
"startLine": 142,
"startColumn": 4,
"endLine": 142,
"endColumn": 46
},
"language": "python",
"snippet": "id = models.BigAutoField(primary_key=True)",
"nameRange": {
"startLine": 142,
"startColumn": 4,
"endLine": 142,
"endColumn": 6
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "get_default_account",
"ref": "djstripe/models/account.py:47",
"definitionRange": {
"startLine": 47,
"startColumn": 4,
"endLine": 57,
"endColumn": 86
},
"language": "python",
"snippet": "def get_default_account(cls, api_key=djstripe_settings.STRIPE_SECRET_KEY):\n # As of API version 2020-03-02, there is no permission that can allow\n # restricted keys to call GET /v1/account\n if djstripe_settings.STRIPE_SECRET_KEY.startswith(\"rk_\"):\n return None\n\n account_data = cls.stripe_class.retrieve(\n api_key=api_key, stripe_version=djstripe_settings.STRIPE_API_VERSION\n )\n\n return cls._get_or_create_from_stripe_object(account_data, api_key=api_key)[0]",
"nameRange": {
"startLine": 47,
"startColumn": 8,
"endLine": 47,
"endColumn": 27
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:153",
"targetRef": "djstripe/models/account.py:47",
"sourceSnippetRange": {
"startLine": 153,
"startColumn": 38,
"endLine": 153,
"endColumn": 57
},
"snippet": "get_default_account"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:41",
"targetRef": "djstripe/models/account.py:47",
"sourceSnippetRange": {
"startLine": 41,
"startColumn": 26,
"endLine": 41,
"endColumn": 45
},
"snippet": "get_default_account"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:198",
"targetRef": "djstripe/models/account.py:47",
"sourceSnippetRange": {
"startLine": 198,
"startColumn": 26,
"endLine": 198,
"endColumn": 45
},
"snippet": "get_default_account"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:274",
"targetRef": "djstripe/models/account.py:47",
"sourceSnippetRange": {
"startLine": 274,
"startColumn": 26,
"endLine": 274,
"endColumn": 45
},
"snippet": "get_default_account"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:406",
"targetRef": "djstripe/models/account.py:47",
"sourceSnippetRange": {
"startLine": 406,
"startColumn": 26,
"endLine": 406,
"endColumn": 45
},
"snippet": "get_default_account"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:843",
"targetRef": "djstripe/models/account.py:47",
"sourceSnippetRange": {
"startLine": 843,
"startColumn": 26,
"endLine": 843,
"endColumn": 45
},
"snippet": "get_default_account"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:907",
"targetRef": "djstripe/models/account.py:47",
"sourceSnippetRange": {
"startLine": 907,
"startColumn": 26,
"endLine": 907,
"endColumn": 45
},
"snippet": "get_default_account"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/models/account.py:47",
"range": {
"startLine": 47,
"startColumn": 41,
"endLine": 47,
"endColumn": 76
},
"name": "djstripe_settings",
"expression": "djstripe_settings.STRIPE_SECRET_KEY",
"definition": {
"type": "expression",
"filePath": "djstripe/settings.py",
"name": "djstripe_settings",
"ref": "djstripe/settings.py:236",
"definitionRange": {
"startLine": 236,
"startColumn": 0,
"endLine": 236,
"endColumn": 38
},
"language": "python",
"snippet": "djstripe_settings = DjstripeSettings()",
"nameRange": {
"startLine": 236,
"startColumn": 0,
"endLine": 236,
"endColumn": 17
}
}
},
{
"type": "comment",
"ref": "djstripe/models/account.py:48",
"range": {
"startLine": 48,
"startColumn": 8,
"endLine": 48,
"endColumn": 77
},
"expression": "# As of API version 2020-03-02, there is no permission that can allow"
},
{
"type": "comment",
"ref": "djstripe/models/account.py:49",
"range": {
"startLine": 49,
"startColumn": 8,
"endLine": 49,
"endColumn": 49
},
"expression": "# restricted keys to call GET /v1/account"
},
{
"type": "call",
"ref": "djstripe/models/account.py:50",
"range": {
"startLine": 50,
"startColumn": 11,
"endLine": 50,
"endColumn": 64
},
"name": "startswith",
"expression": "djstripe_settings.STRIPE_SECRET_KEY.startswith(\"rk_\")",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "startswith",
"ref": "__base_types__:536",
"definitionRange": {
"startLine": 536,
"startColumn": 4,
"endLine": 538,
"endColumn": 18
},
"language": "python",
"snippet": "def startswith(\n self, prefix: str | tuple[str, ...], start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /\n ) -> bool: ...",
"nameRange": {
"startLine": 536,
"startColumn": 8,
"endLine": 536,
"endColumn": 18
}
}
},
{
"type": "variable",
"ref": "djstripe/models/account.py:54",
"range": {
"startLine": 54,
"startColumn": 29,
"endLine": 54,
"endColumn": 80
},
"name": "STRIPE_API_VERSION",
"expression": "stripe_version=djstripe_settings.STRIPE_API_VERSION",
"definition": {
"type": "method",
"filePath": "djstripe/settings.py",
"name": "STRIPE_API_VERSION",
"ref": "djstripe/settings.py:122",
"definitionRange": {
"startLine": 122,
"startColumn": 4,
"endLine": 127,
"endColumn": 57
},
"language": "python",
"snippet": "def STRIPE_API_VERSION(self) -> str:\n \"\"\"\n Get the desired API version to use for Stripe requests.\n \"\"\"\n version = getattr(settings, \"STRIPE_API_VERSION\", stripe.api_version)\n return version or self.DEFAULT_STRIPE_API_VERSION",
"nameRange": {
"startLine": 122,
"startColumn": 8,
"endLine": 122,
"endColumn": 26
}
}
},
{
"type": "call",
"ref": "djstripe/models/account.py:57",
"range": {
"startLine": 57,
"startColumn": 15,
"endLine": 57,
"endColumn": 83
},
"name": "_get_or_create_from_stripe_object",
"expression": "cls._get_or_create_from_stripe_object(account_data, api_key=api_key)",
"definition": {
"type": "method",
"filePath": "djstripe/models/base.py",
"name": "_get_or_create_from_stripe_object",
"ref": "djstripe/models/base.py:702",
"definitionRange": {
"startLine": 702,
"startColumn": 4,
"endLine": 821,
"endColumn": 56
},
"language": "python",
"snippet": "def _get_or_create_from_stripe_object(\n cls,\n data,\n field_name=\"id\",\n refetch=True,\n current_ids=None,\n pending_relations=None,\n save=True,\n stripe_account=None,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n ):\n \"\"\"\n\n :param data:\n :param field_name:\n :param refetch:\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n :param pending_relations: list of tuples of relations to be attached post-save\n :type pending_relations: list\n :param save:\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n :return:\n :rtype: cls, bool\n \"\"\"\n field = data.get(field_name)\n is_nested_data = field_name != \"id\"\n should_expand = False\n if not stripe_account and isinstance(data, StripeObject):\n stripe_account = data.stripe_account\n if pending_relations is None:\n pending_relations = []\n\n id_ = get_id_from_stripe_data(field)\n\n if not field:\n # An empty field - We need to return nothing here because there is\n # no way of knowing what needs to be fetched!\n raise RuntimeError(\n f\"dj-stripe encountered an empty field {cls.__name__}.{field_name} =\"\n f\" {field}\"\n )\n elif id_ == field:\n # A field like {\"subscription\": \"sub_6lsC8pt7IcFpjA\", ...}\n # We'll have to expand if the field is not \"id\" (= is nested)\n should_expand = is_nested_data\n else:\n # A field like {\"subscription\": {\"id\": sub_6lsC8pt7IcFpjA\", ...}}\n data = field\n\n try:\n return cls.stripe_objects.get(id=id_), False\n except cls.DoesNotExist:\n if is_nested_data and refetch:\n # This is what `data` usually looks like:\n # {\"id\": \"cus_XXXX\", \"default_source\": \"card_XXXX\"}\n # Leaving the default field_name (\"id\") will get_or_create the customer.\n # If field_name=\"default_source\", we get_or_create the card instead.\n cls_instance = cls(id=id_)\n try:\n data = cls_instance.api_retrieve(\n stripe_account=stripe_account, api_key=api_key\n )\n except InvalidRequestError as e:\n if \"a similar object exists in\" in str(e):\n # HACK around a Stripe bug.\n # When a File is retrieved from the Account object,\n # a mismatch between live and test mode is possible depending\n # on whether the file (usually the logo) was uploaded in live\n # or test. Reported to Stripe in August 2020.\n # Context: https://github.com/dj-stripe/dj-stripe/issues/830\n pass\n elif \"No such PaymentMethod:\" in str(e):\n # payment methods (card_… etc) can be irretrievably deleted,\n # but still present during sync. For example, if a refund is\n # issued on a charge whose payment method has been deleted.\n return None, False\n elif \"Invalid subscription_item id\" in str(e):\n # subscription items can be irretrievably deleted but still\n # be present during sync. For example, if a line item of type subscription is\n # removed from the subscription, the invoice generated for that billing period\n # will still contain the deleted subscription_item.\n return None, False\n else:\n raise\n should_expand = False\n\n # The next thing to happen will be the \"create from stripe object\" call.\n # At this point, if we don't have data to start with (field is a str),\n # *and* we didn't refetch by id, then `should_expand` is True and we\n # don't have the data to actually create the object.\n # If this happens when syncing Stripe data, it's a djstripe bug. Report it!\n if should_expand:\n raise ValueError(f\"No data to create {cls.__name__} from {field_name}\")\n\n try:\n # We wrap the `_create_from_stripe_object` in a transaction to\n # avoid TransactionManagementError on subsequent queries in case\n # of the IntegrityError catch below. See PR #903\n with transaction.atomic():\n return (\n cls._create_from_stripe_object(\n data,\n current_ids=current_ids,\n pending_relations=pending_relations,\n save=save,\n stripe_account=stripe_account,\n api_key=api_key,\n ),\n True,\n )\n except IntegrityError:\n # Handle the race condition that something else created the object\n # after the `get` and before `_create_from_stripe_object`.\n # This is common during webhook handling, since Stripe sends\n # multiple webhook events simultaneously,\n # each of which will cause recursive syncs. See issue #429\n return cls.stripe_objects.get(id=id_), False",
"nameRange": {
"startLine": 702,
"startColumn": 8,
"endLine": 702,
"endColumn": 41
}
}
}
]
},
{
"type": "class",
"filePath": "djstripe/models/base.py",
"name": "Meta",
"ref": "djstripe/models/base.py:36",
"definitionRange": {
"startLine": 36,
"startColumn": 4,
"endLine": 37,
"endColumn": 23
},
"language": "python",
"snippet": "class Meta:\n abstract = True",
"nameRange": {
"startLine": 36,
"startColumn": 10,
"endLine": 36,
"endColumn": 14
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:139",
"targetRef": "djstripe/models/base.py:36",
"sourceSnippetRange": {
"startLine": 139,
"startColumn": 31,
"endLine": 139,
"endColumn": 35
},
"snippet": "Meta"
}
],
"expressions": []
},
{
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "country",
"ref": "djstripe/models/account.py:92",
"definitionRange": {
"startLine": 92,
"startColumn": 4,
"endLine": 93,
"endColumn": 50
},
"language": "python",
"snippet": "def country(self) -> str:\n return self.stripe_data.get(\"country\", \"\")",
"nameRange": {
"startLine": 92,
"startColumn": 8,
"endLine": 92,
"endColumn": 15
},
"references": [
{
"targetRef": "djstripe/models/account.py:92",
"sourceSnippetRange": {
"startLine": 92,
"startColumn": 0,
"endLine": 92,
"endColumn": 30
},
"sourceRef": "djstripe/models/account.py:92",
"type": "from-search",
"snippet": " def country(self) -> str:\n"
},
{
"targetRef": "djstripe/models/account.py:92",
"sourceSnippetRange": {
"startLine": 93,
"startColumn": 0,
"endLine": 93,
"endColumn": 51
},
"sourceRef": "djstripe/models/account.py:93",
"type": "from-search",
"snippet": " return self.stripe_data.get(\"country\", \"\")\n"
}
],
"expressions": []
},
{
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "djstripe_created",
"ref": "djstripe/models/base.py:32",
"definitionRange": {
"startLine": 32,
"startColumn": 4,
"endLine": 32,
"endColumn": 78
},
"language": "python",
"snippet": "djstripe_created = models.DateTimeField(auto_now_add=True, editable=False)",
"nameRange": {
"startLine": 32,
"startColumn": 4,
"endLine": 32,
"endColumn": 20
},
"references": [
{
"targetRef": "djstripe/models/base.py:32",
"sourceSnippetRange": {
"startLine": 32,
"startColumn": 0,
"endLine": 32,
"endColumn": 79
},
"sourceRef": "djstripe/models/base.py:32",
"type": "from-search",
"snippet": " djstripe_created = models.DateTimeField(auto_now_add=True, editable=False)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/base.py:32",
"range": {
"startLine": 32,
"startColumn": 23,
"endLine": 32,
"endColumn": 78
},
"name": "DateTimeField",
"expression": "models.DateTimeField(auto_now_add=True, editable=False)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "DateTimeField",
"ref": "__base_types__:1215",
"definitionRange": {
"startLine": 1215,
"startColumn": 0,
"endLine": 1276,
"endColumn": 44
},
"language": "python",
"snippet": "class DateTimeField(DateField[_DT]):\n # attributes\n auto_now: bool = ...\n auto_now_add: bool = ...\n @overload\n def __new__( # type: ignore [misc]\n cls,\n verbose_name: str | None = ...,\n name: str | None = ...,\n auto_now: bool = ...,\n auto_now_add: bool = ...,\n primary_key: bool = ...,\n max_length: int | None = ...,\n unique: bool = ...,\n blank: bool = ...,\n null: Literal[False] = ...,\n db_index: bool = ...,\n default: _DT | Callable[[], _DT] | None = ...,\n editable: bool = ...,\n auto_created: bool = ...,\n serialize: bool = ...,\n unique_for_date: str | None = ...,\n unique_for_month: str | None = ...,\n unique_for_year: str | None = ...,\n choices: Iterable[\n tuple[_DT, str] | tuple[str, Iterable[tuple[_DT, str]]]\n ] = ...,\n help_text: str = ...,\n db_column: str | None = ...,\n db_tablespace: str | None = ...,\n validators: Iterable[_ValidatorCallable] = ...,\n error_messages: _ErrorMessagesToOverride | None = ...,\n ) -> DateTimeField[datetime]: ...\n @overload\n def __new__(\n cls,\n verbose_name: str | None = ...,\n name: str | None = ...,\n auto_now: bool = ...,\n auto_now_add: bool = ...,\n primary_key: bool = ...,\n max_length: int | None = ...,\n unique: bool = ...,\n blank: bool = ...,\n null: Literal[True] = ...,\n db_index: bool = ...,\n default: _DT | Callable[[], _DT] = ...,\n editable: bool = ...,\n auto_created: bool = ...,\n serialize: bool = ...,\n unique_for_date: str | None = ...,\n unique_for_month: str | None = ...,\n unique_for_year: str | None = ...,\n choices: Iterable[\n tuple[_DT, str] | tuple[str, Iterable[tuple[_DT, str]]]\n ] = ...,\n help_text: str = ...,\n db_column: str | None = ...,\n db_tablespace: str | None = ...,\n validators: Iterable[_ValidatorCallable] = ...,\n error_messages: _ErrorMessagesToOverride | None = ...,\n ) -> DateTimeField[datetime | None]: ...",
"nameRange": {
"startLine": 1215,
"startColumn": 6,
"endLine": 1215,
"endColumn": 19
}
}
},
{
"type": "variable",
"ref": "djstripe/models/base.py:32",
"range": {
"startLine": 32,
"startColumn": 23,
"endLine": 32,
"endColumn": 43
},
"name": "models",
"expression": "models.DateTimeField",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "stripe_data",
"ref": "djstripe/models/base.py:34",
"definitionRange": {
"startLine": 34,
"startColumn": 4,
"endLine": 34,
"endColumn": 41
},
"language": "python",
"snippet": "stripe_data = JSONField(default=dict)",
"nameRange": {
"startLine": 34,
"startColumn": 4,
"endLine": 34,
"endColumn": 15
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:69",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 69,
"startColumn": 24,
"endLine": 69,
"endColumn": 35
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:70",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 70,
"startColumn": 32,
"endLine": 70,
"endColumn": 43
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:86",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 86,
"startColumn": 32,
"endLine": 86,
"endColumn": 43
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:93",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 93,
"startColumn": 20,
"endLine": 93,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:97",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 97,
"startColumn": 20,
"endLine": 97,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:101",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 101,
"startColumn": 20,
"endLine": 101,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:105",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 105,
"startColumn": 20,
"endLine": 105,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:221",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 221,
"startColumn": 20,
"endLine": 221,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:226",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 226,
"startColumn": 20,
"endLine": 226,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:231",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 231,
"startColumn": 20,
"endLine": 231,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:236",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 236,
"startColumn": 20,
"endLine": 236,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:241",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 241,
"startColumn": 20,
"endLine": 241,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/checkout.py:97",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 97,
"startColumn": 20,
"endLine": 97,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/checkout.py:101",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 101,
"startColumn": 28,
"endLine": 101,
"endColumn": 39
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:382",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 382,
"startColumn": 42,
"endLine": 382,
"endColumn": 53
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:387",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 387,
"startColumn": 20,
"endLine": 387,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:391",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 391,
"startColumn": 20,
"endLine": 391,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:396",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 396,
"startColumn": 20,
"endLine": 396,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:400",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 400,
"startColumn": 20,
"endLine": 400,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:404",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 404,
"startColumn": 20,
"endLine": 404,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:408",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 408,
"startColumn": 51,
"endLine": 408,
"endColumn": 62
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:414",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 414,
"startColumn": 20,
"endLine": 414,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:418",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 418,
"startColumn": 20,
"endLine": 418,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:422",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 422,
"startColumn": 20,
"endLine": 422,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:426",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 426,
"startColumn": 22,
"endLine": 426,
"endColumn": 33
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:467",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 467,
"startColumn": 42,
"endLine": 467,
"endColumn": 53
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:472",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 472,
"startColumn": 20,
"endLine": 472,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:477",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 477,
"startColumn": 20,
"endLine": 477,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:481",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 481,
"startColumn": 51,
"endLine": 481,
"endColumn": 62
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:487",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 487,
"startColumn": 20,
"endLine": 487,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:491",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 491,
"startColumn": 20,
"endLine": 491,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:495",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 495,
"startColumn": 20,
"endLine": 495,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:499",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 499,
"startColumn": 20,
"endLine": 499,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:504",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 504,
"startColumn": 20,
"endLine": 504,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:508",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 508,
"startColumn": 20,
"endLine": 508,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:584",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 584,
"startColumn": 20,
"endLine": 584,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:588",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 588,
"startColumn": 20,
"endLine": 588,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:592",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 592,
"startColumn": 20,
"endLine": 592,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:596",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 596,
"startColumn": 25,
"endLine": 596,
"endColumn": 36
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:776",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 776,
"startColumn": 20,
"endLine": 776,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:780",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 780,
"startColumn": 20,
"endLine": 780,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:784",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 784,
"startColumn": 49,
"endLine": 784,
"endColumn": 60
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:789",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 789,
"startColumn": 20,
"endLine": 789,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:838",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 838,
"startColumn": 51,
"endLine": 838,
"endColumn": 62
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:844",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 844,
"startColumn": 20,
"endLine": 844,
"endColumn": 31
},
"snippet": "stripe_data"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:849",
"targetRef": "djstripe/models/base.py:34",
"sourceSnippetRange": {
"startLine": 849,
"startColumn": 35,
"endLine": 849,
"endColumn": 46
},
"snippet": "stripe_data"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/base.py:34",
"range": {
"startLine": 34,
"startColumn": 18,
"endLine": 34,
"endColumn": 41
},
"name": "JSONField",
"expression": "JSONField(default=dict)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "JSONField",
"ref": "djstripe/fields.py:149",
"definitionRange": {
"startLine": 149,
"startColumn": 0,
"endLine": 152,
"endColumn": 8
},
"language": "python",
"snippet": "class JSONField(FieldDeconstructMixin, BaseJSONField):\n \"\"\"A field used to define a JSONField value according to djstripe logic.\"\"\"\n\n pass",
"nameRange": {
"startLine": 149,
"startColumn": 6,
"endLine": 149,
"endColumn": 15
}
}
},
{
"type": "variable",
"ref": "djstripe/models/base.py:34",
"range": {
"startLine": 34,
"startColumn": 28,
"endLine": 34,
"endColumn": 40
},
"name": "dict",
"expression": "default=dict",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "dict",
"ref": "__base_types__:1027",
"definitionRange": {
"startLine": 1027,
"startColumn": 0,
"endLine": 1097,
"endColumn": 75
},
"language": "python",
"snippet": "class dict(MutableMapping[_KT, _VT]):\n # __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics\n # Also multiprocessing.managers.SyncManager.dict()\n @overload\n def __init__(self) -> None: ...\n @overload\n def __init__(self: dict[str, _VT], **kwargs: _VT) -> None: ...\n @overload\n def __init__(self, map: SupportsKeysAndGetItem[_KT, _VT], /) -> None: ...\n @overload\n def __init__(self: dict[str, _VT], map: SupportsKeysAndGetItem[str, _VT], /, **kwargs: _VT) -> None: ...\n @overload\n def __init__(self, iterable: Iterable[tuple[_KT, _VT]], /) -> None: ...\n @overload\n def __init__(self: dict[str, _VT], iterable: Iterable[tuple[str, _VT]], /, **kwargs: _VT) -> None: ...\n # Next two overloads are for dict(string.split(sep) for string in iterable)\n # Cannot be Iterable[Sequence[_T]] or otherwise dict([\"foo\", \"bar\", \"baz\"]) is not an error\n @overload\n def __init__(self: dict[str, str], iterable: Iterable[list[str]], /) -> None: ...\n @overload\n def __init__(self: dict[bytes, bytes], iterable: Iterable[list[bytes]], /) -> None: ...\n def __new__(cls, *args: Any, **kwargs: Any) -> Self: ...\n def copy(self) -> dict[_KT, _VT]: ...\n def keys(self) -> dict_keys[_KT, _VT]: ...\n def values(self) -> dict_values[_KT, _VT]: ...\n def items(self) -> dict_items[_KT, _VT]: ...\n # Signature of `dict.fromkeys` should be kept identical to `fromkeys` methods of `OrderedDict`/`ChainMap`/`UserDict` in `collections`\n # TODO: the true signature of `dict.fromkeys` is not expressible in the current type system.\n # See #3800 & https://github.com/python/typing/issues/548#issuecomment-683336963.\n @classmethod\n @overload\n def fromkeys(cls, iterable: Iterable[_T], value: None = None, /) -> dict[_T, Any | None]: ...\n @classmethod\n @overload\n def fromkeys(cls, iterable: Iterable[_T], value: _S, /) -> dict[_T, _S]: ...\n # Positional-only in dict, but not in MutableMapping\n @overload # type: ignore[override]\n def get(self, key: _KT, /) -> _VT | None: ...\n @overload\n def get(self, key: _KT, default: _VT, /) -> _VT: ...\n @overload\n def get(self, key: _KT, default: _T, /) -> _VT | _T: ...\n @overload\n def pop(self, key: _KT, /) -> _VT: ...\n @overload\n def pop(self, key: _KT, default: _VT, /) -> _VT: ...\n @overload\n def pop(self, key: _KT, default: _T, /) -> _VT | _T: ...\n def __len__(self) -> int: ...\n def __getitem__(self, key: _KT, /) -> _VT: ...\n def __setitem__(self, key: _KT, value: _VT, /) -> None: ...\n def __delitem__(self, key: _KT, /) -> None: ...\n def __iter__(self) -> Iterator[_KT]: ...\n def __eq__(self, value: object, /) -> bool: ...\n def __reversed__(self) -> Iterator[_KT]: ...\n __hash__: ClassVar[None] # type: ignore[assignment]\n if sys.version_info >= (3, 9):\n def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...\n @overload\n def __or__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...\n @overload\n def __or__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...\n @overload\n def __ror__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...\n @overload\n def __ror__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...\n # dict.__ior__ should be kept roughly in line with MutableMapping.update()\n @overload # type: ignore[misc]\n def __ior__(self, value: SupportsKeysAndGetItem[_KT, _VT], /) -> Self: ...\n @overload\n def __ior__(self, value: Iterable[tuple[_KT, _VT]], /) -> Self: ...",
"nameRange": {
"startLine": 1027,
"startColumn": 6,
"endLine": 1027,
"endColumn": 10
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "djstripe_updated",
"ref": "djstripe/models/base.py:33",
"definitionRange": {
"startLine": 33,
"startColumn": 4,
"endLine": 33,
"endColumn": 74
},
"language": "python",
"snippet": "djstripe_updated = models.DateTimeField(auto_now=True, editable=False)",
"nameRange": {
"startLine": 33,
"startColumn": 4,
"endLine": 33,
"endColumn": 20
},
"references": [
{
"targetRef": "djstripe/models/base.py:33",
"sourceSnippetRange": {
"startLine": 33,
"startColumn": 0,
"endLine": 33,
"endColumn": 75
},
"sourceRef": "djstripe/models/base.py:33",
"type": "from-search",
"snippet": " djstripe_updated = models.DateTimeField(auto_now=True, editable=False)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/base.py:33",
"range": {
"startLine": 33,
"startColumn": 23,
"endLine": 33,
"endColumn": 74
},
"name": "DateTimeField",
"expression": "models.DateTimeField(auto_now=True, editable=False)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "DateTimeField",
"ref": "__base_types__:1215",
"definitionRange": {
"startLine": 1215,
"startColumn": 0,
"endLine": 1276,
"endColumn": 44
},
"language": "python",
"snippet": "class DateTimeField(DateField[_DT]):\n # attributes\n auto_now: bool = ...\n auto_now_add: bool = ...\n @overload\n def __new__( # type: ignore [misc]\n cls,\n verbose_name: str | None = ...,\n name: str | None = ...,\n auto_now: bool = ...,\n auto_now_add: bool = ...,\n primary_key: bool = ...,\n max_length: int | None = ...,\n unique: bool = ...,\n blank: bool = ...,\n null: Literal[False] = ...,\n db_index: bool = ...,\n default: _DT | Callable[[], _DT] | None = ...,\n editable: bool = ...,\n auto_created: bool = ...,\n serialize: bool = ...,\n unique_for_date: str | None = ...,\n unique_for_month: str | None = ...,\n unique_for_year: str | None = ...,\n choices: Iterable[\n tuple[_DT, str] | tuple[str, Iterable[tuple[_DT, str]]]\n ] = ...,\n help_text: str = ...,\n db_column: str | None = ...,\n db_tablespace: str | None = ...,\n validators: Iterable[_ValidatorCallable] = ...,\n error_messages: _ErrorMessagesToOverride | None = ...,\n ) -> DateTimeField[datetime]: ...\n @overload\n def __new__(\n cls,\n verbose_name: str | None = ...,\n name: str | None = ...,\n auto_now: bool = ...,\n auto_now_add: bool = ...,\n primary_key: bool = ...,\n max_length: int | None = ...,\n unique: bool = ...,\n blank: bool = ...,\n null: Literal[True] = ...,\n db_index: bool = ...,\n default: _DT | Callable[[], _DT] = ...,\n editable: bool = ...,\n auto_created: bool = ...,\n serialize: bool = ...,\n unique_for_date: str | None = ...,\n unique_for_month: str | None = ...,\n unique_for_year: str | None = ...,\n choices: Iterable[\n tuple[_DT, str] | tuple[str, Iterable[tuple[_DT, str]]]\n ] = ...,\n help_text: str = ...,\n db_column: str | None = ...,\n db_tablespace: str | None = ...,\n validators: Iterable[_ValidatorCallable] = ...,\n error_messages: _ErrorMessagesToOverride | None = ...,\n ) -> DateTimeField[datetime | None]: ...",
"nameRange": {
"startLine": 1215,
"startColumn": 6,
"endLine": 1215,
"endColumn": 19
}
}
},
{
"type": "variable",
"ref": "djstripe/models/base.py:33",
"range": {
"startLine": 33,
"startColumn": 23,
"endLine": 33,
"endColumn": 43
},
"name": "models",
"expression": "models.DateTimeField",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "default_currency",
"ref": "djstripe/models/account.py:96",
"definitionRange": {
"startLine": 96,
"startColumn": 4,
"endLine": 97,
"endColumn": 59
},
"language": "python",
"snippet": "def default_currency(self) -> str:\n return self.stripe_data.get(\"default_currency\", \"\")",
"nameRange": {
"startLine": 96,
"startColumn": 8,
"endLine": 96,
"endColumn": 24
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:532",
"targetRef": "djstripe/models/account.py:96",
"sourceSnippetRange": {
"startLine": 532,
"startColumn": 86,
"endLine": 532,
"endColumn": 102
},
"snippet": "default_currency"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:62",
"targetRef": "djstripe/models/account.py:96",
"sourceSnippetRange": {
"startLine": 62,
"startColumn": 81,
"endLine": 62,
"endColumn": 97
},
"snippet": "default_currency"
}
],
"expressions": []
},
{
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "abstract",
"ref": "djstripe/models/base.py:37",
"definitionRange": {
"startLine": 37,
"startColumn": 8,
"endLine": 37,
"endColumn": 23
},
"language": "python",
"snippet": "abstract = True",
"nameRange": {
"startLine": 37,
"startColumn": 8,
"endLine": 37,
"endColumn": 16
},
"references": [
{
"targetRef": "djstripe/models/base.py:37",
"sourceSnippetRange": {
"startLine": 37,
"startColumn": 0,
"endLine": 37,
"endColumn": 24
},
"sourceRef": "djstripe/models/base.py:37",
"type": "from-search",
"snippet": " abstract = True\n"
},
{
"targetRef": "djstripe/models/base.py:37",
"sourceSnippetRange": {
"startLine": 140,
"startColumn": 0,
"endLine": 140,
"endColumn": 24
},
"sourceRef": "djstripe/models/base.py:140",
"type": "from-search",
"snippet": " abstract = True\n"
},
{
"targetRef": "djstripe/models/base.py:37",
"sourceSnippetRange": {
"startLine": 163,
"startColumn": 0,
"endLine": 163,
"endColumn": 76
},
"sourceRef": "djstripe/models/base.py:163",
"type": "from-search",
"snippet": " # If the class is abstract (StripeModel), fall back to default key.\n"
},
{
"targetRef": "djstripe/models/base.py:37",
"sourceSnippetRange": {
"startLine": 164,
"startColumn": 0,
"endLine": 164,
"endColumn": 36
},
"sourceRef": "djstripe/models/base.py:164",
"type": "from-search",
"snippet": " if not self._meta.abstract:\n"
}
],
"expressions": []
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "stripe_class",
"ref": "djstripe/models/identity.py:13",
"definitionRange": {
"startLine": 13,
"startColumn": 4,
"endLine": 13,
"endColumn": 54
},
"language": "python",
"snippet": "stripe_class = stripe.identity.VerificationSession",
"nameRange": {
"startLine": 13,
"startColumn": 4,
"endLine": 13,
"endColumn": 16
},
"references": [
{
"targetRef": "djstripe/models/identity.py:13",
"sourceSnippetRange": {
"startLine": 13,
"startColumn": 0,
"endLine": 13,
"endColumn": 55
},
"sourceRef": "djstripe/models/identity.py:13",
"type": "from-search",
"snippet": " stripe_class = stripe.identity.VerificationSession\n"
},
{
"targetRef": "djstripe/models/identity.py:13",
"sourceSnippetRange": {
"startLine": 34,
"startColumn": 0,
"endLine": 34,
"endColumn": 54
},
"sourceRef": "djstripe/models/identity.py:34",
"type": "from-search",
"snippet": " stripe_class = stripe.identity.VerificationReport\n"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/models/identity.py:13",
"range": {
"startLine": 13,
"startColumn": 19,
"endLine": 13,
"endColumn": 34
},
"name": "stripe",
"expression": "stripe.identity",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "Incomplete",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 32
},
"language": "python",
"snippet": "from _typeshed import Incomplete",
"nameRange": {
"startLine": 0,
"startColumn": 22,
"endLine": 0,
"endColumn": 32
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "last_error",
"ref": "djstripe/models/identity.py:15",
"definitionRange": {
"startLine": 15,
"startColumn": 4,
"endLine": 15,
"endColumn": 49
},
"language": "python",
"snippet": "last_error = JSONField(null=True, blank=True)",
"nameRange": {
"startLine": 15,
"startColumn": 4,
"endLine": 15,
"endColumn": 14
},
"references": [
{
"targetRef": "djstripe/models/identity.py:15",
"sourceSnippetRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 15,
"endColumn": 50
},
"sourceRef": "djstripe/models/identity.py:15",
"type": "from-search",
"snippet": " last_error = JSONField(null=True, blank=True)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/identity.py:15",
"range": {
"startLine": 15,
"startColumn": 17,
"endLine": 15,
"endColumn": 49
},
"name": "JSONField",
"expression": "JSONField(null=True, blank=True)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "JSONField",
"ref": "djstripe/fields.py:149",
"definitionRange": {
"startLine": 149,
"startColumn": 0,
"endLine": 152,
"endColumn": 8
},
"language": "python",
"snippet": "class JSONField(FieldDeconstructMixin, BaseJSONField):\n \"\"\"A field used to define a JSONField value according to djstripe logic.\"\"\"\n\n pass",
"nameRange": {
"startLine": 149,
"startColumn": 6,
"endLine": 149,
"endColumn": 15
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "email",
"ref": "djstripe/models/account.py:100",
"definitionRange": {
"startLine": 100,
"startColumn": 4,
"endLine": 101,
"endColumn": 48
},
"language": "python",
"snippet": "def email(self) -> str:\n return self.stripe_data.get(\"email\", \"\")",
"nameRange": {
"startLine": 100,
"startColumn": 8,
"endLine": 100,
"endColumn": 13
},
"references": [
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:536",
"targetRef": "djstripe/models/account.py:100",
"sourceSnippetRange": {
"startLine": 536,
"startColumn": 36,
"endLine": 536,
"endColumn": 41
},
"snippet": "email"
}
],
"expressions": []
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "redaction",
"ref": "djstripe/models/identity.py:19",
"definitionRange": {
"startLine": 19,
"startColumn": 4,
"endLine": 19,
"endColumn": 48
},
"language": "python",
"snippet": "redaction = JSONField(null=True, blank=True)",
"nameRange": {
"startLine": 19,
"startColumn": 4,
"endLine": 19,
"endColumn": 13
},
"references": [
{
"targetRef": "djstripe/models/identity.py:19",
"sourceSnippetRange": {
"startLine": 19,
"startColumn": 0,
"endLine": 19,
"endColumn": 49
},
"sourceRef": "djstripe/models/identity.py:19",
"type": "from-search",
"snippet": " redaction = JSONField(null=True, blank=True)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/identity.py:19",
"range": {
"startLine": 19,
"startColumn": 16,
"endLine": 19,
"endColumn": 48
},
"name": "JSONField",
"expression": "JSONField(null=True, blank=True)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "JSONField",
"ref": "djstripe/fields.py:149",
"definitionRange": {
"startLine": 149,
"startColumn": 0,
"endLine": 152,
"endColumn": 8
},
"language": "python",
"snippet": "class JSONField(FieldDeconstructMixin, BaseJSONField):\n \"\"\"A field used to define a JSONField value according to djstripe logic.\"\"\"\n\n pass",
"nameRange": {
"startLine": 149,
"startColumn": 6,
"endLine": 149,
"endColumn": 15
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "type",
"ref": "djstripe/models/account.py:104",
"definitionRange": {
"startLine": 104,
"startColumn": 4,
"endLine": 105,
"endColumn": 47
},
"language": "python",
"snippet": "def type(self) -> str:\n return self.stripe_data.get(\"type\", \"\")",
"nameRange": {
"startLine": 104,
"startColumn": 8,
"endLine": 104,
"endColumn": 12
},
"references": [
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:535",
"targetRef": "djstripe/models/account.py:104",
"sourceSnippetRange": {
"startLine": 535,
"startColumn": 36,
"endLine": 535,
"endColumn": 40
},
"snippet": "type"
}
],
"expressions": []
},
{
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "business_url",
"ref": "djstripe/models/account.py:82",
"definitionRange": {
"startLine": 82,
"startColumn": 4,
"endLine": 89,
"endColumn": 17
},
"language": "python",
"snippet": "def business_url(self) -> str:\n \"\"\"\n The business's publicly available website.\n \"\"\"\n business_profile = self.stripe_data.get(\"business_profile\")\n if business_profile:\n return business_profile.get(\"url\", \"\")\n return \"\"",
"nameRange": {
"startLine": 82,
"startColumn": 8,
"endLine": 82,
"endColumn": 20
},
"references": [
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:61",
"targetRef": "djstripe/models/account.py:82",
"sourceSnippetRange": {
"startLine": 61,
"startColumn": 33,
"endLine": 61,
"endColumn": 45
},
"snippet": "business_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:63",
"targetRef": "djstripe/models/account.py:82",
"sourceSnippetRange": {
"startLine": 63,
"startColumn": 33,
"endLine": 63,
"endColumn": 45
},
"snippet": "business_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:94",
"targetRef": "djstripe/models/account.py:82",
"sourceSnippetRange": {
"startLine": 94,
"startColumn": 33,
"endLine": 94,
"endColumn": 45
},
"snippet": "business_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:124",
"targetRef": "djstripe/models/account.py:82",
"sourceSnippetRange": {
"startLine": 124,
"startColumn": 74,
"endLine": 124,
"endColumn": 86
},
"snippet": "business_url"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/models/account.py:83",
"range": {
"startLine": 83,
"startColumn": 8,
"endLine": 85,
"endColumn": 11
},
"expression": "\"\"\"\n The business's publicly available website.\n \"\"\""
}
]
},
{
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "get_stripe_dashboard_url",
"ref": "djstripe/models/account.py:107",
"definitionRange": {
"startLine": 107,
"startColumn": 4,
"endLine": 112,
"endColumn": 9
},
"language": "python",
"snippet": "def get_stripe_dashboard_url(self) -> str:\n \"\"\"Get the stripe dashboard url for this object.\"\"\"\n return (\n f\"https://dashboard.stripe.com/{self.id}/\"\n f\"{'test/' if not self.livemode else ''}dashboard\"\n )",
"nameRange": {
"startLine": 107,
"startColumn": 8,
"endLine": 107,
"endColumn": 32
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/checks.py:163",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 163,
"startColumn": 30,
"endLine": 163,
"endColumn": 54
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/api.py:72",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 72,
"startColumn": 8,
"endLine": 72,
"endColumn": 32
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:152",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 152,
"startColumn": 8,
"endLine": 152,
"endColumn": 32
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:971",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 971,
"startColumn": 8,
"endLine": 971,
"endColumn": 32
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1243",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 1243,
"startColumn": 8,
"endLine": 1243,
"endColumn": 32
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:215",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 215,
"startColumn": 8,
"endLine": 215,
"endColumn": 32
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:103",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 103,
"startColumn": 8,
"endLine": 103,
"endColumn": 32
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1490",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 1490,
"startColumn": 8,
"endLine": 1490,
"endColumn": 32
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:2488",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 2488,
"startColumn": 8,
"endLine": 2488,
"endColumn": 32
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:812",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 812,
"startColumn": 8,
"endLine": 812,
"endColumn": 32
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:858",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 858,
"startColumn": 8,
"endLine": 858,
"endColumn": 32
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:860",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 860,
"startColumn": 33,
"endLine": 860,
"endColumn": 57
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:230",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 230,
"startColumn": 20,
"endLine": 230,
"endColumn": 44
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_apikey.py:120",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 120,
"startColumn": 29,
"endLine": 120,
"endColumn": 53
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_apikey.py:124",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 124,
"startColumn": 29,
"endLine": 124,
"endColumn": 53
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_balance_transaction.py:270",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 270,
"startColumn": 32,
"endLine": 270,
"endColumn": 56
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_balance_transaction.py:271",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 271,
"startColumn": 22,
"endLine": 271,
"endColumn": 46
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:189",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 189,
"startColumn": 26,
"endLine": 189,
"endColumn": 50
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:212",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 212,
"startColumn": 26,
"endLine": 212,
"endColumn": 50
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:153",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 153,
"startColumn": 59,
"endLine": 153,
"endColumn": 83
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:179",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 179,
"startColumn": 26,
"endLine": 179,
"endColumn": 50
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:106",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 106,
"startColumn": 39,
"endLine": 106,
"endColumn": 63
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:110",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 110,
"startColumn": 39,
"endLine": 110,
"endColumn": 63
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:113",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 113,
"startColumn": 42,
"endLine": 113,
"endColumn": 66
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_dispute.py:215",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 215,
"startColumn": 20,
"endLine": 215,
"endColumn": 44
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1465",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 1465,
"startColumn": 33,
"endLine": 1465,
"endColumn": 57
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoiceitem.py:148",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 148,
"startColumn": 24,
"endLine": 148,
"endColumn": 48
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_payment_method.py:74",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 74,
"startColumn": 22,
"endLine": 74,
"endColumn": 46
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_payment_method.py:82",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 82,
"startColumn": 22,
"endLine": 82,
"endColumn": 46
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_payment_method.py:82",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 82,
"startColumn": 61,
"endLine": 82,
"endColumn": 85
},
"snippet": "get_stripe_dashboard_url"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_transfer.py:159",
"targetRef": "djstripe/models/account.py:107",
"sourceSnippetRange": {
"startLine": 159,
"startColumn": 21,
"endLine": 159,
"endColumn": 45
},
"snippet": "get_stripe_dashboard_url"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/models/account.py:108",
"range": {
"startLine": 108,
"startColumn": 8,
"endLine": 108,
"endColumn": 59
},
"expression": "\"\"\"Get the stripe dashboard url for this object.\"\"\""
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "expand_fields",
"ref": "djstripe/models/base.py:91",
"definitionRange": {
"startLine": 91,
"startColumn": 4,
"endLine": 91,
"endColumn": 33
},
"language": "python",
"snippet": "expand_fields: List[str] = []",
"nameRange": {
"startLine": 91,
"startColumn": 4,
"endLine": 91,
"endColumn": 17
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:239",
"targetRef": "djstripe/models/base.py:91",
"sourceSnippetRange": {
"startLine": 239,
"startColumn": 24,
"endLine": 239,
"endColumn": 37
},
"snippet": "expand_fields"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2213",
"targetRef": "djstripe/models/base.py:91",
"sourceSnippetRange": {
"startLine": 2213,
"startColumn": 24,
"endLine": 2213,
"endColumn": 37
},
"snippet": "expand_fields"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:303",
"targetRef": "djstripe/models/base.py:91",
"sourceSnippetRange": {
"startLine": 303,
"startColumn": 24,
"endLine": 303,
"endColumn": 37
},
"snippet": "expand_fields"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:89",
"targetRef": "djstripe/models/base.py:91",
"sourceSnippetRange": {
"startLine": 89,
"startColumn": 15,
"endLine": 89,
"endColumn": 28
},
"snippet": "expand_fields"
}
],
"expressions": []
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "last_verification_report",
"ref": "djstripe/models/identity.py:16",
"definitionRange": {
"startLine": 16,
"startColumn": 4,
"endLine": 18,
"endColumn": 5
},
"language": "python",
"snippet": "last_verification_report = StripeForeignKey(\n \"djstripe.VerificationReport\", on_delete=models.SET_NULL, null=True, blank=True\n )",
"nameRange": {
"startLine": 16,
"startColumn": 4,
"endLine": 16,
"endColumn": 28
},
"references": [
{
"targetRef": "djstripe/models/identity.py:16",
"sourceSnippetRange": {
"startLine": 16,
"startColumn": 0,
"endLine": 16,
"endColumn": 49
},
"sourceRef": "djstripe/models/identity.py:16",
"type": "from-search",
"snippet": " last_verification_report = StripeForeignKey(\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/identity.py:16",
"range": {
"startLine": 16,
"startColumn": 31,
"endLine": 18,
"endColumn": 5
},
"name": "StripeForeignKey",
"expression": "StripeForeignKey(\n \"djstripe.VerificationReport\", on_delete=models.SET_NULL, null=True, blank=True\n )",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "StripeForeignKey",
"ref": "djstripe/fields.py:31",
"definitionRange": {
"startLine": 31,
"startColumn": 0,
"endLine": 32,
"endColumn": 8
},
"language": "python",
"snippet": "class StripeForeignKey(models.ForeignKey):\n pass",
"nameRange": {
"startLine": 31,
"startColumn": 6,
"endLine": 31,
"endColumn": 22
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:17",
"range": {
"startLine": 17,
"startColumn": 39,
"endLine": 17,
"endColumn": 64
},
"name": "SET_NULL",
"expression": "on_delete=models.SET_NULL",
"definition": {
"type": "function",
"filePath": "__base_types__",
"name": "SET_NULL",
"ref": "__base_types__:14",
"definitionRange": {
"startLine": 14,
"startColumn": 0,
"endLine": 19,
"endColumn": 14
},
"language": "python",
"snippet": "def SET_NULL(\n collector: Collector,\n field: Field[Any, Any],\n sub_objs: Sequence[Model],\n using: str,\n) -> None: ...",
"nameRange": {
"startLine": 14,
"startColumn": 4,
"endLine": 14,
"endColumn": 12
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:17",
"range": {
"startLine": 17,
"startColumn": 49,
"endLine": 17,
"endColumn": 64
},
"name": "models",
"expression": "models.SET_NULL",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "verified_outputs",
"ref": "djstripe/models/identity.py:20",
"definitionRange": {
"startLine": 20,
"startColumn": 4,
"endLine": 20,
"endColumn": 55
},
"language": "python",
"snippet": "verified_outputs = JSONField(null=True, blank=True)",
"nameRange": {
"startLine": 20,
"startColumn": 4,
"endLine": 20,
"endColumn": 20
},
"references": [
{
"targetRef": "djstripe/models/identity.py:20",
"sourceSnippetRange": {
"startLine": 20,
"startColumn": 0,
"endLine": 20,
"endColumn": 56
},
"sourceRef": "djstripe/models/identity.py:20",
"type": "from-search",
"snippet": " verified_outputs = JSONField(null=True, blank=True)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/identity.py:20",
"range": {
"startLine": 20,
"startColumn": 23,
"endLine": 20,
"endColumn": 55
},
"name": "JSONField",
"expression": "JSONField(null=True, blank=True)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "JSONField",
"ref": "djstripe/fields.py:149",
"definitionRange": {
"startLine": 149,
"startColumn": 0,
"endLine": 152,
"endColumn": 8
},
"language": "python",
"snippet": "class JSONField(FieldDeconstructMixin, BaseJSONField):\n \"\"\"A field used to define a JSONField value according to djstripe logic.\"\"\"\n\n pass",
"nameRange": {
"startLine": 149,
"startColumn": 6,
"endLine": 149,
"endColumn": 15
}
}
}
]
},
{
"type": "class",
"filePath": "djstripe/managers.py",
"name": "ChargeManager",
"ref": "djstripe/managers.py:83",
"definitionRange": {
"startLine": 83,
"startColumn": 0,
"endLine": 102,
"endColumn": 9
},
"language": "python",
"snippet": "class ChargeManager(models.Manager):\n \"\"\"Manager used by models.Charge.\"\"\"\n\n def during(self, year, month):\n \"\"\"Return Charges between a certain time range based on `created`.\"\"\"\n return self.filter(created__year=year, created__month=month)\n\n def paid_totals_for(self, year, month):\n \"\"\"\n Return paid Charges during a certain year, month with total amount,\n fee and refunded annotated.\n \"\"\"\n return (\n self.during(year, month)\n .filter(paid=True)\n .aggregate(\n total_amount=models.Sum(\"amount\"),\n total_refunded=models.Sum(\"amount_refunded\"),\n )\n )",
"nameRange": {
"startLine": 83,
"startColumn": 6,
"endLine": 83,
"endColumn": 19
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:25",
"targetRef": "djstripe/managers.py:83",
"sourceSnippetRange": {
"startLine": 25,
"startColumn": 23,
"endLine": 25,
"endColumn": 36
},
"snippet": "ChargeManager"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:388",
"targetRef": "djstripe/managers.py:83",
"sourceSnippetRange": {
"startLine": 388,
"startColumn": 14,
"endLine": 388,
"endColumn": 27
},
"snippet": "ChargeManager"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/managers.py:83",
"range": {
"startLine": 83,
"startColumn": 19,
"endLine": 83,
"endColumn": 35
},
"name": "Manager",
"expression": "(models.Manager)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Manager",
"ref": "__base_types__:39",
"definitionRange": {
"startLine": 39,
"startColumn": 0,
"endLine": 40,
"endColumn": 39
},
"language": "python",
"snippet": "class Manager(BaseManager[_T]):\n _queryset_class: type[QuerySet[_T]]",
"nameRange": {
"startLine": 39,
"startColumn": 6,
"endLine": 39,
"endColumn": 13
}
}
},
{
"type": "variable",
"ref": "djstripe/managers.py:83",
"range": {
"startLine": 83,
"startColumn": 20,
"endLine": 83,
"endColumn": 34
},
"name": "models",
"expression": "models.Manager",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
},
{
"type": "comment",
"ref": "djstripe/managers.py:84",
"range": {
"startLine": 84,
"startColumn": 4,
"endLine": 84,
"endColumn": 40
},
"expression": "\"\"\"Manager used by models.Charge.\"\"\""
},
{
"type": "comment",
"ref": "djstripe/managers.py:87",
"range": {
"startLine": 87,
"startColumn": 8,
"endLine": 87,
"endColumn": 77
},
"expression": "\"\"\"Return Charges between a certain time range based on `created`.\"\"\""
},
{
"type": "variable",
"ref": "djstripe/managers.py:88",
"range": {
"startLine": 88,
"startColumn": 27,
"endLine": 88,
"endColumn": 45
},
"name": "year",
"expression": "created__year=year",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "during",
"ref": "djstripe/managers.py:86",
"definitionRange": {
"startLine": 86,
"startColumn": 4,
"endLine": 88,
"endColumn": 68
},
"language": "python",
"snippet": "def during(self, year, month):\n \"\"\"Return Charges between a certain time range based on `created`.\"\"\"\n return self.filter(created__year=year, created__month=month)",
"nameRange": {
"startLine": 86,
"startColumn": 8,
"endLine": 86,
"endColumn": 14
}
}
},
{
"type": "comment",
"ref": "djstripe/managers.py:91",
"range": {
"startLine": 91,
"startColumn": 8,
"endLine": 94,
"endColumn": 11
},
"expression": "\"\"\"\n Return paid Charges during a certain year, month with total amount,\n fee and refunded annotated.\n \"\"\""
},
{
"type": "variable",
"ref": "djstripe/managers.py:96",
"range": {
"startLine": 96,
"startColumn": 23,
"endLine": 96,
"endColumn": 36
},
"name": "year",
"expression": "(year, month)",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "paid_totals_for",
"ref": "djstripe/managers.py:90",
"definitionRange": {
"startLine": 90,
"startColumn": 4,
"endLine": 102,
"endColumn": 9
},
"language": "python",
"snippet": "def paid_totals_for(self, year, month):\n \"\"\"\n Return paid Charges during a certain year, month with total amount,\n fee and refunded annotated.\n \"\"\"\n return (\n self.during(year, month)\n .filter(paid=True)\n .aggregate(\n total_amount=models.Sum(\"amount\"),\n total_refunded=models.Sum(\"amount_refunded\"),\n )\n )",
"nameRange": {
"startLine": 90,
"startColumn": 8,
"endLine": 90,
"endColumn": 23
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:96",
"range": {
"startLine": 96,
"startColumn": 12,
"endLine": 101,
"endColumn": 13
},
"name": "aggregate",
"expression": "self.during(year, month)\n .filter(paid=True)\n .aggregate(\n total_amount=models.Sum(\"amount\"),\n total_refunded=models.Sum(\"amount_refunded\"),\n )",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "aggregate",
"ref": "__base_types__:45",
"definitionRange": {
"startLine": 45,
"startColumn": 4,
"endLine": 45,
"endColumn": 73
},
"language": "python",
"snippet": "def aggregate(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...",
"nameRange": {
"startLine": 45,
"startColumn": 8,
"endLine": 45,
"endColumn": 17
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:99",
"range": {
"startLine": 99,
"startColumn": 29,
"endLine": 99,
"endColumn": 49
},
"name": "Sum",
"expression": "models.Sum(\"amount\")",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Sum",
"ref": "__base_types__:21",
"definitionRange": {
"startLine": 21,
"startColumn": 0,
"endLine": 21,
"endColumn": 25
},
"language": "python",
"snippet": "class Sum(Aggregate): ...",
"nameRange": {
"startLine": 21,
"startColumn": 6,
"endLine": 21,
"endColumn": 9
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "stripe_dashboard_item_name",
"ref": "djstripe/models/base.py:92",
"definitionRange": {
"startLine": 92,
"startColumn": 4,
"endLine": 92,
"endColumn": 35
},
"language": "python",
"snippet": "stripe_dashboard_item_name = \"\"",
"nameRange": {
"startLine": 92,
"startColumn": 4,
"endLine": 92,
"endColumn": 30
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:154",
"targetRef": "djstripe/models/base.py:92",
"sourceSnippetRange": {
"startLine": 154,
"startColumn": 20,
"endLine": 154,
"endColumn": 46
},
"snippet": "stripe_dashboard_item_name"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:158",
"targetRef": "djstripe/models/base.py:92",
"sourceSnippetRange": {
"startLine": 158,
"startColumn": 24,
"endLine": 158,
"endColumn": 50
},
"snippet": "stripe_dashboard_item_name"
}
],
"expressions": []
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "url",
"ref": "djstripe/models/identity.py:25",
"definitionRange": {
"startLine": 25,
"startColumn": 4,
"endLine": 25,
"endColumn": 14
},
"language": "python",
"snippet": "url = None",
"nameRange": {
"startLine": 25,
"startColumn": 4,
"endLine": 25,
"endColumn": 7
},
"references": [
{
"targetRef": "djstripe/models/identity.py:25",
"sourceSnippetRange": {
"startLine": 25,
"startColumn": 0,
"endLine": 25,
"endColumn": 15
},
"sourceRef": "djstripe/models/identity.py:25",
"type": "from-search",
"snippet": " url = None\n"
}
],
"expressions": []
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "client_secret",
"ref": "djstripe/models/identity.py:26",
"definitionRange": {
"startLine": 26,
"startColumn": 4,
"endLine": 26,
"endColumn": 24
},
"language": "python",
"snippet": "client_secret = None",
"nameRange": {
"startLine": 26,
"startColumn": 4,
"endLine": 26,
"endColumn": 17
},
"references": [
{
"targetRef": "djstripe/models/identity.py:26",
"sourceSnippetRange": {
"startLine": 26,
"startColumn": 0,
"endLine": 26,
"endColumn": 25
},
"sourceRef": "djstripe/models/identity.py:26",
"type": "from-search",
"snippet": " client_secret = None\n"
}
],
"expressions": []
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "status",
"ref": "djstripe/models/identity.py:21",
"definitionRange": {
"startLine": 21,
"startColumn": 4,
"endLine": 21,
"endColumn": 66
},
"language": "python",
"snippet": "status = StripeEnumField(enum=enums.VerificationSessionStatus)",
"nameRange": {
"startLine": 21,
"startColumn": 4,
"endLine": 21,
"endColumn": 10
},
"references": [
{
"targetRef": "djstripe/models/identity.py:21",
"sourceSnippetRange": {
"startLine": 21,
"startColumn": 0,
"endLine": 21,
"endColumn": 67
},
"sourceRef": "djstripe/models/identity.py:21",
"type": "from-search",
"snippet": " status = StripeEnumField(enum=enums.VerificationSessionStatus)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/identity.py:21",
"range": {
"startLine": 21,
"startColumn": 13,
"endLine": 21,
"endColumn": 66
},
"name": "StripeEnumField",
"expression": "StripeEnumField(enum=enums.VerificationSessionStatus)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "StripeEnumField",
"ref": "djstripe/fields.py:106",
"definitionRange": {
"startLine": 106,
"startColumn": 0,
"endLine": 117,
"endColumn": 39
},
"language": "python",
"snippet": "class StripeEnumField(FieldDeconstructMixin, models.CharField):\n def __init__(self, enum, *args, **kwargs):\n self.enum = enum\n choices = enum.choices\n defaults = {\"choices\": choices, \"max_length\": 255}\n defaults.update(kwargs)\n super().__init__(*args, **defaults)\n\n def deconstruct(self):\n name, path, args, kwargs = super().deconstruct()\n kwargs[\"enum\"] = self.enum\n return name, path, args, kwargs",
"nameRange": {
"startLine": 106,
"startColumn": 6,
"endLine": 106,
"endColumn": 21
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:21",
"range": {
"startLine": 21,
"startColumn": 29,
"endLine": 21,
"endColumn": 65
},
"name": "VerificationSessionStatus",
"expression": "enum=enums.VerificationSessionStatus",
"definition": {
"type": "class",
"filePath": "djstripe/enums.py",
"name": "VerificationSessionStatus",
"ref": "djstripe/enums.py:820",
"definitionRange": {
"startLine": 820,
"startColumn": 0,
"endLine": 828,
"endColumn": 28
},
"language": "python",
"snippet": "class VerificationSessionStatus(Enum):\n \"\"\"\n https://stripe.com/docs/api/identity/verification_sessions/object#identity_verification_session_object-status\n \"\"\"\n\n requires_input = _(\"Requires input\")\n processing = _(\"Processing\")\n verified = _(\"Verified\")\n canceled = _(\"Canceled\")",
"nameRange": {
"startLine": 820,
"startColumn": 6,
"endLine": 820,
"endColumn": 31
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:21",
"range": {
"startLine": 21,
"startColumn": 34,
"endLine": 21,
"endColumn": 65
},
"name": "enums",
"expression": "enums.VerificationSessionStatus",
"definition": {
"type": "import",
"filePath": "djstripe/enums.py",
"name": "operator",
"ref": "djstripe/enums.py:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 15
},
"language": "python",
"snippet": "import operator",
"nameRange": {
"startLine": 0,
"startColumn": 7,
"endLine": 0,
"endColumn": 15
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "type",
"ref": "djstripe/models/identity.py:22",
"definitionRange": {
"startLine": 22,
"startColumn": 4,
"endLine": 22,
"endColumn": 55
},
"language": "python",
"snippet": "type = StripeEnumField(enum=enums.VerificationType)",
"nameRange": {
"startLine": 22,
"startColumn": 4,
"endLine": 22,
"endColumn": 8
},
"references": [
{
"targetRef": "djstripe/models/identity.py:22",
"sourceSnippetRange": {
"startLine": 22,
"startColumn": 0,
"endLine": 22,
"endColumn": 56
},
"sourceRef": "djstripe/models/identity.py:22",
"type": "from-search",
"snippet": " type = StripeEnumField(enum=enums.VerificationType)\n"
},
{
"targetRef": "djstripe/models/identity.py:22",
"sourceSnippetRange": {
"startLine": 40,
"startColumn": 0,
"endLine": 40,
"endColumn": 56
},
"sourceRef": "djstripe/models/identity.py:40",
"type": "from-search",
"snippet": " type = StripeEnumField(enum=enums.VerificationType)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/identity.py:22",
"range": {
"startLine": 22,
"startColumn": 11,
"endLine": 22,
"endColumn": 55
},
"name": "StripeEnumField",
"expression": "StripeEnumField(enum=enums.VerificationType)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "StripeEnumField",
"ref": "djstripe/fields.py:106",
"definitionRange": {
"startLine": 106,
"startColumn": 0,
"endLine": 117,
"endColumn": 39
},
"language": "python",
"snippet": "class StripeEnumField(FieldDeconstructMixin, models.CharField):\n def __init__(self, enum, *args, **kwargs):\n self.enum = enum\n choices = enum.choices\n defaults = {\"choices\": choices, \"max_length\": 255}\n defaults.update(kwargs)\n super().__init__(*args, **defaults)\n\n def deconstruct(self):\n name, path, args, kwargs = super().deconstruct()\n kwargs[\"enum\"] = self.enum\n return name, path, args, kwargs",
"nameRange": {
"startLine": 106,
"startColumn": 6,
"endLine": 106,
"endColumn": 21
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:22",
"range": {
"startLine": 22,
"startColumn": 27,
"endLine": 22,
"endColumn": 54
},
"name": "VerificationType",
"expression": "enum=enums.VerificationType",
"definition": {
"type": "class",
"filePath": "djstripe/enums.py",
"name": "VerificationType",
"ref": "djstripe/enums.py:831",
"definitionRange": {
"startLine": 831,
"startColumn": 0,
"endLine": 837,
"endColumn": 30
},
"language": "python",
"snippet": "class VerificationType(Enum):\n \"\"\"\n https://stripe.com/docs/api/identity/verification_sessions/object#identity_verification_session_object-type\n \"\"\"\n\n document = _(\"Document\")\n id_number = _(\"ID number\")",
"nameRange": {
"startLine": 831,
"startColumn": 6,
"endLine": 831,
"endColumn": 22
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:22",
"range": {
"startLine": 22,
"startColumn": 32,
"endLine": 22,
"endColumn": 54
},
"name": "enums",
"expression": "enums.VerificationType",
"definition": {
"type": "import",
"filePath": "djstripe/enums.py",
"name": "operator",
"ref": "djstripe/enums.py:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 15
},
"language": "python",
"snippet": "import operator",
"nameRange": {
"startLine": 0,
"startColumn": 7,
"endLine": 0,
"endColumn": 15
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/managers.py",
"name": "paid_totals_for",
"ref": "djstripe/managers.py:90",
"definitionRange": {
"startLine": 90,
"startColumn": 4,
"endLine": 102,
"endColumn": 9
},
"language": "python",
"snippet": "def paid_totals_for(self, year, month):\n \"\"\"\n Return paid Charges during a certain year, month with total amount,\n fee and refunded annotated.\n \"\"\"\n return (\n self.during(year, month)\n .filter(paid=True)\n .aggregate(\n total_amount=models.Sum(\"amount\"),\n total_refunded=models.Sum(\"amount_refunded\"),\n )\n )",
"nameRange": {
"startLine": 90,
"startColumn": 8,
"endLine": 90,
"endColumn": 23
},
"references": [
{
"targetRef": "djstripe/managers.py:90",
"sourceSnippetRange": {
"startLine": 76,
"startColumn": 0,
"endLine": 76,
"endColumn": 44
},
"sourceRef": "djstripe/managers.py:76",
"type": "from-search",
"snippet": " def paid_totals_for(self, year, month):\n"
},
{
"targetRef": "djstripe/managers.py:90",
"sourceSnippetRange": {
"startLine": 90,
"startColumn": 0,
"endLine": 90,
"endColumn": 44
},
"sourceRef": "djstripe/managers.py:90",
"type": "from-search",
"snippet": " def paid_totals_for(self, year, month):\n"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/managers.py:91",
"range": {
"startLine": 91,
"startColumn": 8,
"endLine": 94,
"endColumn": 11
},
"expression": "\"\"\"\n Return paid Charges during a certain year, month with total amount,\n fee and refunded annotated.\n \"\"\""
},
{
"type": "call",
"ref": "djstripe/managers.py:96",
"range": {
"startLine": 96,
"startColumn": 12,
"endLine": 96,
"endColumn": 36
},
"name": "during",
"expression": "self.during(year, month)",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "during",
"ref": "djstripe/managers.py:86",
"definitionRange": {
"startLine": 86,
"startColumn": 4,
"endLine": 88,
"endColumn": 68
},
"language": "python",
"snippet": "def during(self, year, month):\n \"\"\"Return Charges between a certain time range based on `created`.\"\"\"\n return self.filter(created__year=year, created__month=month)",
"nameRange": {
"startLine": 86,
"startColumn": 8,
"endLine": 86,
"endColumn": 14
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:96",
"range": {
"startLine": 96,
"startColumn": 12,
"endLine": 101,
"endColumn": 13
},
"name": "aggregate",
"expression": "self.during(year, month)\n .filter(paid=True)\n .aggregate(\n total_amount=models.Sum(\"amount\"),\n total_refunded=models.Sum(\"amount_refunded\"),\n )",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "aggregate",
"ref": "__base_types__:45",
"definitionRange": {
"startLine": 45,
"startColumn": 4,
"endLine": 45,
"endColumn": 73
},
"language": "python",
"snippet": "def aggregate(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...",
"nameRange": {
"startLine": 45,
"startColumn": 8,
"endLine": 45,
"endColumn": 17
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:99",
"range": {
"startLine": 99,
"startColumn": 29,
"endLine": 99,
"endColumn": 49
},
"name": "Sum",
"expression": "models.Sum(\"amount\")",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Sum",
"ref": "__base_types__:21",
"definitionRange": {
"startLine": 21,
"startColumn": 0,
"endLine": 21,
"endColumn": 25
},
"language": "python",
"snippet": "class Sum(Aggregate): ...",
"nameRange": {
"startLine": 21,
"startColumn": 6,
"endLine": 21,
"endColumn": 9
}
}
},
{
"type": "variable",
"ref": "djstripe/managers.py:99",
"range": {
"startLine": 99,
"startColumn": 29,
"endLine": 99,
"endColumn": 39
},
"name": "models",
"expression": "models.Sum",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "objects",
"ref": "djstripe/models/base.py:94",
"definitionRange": {
"startLine": 94,
"startColumn": 4,
"endLine": 94,
"endColumn": 30
},
"language": "python",
"snippet": "objects = models.Manager()",
"nameRange": {
"startLine": 94,
"startColumn": 4,
"endLine": 94,
"endColumn": 11
},
"references": [
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 94,
"startColumn": 0,
"endLine": 94,
"endColumn": 31
},
"sourceRef": "djstripe/models/base.py:94",
"type": "from-search",
"snippet": " objects = models.Manager()\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 95,
"startColumn": 0,
"endLine": 95,
"endColumn": 42
},
"sourceRef": "djstripe/models/base.py:95",
"type": "from-search",
"snippet": " stripe_objects = StripeModelManager()\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 366,
"startColumn": 0,
"endLine": 366,
"endColumn": 59
},
"sourceRef": "djstripe/models/base.py:366",
"type": "from-search",
"snippet": " (so that an objects.create() call would not fail).\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 369,
"startColumn": 0,
"endLine": 369,
"endColumn": 85
},
"sourceRef": "djstripe/models/base.py:369",
"type": "from-search",
"snippet": " :param current_ids: stripe ids of objects that are currently being processed\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 452,
"startColumn": 0,
"endLine": 452,
"endColumn": 80
},
"sourceRef": "djstripe/models/base.py:452",
"type": "from-search",
"snippet": " # For all objects other than the account object itself, get the API key\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 478,
"startColumn": 0,
"endLine": 478,
"endColumn": 85
},
"sourceRef": "djstripe/models/base.py:478",
"type": "from-search",
"snippet": " :param current_ids: stripe ids of objects that are currently being processed\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 581,
"startColumn": 0,
"endLine": 581,
"endColumn": 30
},
"sourceRef": "djstripe/models/base.py:581",
"type": "from-search",
"snippet": " def _attach_objects_hook(\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 591,
"startColumn": 0,
"endLine": 591,
"endColumn": 85
},
"sourceRef": "djstripe/models/base.py:591",
"type": "from-search",
"snippet": " :param current_ids: stripe ids of objects that are currently being processed\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 597,
"startColumn": 0,
"endLine": 597,
"endColumn": 40
},
"sourceRef": "djstripe/models/base.py:597",
"type": "from-search",
"snippet": " def _attach_objects_post_save_hook(\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 620,
"startColumn": 0,
"endLine": 620,
"endColumn": 67
},
"sourceRef": "djstripe/models/base.py:620",
"type": "from-search",
"snippet": " target = field.model.objects.get(id=object_id)\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 657,
"startColumn": 0,
"endLine": 657,
"endColumn": 85
},
"sourceRef": "djstripe/models/base.py:657",
"type": "from-search",
"snippet": " :param current_ids: stripe ids of objects that are currently being processed\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 678,
"startColumn": 0,
"endLine": 678,
"endColumn": 58
},
"sourceRef": "djstripe/models/base.py:678",
"type": "from-search",
"snippet": " instance = cls.stripe_objects.get(id=id_)\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 688,
"startColumn": 0,
"endLine": 688,
"endColumn": 43
},
"sourceRef": "djstripe/models/base.py:688",
"type": "from-search",
"snippet": " instance._attach_objects_hook(\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 695,
"startColumn": 0,
"endLine": 695,
"endColumn": 53
},
"sourceRef": "djstripe/models/base.py:695",
"type": "from-search",
"snippet": " instance._attach_objects_post_save_hook(\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 718,
"startColumn": 0,
"endLine": 718,
"endColumn": 85
},
"sourceRef": "djstripe/models/base.py:718",
"type": "from-search",
"snippet": " :param current_ids: stripe ids of objects that are currently being processed\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 755,
"startColumn": 0,
"endLine": 755,
"endColumn": 57
},
"sourceRef": "djstripe/models/base.py:755",
"type": "from-search",
"snippet": " return cls.stripe_objects.get(id=id_), False\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 821,
"startColumn": 0,
"endLine": 821,
"endColumn": 57
},
"sourceRef": "djstripe/models/base.py:821",
"type": "from-search",
"snippet": " return cls.stripe_objects.get(id=id_), False\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 838,
"startColumn": 0,
"endLine": 838,
"endColumn": 85
},
"sourceRef": "djstripe/models/base.py:838",
"type": "from-search",
"snippet": " :param current_ids: stripe ids of objects that are currently being processed\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 916,
"startColumn": 0,
"endLine": 916,
"endColumn": 65
},
"sourceRef": "djstripe/models/base.py:916",
"type": "from-search",
"snippet": " tax_amount, _ = target_cls.objects.update_or_create(\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 1063,
"startColumn": 0,
"endLine": 1063,
"endColumn": 77
},
"sourceRef": "djstripe/models/base.py:1063",
"type": "from-search",
"snippet": " # stop nested objects from trying to retrieve this object before\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 1080,
"startColumn": 0,
"endLine": 1080,
"endColumn": 43
},
"sourceRef": "djstripe/models/base.py:1080",
"type": "from-search",
"snippet": " instance._attach_objects_hook(\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 1084,
"startColumn": 0,
"endLine": 1084,
"endColumn": 80
},
"sourceRef": "djstripe/models/base.py:1084",
"type": "from-search",
"snippet": " instance._attach_objects_post_save_hook(cls, data, api_key=api_key)\n"
},
{
"targetRef": "djstripe/models/base.py:94",
"sourceSnippetRange": {
"startLine": 1100,
"startColumn": 0,
"endLine": 1100,
"endColumn": 42
},
"sourceRef": "djstripe/models/base.py:1100",
"type": "from-search",
"snippet": " return cls.objects.get(id=id)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/base.py:94",
"range": {
"startLine": 94,
"startColumn": 14,
"endLine": 94,
"endColumn": 30
},
"name": "Manager",
"expression": "models.Manager()",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Manager",
"ref": "__base_types__:39",
"definitionRange": {
"startLine": 39,
"startColumn": 0,
"endLine": 40,
"endColumn": 39
},
"language": "python",
"snippet": "class Manager(BaseManager[_T]):\n _queryset_class: type[QuerySet[_T]]",
"nameRange": {
"startLine": 39,
"startColumn": 6,
"endLine": 39,
"endColumn": 13
}
}
},
{
"type": "variable",
"ref": "djstripe/models/base.py:94",
"range": {
"startLine": 94,
"startColumn": 14,
"endLine": 94,
"endColumn": 28
},
"name": "models",
"expression": "models.Manager",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "stripe_class",
"ref": "djstripe/models/identity.py:34",
"definitionRange": {
"startLine": 34,
"startColumn": 4,
"endLine": 34,
"endColumn": 53
},
"language": "python",
"snippet": "stripe_class = stripe.identity.VerificationReport",
"nameRange": {
"startLine": 34,
"startColumn": 4,
"endLine": 34,
"endColumn": 16
},
"references": [
{
"targetRef": "djstripe/models/identity.py:34",
"sourceSnippetRange": {
"startLine": 13,
"startColumn": 0,
"endLine": 13,
"endColumn": 55
},
"sourceRef": "djstripe/models/identity.py:13",
"type": "from-search",
"snippet": " stripe_class = stripe.identity.VerificationSession\n"
},
{
"targetRef": "djstripe/models/identity.py:34",
"sourceSnippetRange": {
"startLine": 34,
"startColumn": 0,
"endLine": 34,
"endColumn": 54
},
"sourceRef": "djstripe/models/identity.py:34",
"type": "from-search",
"snippet": " stripe_class = stripe.identity.VerificationReport\n"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/models/identity.py:34",
"range": {
"startLine": 34,
"startColumn": 19,
"endLine": 34,
"endColumn": 34
},
"name": "stripe",
"expression": "stripe.identity",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "Incomplete",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 32
},
"language": "python",
"snippet": "from _typeshed import Incomplete",
"nameRange": {
"startLine": 0,
"startColumn": 22,
"endLine": 0,
"endColumn": 32
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "document",
"ref": "djstripe/models/identity.py:36",
"definitionRange": {
"startLine": 36,
"startColumn": 4,
"endLine": 36,
"endColumn": 47
},
"language": "python",
"snippet": "document = JSONField(null=True, blank=True)",
"nameRange": {
"startLine": 36,
"startColumn": 4,
"endLine": 36,
"endColumn": 12
},
"references": [
{
"targetRef": "djstripe/models/identity.py:36",
"sourceSnippetRange": {
"startLine": 10,
"startColumn": 0,
"endLine": 10,
"endColumn": 85
},
"sourceRef": "djstripe/models/identity.py:10",
"type": "from-search",
"snippet": " Stripe documentation: https://stripe.com/docs/api/identity/verification_sessions\n"
},
{
"targetRef": "djstripe/models/identity.py:36",
"sourceSnippetRange": {
"startLine": 31,
"startColumn": 0,
"endLine": 31,
"endColumn": 84
},
"sourceRef": "djstripe/models/identity.py:31",
"type": "from-search",
"snippet": " Stripe documentation: https://stripe.com/docs/api/identity/verification_reports\n"
},
{
"targetRef": "djstripe/models/identity.py:36",
"sourceSnippetRange": {
"startLine": 36,
"startColumn": 0,
"endLine": 36,
"endColumn": 48
},
"sourceRef": "djstripe/models/identity.py:36",
"type": "from-search",
"snippet": " document = JSONField(null=True, blank=True)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/identity.py:36",
"range": {
"startLine": 36,
"startColumn": 15,
"endLine": 36,
"endColumn": 47
},
"name": "JSONField",
"expression": "JSONField(null=True, blank=True)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "JSONField",
"ref": "djstripe/fields.py:149",
"definitionRange": {
"startLine": 149,
"startColumn": 0,
"endLine": 152,
"endColumn": 8
},
"language": "python",
"snippet": "class JSONField(FieldDeconstructMixin, BaseJSONField):\n \"\"\"A field used to define a JSONField value according to djstripe logic.\"\"\"\n\n pass",
"nameRange": {
"startLine": 149,
"startColumn": 6,
"endLine": 149,
"endColumn": 15
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/models/base.py",
"name": "api_list",
"ref": "djstripe/models/base.py:66",
"definitionRange": {
"startLine": 66,
"startColumn": 4,
"endLine": 85,
"endColumn": 28
},
"language": "python",
"snippet": "def api_list(cls, api_key=djstripe_settings.STRIPE_SECRET_KEY, **kwargs):\n \"\"\"\n Call the stripe API's list operation for this model.\n\n :param api_key: The api key to use for this request. \\\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n\n See Stripe documentation for accepted kwargs for each object.\n\n :returns: an iterator over all items in the query\n \"\"\"\n # Update kwargs with `expand` param\n kwargs = cls.get_expand_params(api_key, **kwargs)\n\n return cls.stripe_class.list(\n api_key=api_key,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n **kwargs,\n ).auto_paging_iter()",
"nameRange": {
"startLine": 66,
"startColumn": 8,
"endLine": 66,
"endColumn": 16
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_process_events.py:86",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 86,
"startColumn": 41,
"endLine": 86,
"endColumn": 49
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:224",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 224,
"startColumn": 51,
"endLine": 224,
"endColumn": 59
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:324",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 324,
"startColumn": 49,
"endLine": 324,
"endColumn": 57
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:342",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 342,
"startColumn": 51,
"endLine": 342,
"endColumn": 59
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:361",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 361,
"startColumn": 52,
"endLine": 361,
"endColumn": 60
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:383",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 383,
"startColumn": 44,
"endLine": 383,
"endColumn": 52
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:398",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 398,
"startColumn": 45,
"endLine": 398,
"endColumn": 53
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:413",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 413,
"startColumn": 44,
"endLine": 413,
"endColumn": 52
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:428",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 428,
"startColumn": 52,
"endLine": 428,
"endColumn": 60
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:431",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 431,
"startColumn": 65,
"endLine": 431,
"endColumn": 73
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1396",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 1396,
"startColumn": 8,
"endLine": 1396,
"endColumn": 16
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1562",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 1562,
"startColumn": 8,
"endLine": 1562,
"endColumn": 16
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1578",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 1578,
"startColumn": 23,
"endLine": 1578,
"endColumn": 31
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2219",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 2219,
"startColumn": 8,
"endLine": 2219,
"endColumn": 16
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2410",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 2410,
"startColumn": 8,
"endLine": 2410,
"endColumn": 16
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:308",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 308,
"startColumn": 8,
"endLine": 308,
"endColumn": 16
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1396",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 1396,
"startColumn": 38,
"endLine": 1396,
"endColumn": 46
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1401",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 1401,
"startColumn": 36,
"endLine": 1401,
"endColumn": 44
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1415",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 1415,
"startColumn": 48,
"endLine": 1415,
"endColumn": 56
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:725",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 725,
"startColumn": 8,
"endLine": 725,
"endColumn": 16
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:754",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 754,
"startColumn": 8,
"endLine": 754,
"endColumn": 16
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:806",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 806,
"startColumn": 44,
"endLine": 806,
"endColumn": 52
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/management/commands/regenerate_test_fixtures.py:311",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 311,
"startColumn": 64,
"endLine": 311,
"endColumn": 72
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/management/commands/regenerate_test_fixtures.py:319",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 319,
"startColumn": 48,
"endLine": 319,
"endColumn": 56
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_line_item.py:151",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 151,
"startColumn": 21,
"endLine": 151,
"endColumn": 29
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription.py:1159",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 1159,
"startColumn": 21,
"endLine": 1159,
"endColumn": 29
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription.py:1174",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 1174,
"startColumn": 21,
"endLine": 1174,
"endColumn": 29
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_tax_id.py:182",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 182,
"startColumn": 14,
"endLine": 182,
"endColumn": 22
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_transfer_reversal.py:162",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 162,
"startColumn": 25,
"endLine": 162,
"endColumn": 33
},
"snippet": "api_list"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_usage_record_summary.py:285",
"targetRef": "djstripe/models/base.py:66",
"sourceSnippetRange": {
"startLine": 285,
"startColumn": 27,
"endLine": 285,
"endColumn": 35
},
"snippet": "api_list"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/models/base.py:66",
"range": {
"startLine": 66,
"startColumn": 30,
"endLine": 66,
"endColumn": 65
},
"name": "djstripe_settings",
"expression": "djstripe_settings.STRIPE_SECRET_KEY",
"definition": {
"type": "expression",
"filePath": "djstripe/settings.py",
"name": "djstripe_settings",
"ref": "djstripe/settings.py:236",
"definitionRange": {
"startLine": 236,
"startColumn": 0,
"endLine": 236,
"endColumn": 38
},
"language": "python",
"snippet": "djstripe_settings = DjstripeSettings()",
"nameRange": {
"startLine": 236,
"startColumn": 0,
"endLine": 236,
"endColumn": 17
}
}
},
{
"type": "comment",
"ref": "djstripe/models/base.py:67",
"range": {
"startLine": 67,
"startColumn": 8,
"endLine": 77,
"endColumn": 11
},
"expression": "\"\"\"\n Call the stripe API's list operation for this model.\n\n :param api_key: The api key to use for this request. \\\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n\n See Stripe documentation for accepted kwargs for each object.\n\n :returns: an iterator over all items in the query\n \"\"\""
},
{
"type": "comment",
"ref": "djstripe/models/base.py:78",
"range": {
"startLine": 78,
"startColumn": 8,
"endLine": 78,
"endColumn": 43
},
"expression": "# Update kwargs with `expand` param"
},
{
"type": "call",
"ref": "djstripe/models/base.py:79",
"range": {
"startLine": 79,
"startColumn": 17,
"endLine": 79,
"endColumn": 57
},
"name": "get_expand_params",
"expression": "cls.get_expand_params(api_key, **kwargs)",
"definition": {
"type": "method",
"filePath": "djstripe/models/base.py",
"name": "get_expand_params",
"ref": "djstripe/models/base.py:40",
"definitionRange": {
"startLine": 40,
"startColumn": 4,
"endLine": 63,
"endColumn": 21
},
"language": "python",
"snippet": "def get_expand_params(cls, api_key, **kwargs):\n \"\"\"Populate `expand` kwarg in stripe api calls by updating the kwargs passed.\"\"\"\n # To avoid Circular Import Error\n from djstripe.management.commands.djstripe_sync_models import Command\n\n # As api_list is a class method we will never get the stripe account unless we\n # default to the owner account of the api_key. But even that is pointless as we only care about expand\n # So no need to make a call to Stripe and again do an account object sync which would make\n # no sense if this is for a Stripe Connected Account\n expand = Command.get_default_list_kwargs(\n cls, {kwargs.get(\"stripe_account\", \"acct_fake\")}, api_key\n )[0].get(\"expand\", [])\n\n # Add expand to the provided list\n if kwargs.get(\"expand\"):\n kwargs[\"expand\"].extend(expand)\n else:\n kwargs[\"expand\"] = expand\n\n # Keep only unique elements\n # Sort it to ensure the items are returned in the same order\n kwargs[\"expand\"] = sorted(list(set(kwargs[\"expand\"])))\n\n return kwargs",
"nameRange": {
"startLine": 40,
"startColumn": 8,
"endLine": 40,
"endColumn": 25
}
}
},
{
"type": "variable",
"ref": "djstripe/models/base.py:83",
"range": {
"startLine": 83,
"startColumn": 12,
"endLine": 83,
"endColumn": 63
},
"name": "STRIPE_API_VERSION",
"expression": "stripe_version=djstripe_settings.STRIPE_API_VERSION",
"definition": {
"type": "method",
"filePath": "djstripe/settings.py",
"name": "STRIPE_API_VERSION",
"ref": "djstripe/settings.py:122",
"definitionRange": {
"startLine": 122,
"startColumn": 4,
"endLine": 127,
"endColumn": 57
},
"language": "python",
"snippet": "def STRIPE_API_VERSION(self) -> str:\n \"\"\"\n Get the desired API version to use for Stripe requests.\n \"\"\"\n version = getattr(settings, \"STRIPE_API_VERSION\", stripe.api_version)\n return version or self.DEFAULT_STRIPE_API_VERSION",
"nameRange": {
"startLine": 122,
"startColumn": 8,
"endLine": 122,
"endColumn": 26
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "id_number",
"ref": "djstripe/models/identity.py:37",
"definitionRange": {
"startLine": 37,
"startColumn": 4,
"endLine": 37,
"endColumn": 48
},
"language": "python",
"snippet": "id_number = JSONField(null=True, blank=True)",
"nameRange": {
"startLine": 37,
"startColumn": 4,
"endLine": 37,
"endColumn": 13
},
"references": [
{
"targetRef": "djstripe/models/identity.py:37",
"sourceSnippetRange": {
"startLine": 37,
"startColumn": 0,
"endLine": 37,
"endColumn": 49
},
"sourceRef": "djstripe/models/identity.py:37",
"type": "from-search",
"snippet": " id_number = JSONField(null=True, blank=True)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/identity.py:37",
"range": {
"startLine": 37,
"startColumn": 16,
"endLine": 37,
"endColumn": 48
},
"name": "JSONField",
"expression": "JSONField(null=True, blank=True)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "JSONField",
"ref": "djstripe/fields.py:149",
"definitionRange": {
"startLine": 149,
"startColumn": 0,
"endLine": 152,
"endColumn": 8
},
"language": "python",
"snippet": "class JSONField(FieldDeconstructMixin, BaseJSONField):\n \"\"\"A field used to define a JSONField value according to djstripe logic.\"\"\"\n\n pass",
"nameRange": {
"startLine": 149,
"startColumn": 6,
"endLine": 149,
"endColumn": 15
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/models/account.py",
"name": "api_reject",
"ref": "djstripe/models/account.py:114",
"definitionRange": {
"startLine": 114,
"startColumn": 4,
"endLine": 137,
"endColumn": 9
},
"language": "python",
"snippet": "def api_reject(self, api_key=None, stripe_account=None, **kwargs):\n \"\"\"\n Call the stripe API's reject operation for Account model\n\n :param api_key: The api key to use for this request.\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n \"\"\"\n api_key = api_key or self.default_api_key\n\n # Prefer passed in stripe_account if set.\n if not stripe_account:\n stripe_account = self._get_stripe_account_id(api_key)\n\n return self.stripe_class.reject(\n self.id,\n api_key=api_key,\n stripe_account=stripe_account,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n **kwargs,\n )",
"nameRange": {
"startLine": 114,
"startColumn": 8,
"endLine": 114,
"endColumn": 18
},
"references": [
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:499",
"targetRef": "djstripe/models/account.py:114",
"sourceSnippetRange": {
"startLine": 499,
"startColumn": 31,
"endLine": 499,
"endColumn": 41
},
"snippet": "api_reject"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/models/account.py:115",
"range": {
"startLine": 115,
"startColumn": 8,
"endLine": 124,
"endColumn": 11
},
"expression": "\"\"\"\n Call the stripe API's reject operation for Account model\n\n :param api_key: The api key to use for this request.\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n \"\"\""
},
{
"type": "comment",
"ref": "djstripe/models/account.py:127",
"range": {
"startLine": 127,
"startColumn": 8,
"endLine": 127,
"endColumn": 49
},
"expression": "# Prefer passed in stripe_account if set."
},
{
"type": "call",
"ref": "djstripe/models/account.py:129",
"range": {
"startLine": 129,
"startColumn": 29,
"endLine": 129,
"endColumn": 65
},
"name": "_get_stripe_account_id",
"expression": "self._get_stripe_account_id(api_key)",
"definition": {
"type": "method",
"filePath": "djstripe/models/base.py",
"name": "_get_stripe_account_id",
"ref": "djstripe/models/base.py:169",
"definitionRange": {
"startLine": 169,
"startColumn": 4,
"endLine": 216,
"endColumn": 19
},
"language": "python",
"snippet": "def _get_stripe_account_id(self, api_key=None) -> Optional[str]:\n \"\"\"\n Call the stripe API's retrieve operation for this model.\n\n :param api_key: The api key to use for this request. \\\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n \"\"\"\n from djstripe.models import Account\n\n api_key = api_key or self.default_api_key\n\n try:\n djstripe_owner_account = self.djstripe_owner_account\n if djstripe_owner_account is not None:\n return djstripe_owner_account.id\n except (AttributeError, KeyError, ValueError):\n pass\n\n # Get reverse foreign key relations to Account in case we need to\n # retrieve ourselves using that Account ID.\n reverse_account_relations = (\n field\n for field in self._meta.get_fields(include_parents=True)\n if field.is_relation\n and field.one_to_many\n and field.related_model is Account\n )\n\n # Handle case where we have a reverse relation to Account and should pass\n # that account ID to the retrieve call.\n for field in reverse_account_relations:\n # Grab the related object, using the first one we find.\n reverse_lookup_attr = field.get_accessor_name()\n try:\n account = getattr(self, reverse_lookup_attr).first()\n except ValueError:\n if isinstance(self, Account):\n # return the id if self is the Account model itself.\n return self.id\n else:\n if account is not None:\n return account.id\n\n return None",
"nameRange": {
"startLine": 169,
"startColumn": 8,
"endLine": 169,
"endColumn": 30
}
}
},
{
"type": "variable",
"ref": "djstripe/models/account.py:131",
"range": {
"startLine": 131,
"startColumn": 39,
"endLine": 137,
"endColumn": 9
},
"name": "id",
"expression": "(\n self.id,\n api_key=api_key,\n stripe_account=stripe_account,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n **kwargs,\n )",
"definition": {
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "id",
"ref": "djstripe/models/base.py:100",
"definitionRange": {
"startLine": 100,
"startColumn": 4,
"endLine": 100,
"endColumn": 35
},
"language": "python",
"snippet": "id = StripeIdField(unique=True)",
"nameRange": {
"startLine": 100,
"startColumn": 4,
"endLine": 100,
"endColumn": 6
}
}
},
{
"type": "variable",
"ref": "djstripe/models/account.py:135",
"range": {
"startLine": 135,
"startColumn": 12,
"endLine": 135,
"endColumn": 63
},
"name": "STRIPE_API_VERSION",
"expression": "stripe_version=djstripe_settings.STRIPE_API_VERSION",
"definition": {
"type": "method",
"filePath": "djstripe/settings.py",
"name": "STRIPE_API_VERSION",
"ref": "djstripe/settings.py:122",
"definitionRange": {
"startLine": 122,
"startColumn": 4,
"endLine": 127,
"endColumn": 57
},
"language": "python",
"snippet": "def STRIPE_API_VERSION(self) -> str:\n \"\"\"\n Get the desired API version to use for Stripe requests.\n \"\"\"\n version = getattr(settings, \"STRIPE_API_VERSION\", stripe.api_version)\n return version or self.DEFAULT_STRIPE_API_VERSION",
"nameRange": {
"startLine": 122,
"startColumn": 8,
"endLine": 122,
"endColumn": 26
}
}
},
{
"type": "variable",
"ref": "djstripe/models/account.py:135",
"range": {
"startLine": 135,
"startColumn": 27,
"endLine": 135,
"endColumn": 63
},
"name": "djstripe_settings",
"expression": "djstripe_settings.STRIPE_API_VERSION",
"definition": {
"type": "expression",
"filePath": "djstripe/settings.py",
"name": "djstripe_settings",
"ref": "djstripe/settings.py:236",
"definitionRange": {
"startLine": 236,
"startColumn": 0,
"endLine": 236,
"endColumn": 38
},
"language": "python",
"snippet": "djstripe_settings = DjstripeSettings()",
"nameRange": {
"startLine": 236,
"startColumn": 0,
"endLine": 236,
"endColumn": 17
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/settings.py",
"name": "get_subscriber_model",
"ref": "djstripe/settings.py:187",
"definitionRange": {
"startLine": 187,
"startColumn": 4,
"endLine": 232,
"endColumn": 31
},
"language": "python",
"snippet": "def get_subscriber_model(self):\n \"\"\"\n Attempt to pull settings.DJSTRIPE_SUBSCRIBER_MODEL.\n\n Users have the option of specifying a custom subscriber model via the\n DJSTRIPE_SUBSCRIBER_MODEL setting.\n\n This methods falls back to AUTH_USER_MODEL if DJSTRIPE_SUBSCRIBER_MODEL is not set.\n\n Returns the subscriber model that is active in this project.\n \"\"\"\n model_name = self.get_subscriber_model_string()\n\n # Attempt a Django 1.7 app lookup\n try:\n subscriber_model = django_apps.get_model(model_name)\n except ValueError:\n raise ImproperlyConfigured(\n \"DJSTRIPE_SUBSCRIBER_MODEL must be of the form 'app_label.model_name'.\"\n )\n except LookupError:\n raise ImproperlyConfigured(\n f\"DJSTRIPE_SUBSCRIBER_MODEL refers to model '{model_name}' \"\n \"that has not been installed.\"\n )\n\n if (\n \"email\"\n not in [field_.name for field_ in subscriber_model._meta.get_fields()]\n ) and not hasattr(subscriber_model, \"email\"):\n raise ImproperlyConfigured(\n \"DJSTRIPE_SUBSCRIBER_MODEL must have an email attribute.\"\n )\n\n if model_name != settings.AUTH_USER_MODEL:\n # Custom user model detected. Make sure the callback is configured.\n func = self.get_callback_function(\n \"DJSTRIPE_SUBSCRIBER_MODEL_REQUEST_CALLBACK\"\n )\n if not func:\n raise ImproperlyConfigured(\n \"DJSTRIPE_SUBSCRIBER_MODEL_REQUEST_CALLBACK must be implemented \"\n \"if a DJSTRIPE_SUBSCRIBER_MODEL is defined.\"\n )\n\n return subscriber_model",
"nameRange": {
"startLine": 187,
"startColumn": 8,
"endLine": 187,
"endColumn": 28
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/event_handlers.py:37",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 37,
"startColumn": 45,
"endLine": 37,
"endColumn": 65
},
"snippet": "get_subscriber_model"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_init_customers.py:19",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 19,
"startColumn": 42,
"endLine": 19,
"endColumn": 62
},
"snippet": "get_subscriber_model"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_customers.py:17",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 17,
"startColumn": 31,
"endLine": 17,
"endColumn": 51
},
"snippet": "get_subscriber_model"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1377",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 1377,
"startColumn": 36,
"endLine": 1377,
"endColumn": 56
},
"snippet": "get_subscriber_model"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_migrations.py:28",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 28,
"startColumn": 64,
"endLine": 28,
"endColumn": 84
},
"snippet": "get_subscriber_model"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:17",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 17,
"startColumn": 48,
"endLine": 17,
"endColumn": 68
},
"snippet": "get_subscriber_model"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:25",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 25,
"startColumn": 47,
"endLine": 25,
"endColumn": 67
},
"snippet": "get_subscriber_model"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:33",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 33,
"startColumn": 47,
"endLine": 33,
"endColumn": 67
},
"snippet": "get_subscriber_model"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:44",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 44,
"startColumn": 39,
"endLine": 44,
"endColumn": 59
},
"snippet": "get_subscriber_model"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:58",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 58,
"startColumn": 39,
"endLine": 58,
"endColumn": 59
},
"snippet": "get_subscriber_model"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:69",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 69,
"startColumn": 39,
"endLine": 69,
"endColumn": 59
},
"snippet": "get_subscriber_model"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:80",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 80,
"startColumn": 39,
"endLine": 80,
"endColumn": 59
},
"snippet": "get_subscriber_model"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_settings.py:91",
"targetRef": "djstripe/settings.py:187",
"sourceSnippetRange": {
"startLine": 91,
"startColumn": 39,
"endLine": 91,
"endColumn": 59
},
"snippet": "get_subscriber_model"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/settings.py:188",
"range": {
"startLine": 188,
"startColumn": 8,
"endLine": 197,
"endColumn": 11
},
"expression": "\"\"\"\n Attempt to pull settings.DJSTRIPE_SUBSCRIBER_MODEL.\n\n Users have the option of specifying a custom subscriber model via the\n DJSTRIPE_SUBSCRIBER_MODEL setting.\n\n This methods falls back to AUTH_USER_MODEL if DJSTRIPE_SUBSCRIBER_MODEL is not set.\n\n Returns the subscriber model that is active in this project.\n \"\"\""
},
{
"type": "call",
"ref": "djstripe/settings.py:198",
"range": {
"startLine": 198,
"startColumn": 21,
"endLine": 198,
"endColumn": 55
},
"name": "get_subscriber_model_string",
"expression": "self.get_subscriber_model_string()",
"definition": {
"type": "method",
"filePath": "djstripe/settings.py",
"name": "get_subscriber_model_string",
"ref": "djstripe/settings.py:183",
"definitionRange": {
"startLine": 183,
"startColumn": 4,
"endLine": 185,
"endColumn": 103
},
"language": "python",
"snippet": "def get_subscriber_model_string(self) -> str:\n \"\"\"Get the configured subscriber model as a module path string.\"\"\"\n return getattr(settings, \"DJSTRIPE_SUBSCRIBER_MODEL\", settings.AUTH_USER_MODEL) # type: ignore",
"nameRange": {
"startLine": 183,
"startColumn": 8,
"endLine": 183,
"endColumn": 35
}
}
},
{
"type": "comment",
"ref": "djstripe/settings.py:200",
"range": {
"startLine": 200,
"startColumn": 8,
"endLine": 200,
"endColumn": 41
},
"expression": "# Attempt a Django 1.7 app lookup"
},
{
"type": "call",
"ref": "djstripe/settings.py:202",
"range": {
"startLine": 202,
"startColumn": 31,
"endLine": 202,
"endColumn": 64
},
"name": "get_model",
"expression": "django_apps.get_model(model_name)",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "get_model",
"ref": "__base_types__:30",
"definitionRange": {
"startLine": 30,
"startColumn": 4,
"endLine": 32,
"endColumn": 25
},
"language": "python",
"snippet": "def get_model(\n self, app_label: str, model_name: str | None = ..., require_ready: bool = ...\n ) -> type[Model]: ...",
"nameRange": {
"startLine": 30,
"startColumn": 8,
"endLine": 30,
"endColumn": 17
}
}
},
{
"type": "variable",
"ref": "djstripe/settings.py:202",
"range": {
"startLine": 202,
"startColumn": 31,
"endLine": 202,
"endColumn": 52
},
"name": "django_apps",
"expression": "django_apps.get_model",
"definition": {
"type": "expression",
"filePath": "__base_types__",
"name": "apps",
"ref": "__base_types__:48",
"definitionRange": {
"startLine": 48,
"startColumn": 0,
"endLine": 48,
"endColumn": 10
},
"language": "python",
"snippet": "apps: Apps",
"nameRange": {
"startLine": 48,
"startColumn": 0,
"endLine": 48,
"endColumn": 4
}
}
},
{
"type": "call",
"ref": "djstripe/settings.py:204",
"range": {
"startLine": 204,
"startColumn": 18,
"endLine": 206,
"endColumn": 13
},
"name": "ImproperlyConfigured",
"expression": "ImproperlyConfigured(\n \"DJSTRIPE_SUBSCRIBER_MODEL must be of the form 'app_label.model_name'.\"\n )",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "ImproperlyConfigured",
"ref": "__base_types__:24",
"definitionRange": {
"startLine": 24,
"startColumn": 0,
"endLine": 24,
"endColumn": 42
},
"language": "python",
"snippet": "class ImproperlyConfigured(Exception): ...",
"nameRange": {
"startLine": 24,
"startColumn": 6,
"endLine": 24,
"endColumn": 26
}
}
},
{
"type": "call",
"ref": "djstripe/settings.py:215",
"range": {
"startLine": 215,
"startColumn": 46,
"endLine": 215,
"endColumn": 81
},
"name": "get_fields",
"expression": "subscriber_model._meta.get_fields()",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "get_fields",
"ref": "__base_types__:126",
"definitionRange": {
"startLine": 126,
"startColumn": 4,
"endLine": 128,
"endColumn": 54
},
"language": "python",
"snippet": "def get_fields(\n self, include_parents: bool = ..., include_hidden: bool = ...\n ) -> list[Field[Any, Any] | ForeignObjectRel]: ...",
"nameRange": {
"startLine": 126,
"startColumn": 8,
"endLine": 126,
"endColumn": 18
}
}
},
{
"type": "expression",
"ref": "djstripe/settings.py:221",
"range": {
"startLine": 221,
"startColumn": 11,
"endLine": 221,
"endColumn": 49
},
"name": "AUTH_USER_MODEL",
"expression": "model_name != settings.AUTH_USER_MODEL",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "__getattr__",
"ref": "__base_types__:9",
"definitionRange": {
"startLine": 9,
"startColumn": 4,
"endLine": 9,
"endColumn": 48
},
"language": "python",
"snippet": "def __getattr__(self, item: Any) -> Any: ...",
"nameRange": {
"startLine": 9,
"startColumn": 8,
"endLine": 9,
"endColumn": 19
}
}
},
{
"type": "comment",
"ref": "djstripe/settings.py:222",
"range": {
"startLine": 222,
"startColumn": 12,
"endLine": 222,
"endColumn": 79
},
"expression": "# Custom user model detected. Make sure the callback is configured."
},
{
"type": "call",
"ref": "djstripe/settings.py:223",
"range": {
"startLine": 223,
"startColumn": 19,
"endLine": 225,
"endColumn": 13
},
"name": "get_callback_function",
"expression": "self.get_callback_function(\n \"DJSTRIPE_SUBSCRIBER_MODEL_REQUEST_CALLBACK\"\n )",
"definition": {
"type": "method",
"filePath": "djstripe/settings.py",
"name": "get_callback_function",
"ref": "djstripe/settings.py:129",
"definitionRange": {
"startLine": 129,
"startColumn": 4,
"endLine": 158,
"endColumn": 19
},
"language": "python",
"snippet": "def get_callback_function(self, setting_name, default=None):\n \"\"\"\n Resolve a callback function based on a setting name.\n\n If the setting value isn't set, default is returned. If the setting value\n is already a callable function, that value is used - If the setting value\n is a string, an attempt is made to import it. Anything else will result in\n a failed import causing ImportError to be raised.\n\n :param setting_name: The name of the setting to resolve a callback from.\n :type setting_name: string (``str``/``unicode``)\n :param default: The default to return if setting isn't populated.\n :type default: ``bool``\n :returns: The resolved callback function (if any).\n :type: ``callable``\n \"\"\"\n func = getattr(settings, setting_name, None)\n if not func:\n return default\n\n if callable(func):\n return func\n\n if isinstance(func, str):\n func = import_string(func)\n\n if not callable(func):\n raise ImproperlyConfigured(f\"{setting_name} must be callable.\")\n\n return func",
"nameRange": {
"startLine": 129,
"startColumn": 8,
"endLine": 129,
"endColumn": 29
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "stripe_objects",
"ref": "djstripe/models/base.py:95",
"definitionRange": {
"startLine": 95,
"startColumn": 4,
"endLine": 95,
"endColumn": 41
},
"language": "python",
"snippet": "stripe_objects = StripeModelManager()",
"nameRange": {
"startLine": 95,
"startColumn": 4,
"endLine": 95,
"endColumn": 18
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:678",
"targetRef": "djstripe/models/base.py:95",
"sourceSnippetRange": {
"startLine": 678,
"startColumn": 31,
"endLine": 678,
"endColumn": 45
},
"snippet": "stripe_objects"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:755",
"targetRef": "djstripe/models/base.py:95",
"sourceSnippetRange": {
"startLine": 755,
"startColumn": 23,
"endLine": 755,
"endColumn": 37
},
"snippet": "stripe_objects"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:821",
"targetRef": "djstripe/models/base.py:95",
"sourceSnippetRange": {
"startLine": 821,
"startColumn": 23,
"endLine": 821,
"endColumn": 37
},
"snippet": "stripe_objects"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/base.py:95",
"range": {
"startLine": 95,
"startColumn": 21,
"endLine": 95,
"endColumn": 41
},
"name": "StripeModelManager",
"expression": "StripeModelManager()",
"definition": {
"type": "class",
"filePath": "djstripe/managers.py",
"name": "StripeModelManager",
"ref": "djstripe/managers.py:9",
"definitionRange": {
"startLine": 9,
"startColumn": 0,
"endLine": 12,
"endColumn": 8
},
"language": "python",
"snippet": "class StripeModelManager(models.Manager):\n \"\"\"Manager used in StripeModel.\"\"\"\n\n pass",
"nameRange": {
"startLine": 9,
"startColumn": 6,
"endLine": 9,
"endColumn": 24
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "options",
"ref": "djstripe/models/identity.py:38",
"definitionRange": {
"startLine": 38,
"startColumn": 4,
"endLine": 38,
"endColumn": 46
},
"language": "python",
"snippet": "options = JSONField(null=True, blank=True)",
"nameRange": {
"startLine": 38,
"startColumn": 4,
"endLine": 38,
"endColumn": 11
},
"references": [
{
"targetRef": "djstripe/models/identity.py:38",
"sourceSnippetRange": {
"startLine": 38,
"startColumn": 0,
"endLine": 38,
"endColumn": 47
},
"sourceRef": "djstripe/models/identity.py:38",
"type": "from-search",
"snippet": " options = JSONField(null=True, blank=True)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/identity.py:38",
"range": {
"startLine": 38,
"startColumn": 14,
"endLine": 38,
"endColumn": 46
},
"name": "JSONField",
"expression": "JSONField(null=True, blank=True)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "JSONField",
"ref": "djstripe/fields.py:149",
"definitionRange": {
"startLine": 149,
"startColumn": 0,
"endLine": 152,
"endColumn": 8
},
"language": "python",
"snippet": "class JSONField(FieldDeconstructMixin, BaseJSONField):\n \"\"\"A field used to define a JSONField value according to djstripe logic.\"\"\"\n\n pass",
"nameRange": {
"startLine": 149,
"startColumn": 6,
"endLine": 149,
"endColumn": 15
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "selfie",
"ref": "djstripe/models/identity.py:39",
"definitionRange": {
"startLine": 39,
"startColumn": 4,
"endLine": 39,
"endColumn": 45
},
"language": "python",
"snippet": "selfie = JSONField(null=True, blank=True)",
"nameRange": {
"startLine": 39,
"startColumn": 4,
"endLine": 39,
"endColumn": 10
},
"references": [
{
"targetRef": "djstripe/models/identity.py:39",
"sourceSnippetRange": {
"startLine": 39,
"startColumn": 0,
"endLine": 39,
"endColumn": 46
},
"sourceRef": "djstripe/models/identity.py:39",
"type": "from-search",
"snippet": " selfie = JSONField(null=True, blank=True)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/identity.py:39",
"range": {
"startLine": 39,
"startColumn": 13,
"endLine": 39,
"endColumn": 45
},
"name": "JSONField",
"expression": "JSONField(null=True, blank=True)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "JSONField",
"ref": "djstripe/fields.py:149",
"definitionRange": {
"startLine": 149,
"startColumn": 0,
"endLine": 152,
"endColumn": 8
},
"language": "python",
"snippet": "class JSONField(FieldDeconstructMixin, BaseJSONField):\n \"\"\"A field used to define a JSONField value according to djstripe logic.\"\"\"\n\n pass",
"nameRange": {
"startLine": 149,
"startColumn": 6,
"endLine": 149,
"endColumn": 15
}
}
}
]
},
{
"type": "method",
"filePath": "djstripe/models/base.py",
"name": "get_expand_params",
"ref": "djstripe/models/base.py:40",
"definitionRange": {
"startLine": 40,
"startColumn": 4,
"endLine": 63,
"endColumn": 21
},
"language": "python",
"snippet": "def get_expand_params(cls, api_key, **kwargs):\n \"\"\"Populate `expand` kwarg in stripe api calls by updating the kwargs passed.\"\"\"\n # To avoid Circular Import Error\n from djstripe.management.commands.djstripe_sync_models import Command\n\n # As api_list is a class method we will never get the stripe account unless we\n # default to the owner account of the api_key. But even that is pointless as we only care about expand\n # So no need to make a call to Stripe and again do an account object sync which would make\n # no sense if this is for a Stripe Connected Account\n expand = Command.get_default_list_kwargs(\n cls, {kwargs.get(\"stripe_account\", \"acct_fake\")}, api_key\n )[0].get(\"expand\", [])\n\n # Add expand to the provided list\n if kwargs.get(\"expand\"):\n kwargs[\"expand\"].extend(expand)\n else:\n kwargs[\"expand\"] = expand\n\n # Keep only unique elements\n # Sort it to ensure the items are returned in the same order\n kwargs[\"expand\"] = sorted(list(set(kwargs[\"expand\"])))\n\n return kwargs",
"nameRange": {
"startLine": 40,
"startColumn": 8,
"endLine": 40,
"endColumn": 25
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:79",
"targetRef": "djstripe/models/base.py:40",
"sourceSnippetRange": {
"startLine": 79,
"startColumn": 21,
"endLine": 79,
"endColumn": 38
},
"snippet": "get_expand_params"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1414",
"targetRef": "djstripe/models/base.py:40",
"sourceSnippetRange": {
"startLine": 1414,
"startColumn": 21,
"endLine": 1414,
"endColumn": 38
},
"snippet": "get_expand_params"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1572",
"targetRef": "djstripe/models/base.py:40",
"sourceSnippetRange": {
"startLine": 1572,
"startColumn": 21,
"endLine": 1572,
"endColumn": 38
},
"snippet": "get_expand_params"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2229",
"targetRef": "djstripe/models/base.py:40",
"sourceSnippetRange": {
"startLine": 2229,
"startColumn": 21,
"endLine": 2229,
"endColumn": 38
},
"snippet": "get_expand_params"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2423",
"targetRef": "djstripe/models/base.py:40",
"sourceSnippetRange": {
"startLine": 2423,
"startColumn": 21,
"endLine": 2423,
"endColumn": 38
},
"snippet": "get_expand_params"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:318",
"targetRef": "djstripe/models/base.py:40",
"sourceSnippetRange": {
"startLine": 318,
"startColumn": 21,
"endLine": 318,
"endColumn": 38
},
"snippet": "get_expand_params"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:735",
"targetRef": "djstripe/models/base.py:40",
"sourceSnippetRange": {
"startLine": 735,
"startColumn": 21,
"endLine": 735,
"endColumn": 38
},
"snippet": "get_expand_params"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:764",
"targetRef": "djstripe/models/base.py:40",
"sourceSnippetRange": {
"startLine": 764,
"startColumn": 21,
"endLine": 764,
"endColumn": 38
},
"snippet": "get_expand_params"
}
],
"expressions": [
{
"type": "comment",
"ref": "djstripe/models/base.py:41",
"range": {
"startLine": 41,
"startColumn": 8,
"endLine": 41,
"endColumn": 88
},
"expression": "\"\"\"Populate `expand` kwarg in stripe api calls by updating the kwargs passed.\"\"\""
},
{
"type": "comment",
"ref": "djstripe/models/base.py:42",
"range": {
"startLine": 42,
"startColumn": 8,
"endLine": 42,
"endColumn": 40
},
"expression": "# To avoid Circular Import Error"
},
{
"type": "comment",
"ref": "djstripe/models/base.py:45",
"range": {
"startLine": 45,
"startColumn": 8,
"endLine": 45,
"endColumn": 86
},
"expression": "# As api_list is a class method we will never get the stripe account unless we"
},
{
"type": "comment",
"ref": "djstripe/models/base.py:46",
"range": {
"startLine": 46,
"startColumn": 8,
"endLine": 46,
"endColumn": 110
},
"expression": "# default to the owner account of the api_key. But even that is pointless as we only care about expand"
},
{
"type": "comment",
"ref": "djstripe/models/base.py:47",
"range": {
"startLine": 47,
"startColumn": 8,
"endLine": 47,
"endColumn": 98
},
"expression": "# So no need to make a call to Stripe and again do an account object sync which would make"
},
{
"type": "comment",
"ref": "djstripe/models/base.py:48",
"range": {
"startLine": 48,
"startColumn": 8,
"endLine": 48,
"endColumn": 60
},
"expression": "# no sense if this is for a Stripe Connected Account"
},
{
"type": "call",
"ref": "djstripe/models/base.py:49",
"range": {
"startLine": 49,
"startColumn": 17,
"endLine": 51,
"endColumn": 9
},
"name": "get_default_list_kwargs",
"expression": "Command.get_default_list_kwargs(\n cls, {kwargs.get(\"stripe_account\", \"acct_fake\")}, api_key\n )",
"definition": {
"type": "method",
"filePath": "djstripe/management/commands/djstripe_sync_models.py",
"name": "get_default_list_kwargs",
"ref": "djstripe/management/commands/djstripe_sync_models.py:231",
"definitionRange": {
"startLine": 231,
"startColumn": 4,
"endLine": 312,
"endColumn": 34
},
"language": "python",
"snippet": "def get_default_list_kwargs(model, accounts_set, api_key: str):\n \"\"\"Returns default sequence of kwargs to sync\n all Stripe Accounts\"\"\"\n expand = []\n\n try:\n # get all forward and reverse relations for given cls\n for field in model.expand_fields:\n # add expand_field on the current model\n expand.append(f\"data.{field}\")\n\n try:\n field_inst = model._meta.get_field(field)\n\n # get expand_fields on Forward FK and OneToOneField relations on the current model\n if isinstance(\n field_inst,\n (django_models.ForeignKey, django_models.OneToOneField),\n ):\n try:\n for (\n related_model_expand_field\n ) in field_inst.related_model.expand_fields:\n # add expand_field on the current model\n expand.append(\n f\"data.{field}.{related_model_expand_field}\"\n )\n\n related_model_expand_field_inst = (\n field_inst.related_model._meta.get_field(\n related_model_expand_field\n )\n )\n\n # get expand_fields on Forward FK and OneToOneField relations on the current model\n if isinstance(\n related_model_expand_field_inst,\n (\n django_models.ForeignKey,\n django_models.OneToOneField,\n ),\n ):\n try:\n # need to prepend \"field_name.\" to each of the entry in the expand_fields list\n related_model_expand_fields = map(\n lambda i: f\"data.{field_inst.name}.{related_model_expand_field}.{i}\",\n related_model_expand_field_inst.related_model.expand_fields,\n )\n\n expand = [\n *expand,\n *related_model_expand_fields,\n ]\n except AttributeError:\n continue\n except AttributeError:\n continue\n except FieldDoesNotExist:\n pass\n except AttributeError:\n pass\n\n if expand:\n default_list_kwargs = [\n {\n \"expand\": expand,\n \"stripe_account\": account,\n \"api_key\": api_key,\n }\n for account in accounts_set\n ]\n\n else:\n default_list_kwargs = [\n {\n \"stripe_account\": account,\n \"api_key\": api_key,\n }\n for account in accounts_set\n ]\n\n return default_list_kwargs",
"nameRange": {
"startLine": 231,
"startColumn": 8,
"endLine": 231,
"endColumn": 31
}
}
},
{
"type": "variable",
"ref": "djstripe/models/base.py:49",
"range": {
"startLine": 49,
"startColumn": 17,
"endLine": 49,
"endColumn": 48
},
"name": "Command",
"expression": "Command.get_default_list_kwargs",
"definition": {
"type": "class",
"filePath": "djstripe/management/commands/djstripe_sync_models.py",
"name": "Command",
"ref": "djstripe/management/commands/djstripe_sync_models.py:42",
"definitionRange": {
"startLine": 42,
"startColumn": 0,
"endLine": 528,
"endColumn": 13
},
"language": "python",
"snippet": "class Command(BaseCommand):\n \"\"\"Sync models from stripe.\"\"\"\n\n help = \"Sync models from stripe.\"\n\n def add_arguments(self, parser):\n parser.add_argument(\n \"args\",\n metavar=\"ModelName\",\n nargs=\"*\",\n help=(\n \"restricts sync to these model names (default is to sync all \"\n \"supported models)\"\n ),\n )\n # Named (optional) arguments\n parser.add_argument(\n \"--api-keys\",\n metavar=\"ApiKeys\",\n nargs=\"*\",\n type=str,\n action=\"extend\",\n help=\"Specify the api_keys you would like to perform this sync for.\",\n )\n\n def handle(self, *args, api_keys: typing.List[str], **options):\n app_label = \"djstripe\"\n app_config = apps.get_app_config(app_label)\n model_list: typing.List[models.StripeModel] = []\n\n if args:\n for model_label in args:\n try:\n model = app_config.get_model(model_label)\n except LookupError:\n raise CommandError(f\"Unknown model: {app_label}.{model_label}\")\n\n model_list.append(model)\n else:\n model_list = app_config.get_models()\n\n if api_keys is not None:\n for api_key in api_keys:\n try:\n # check to ensure the given key is in the DB\n models.APIKey.objects.get(secret=api_key)\n except models.APIKey.DoesNotExist:\n raise CommandError(f\"APIKey: {api_key} is not in the database.\")\n\n api_qs = models.APIKey.objects.filter(secret__in=api_keys)\n else:\n # get all APIKey objects in the db\n api_qs = models.APIKey.objects.all()\n\n if not api_qs.exists():\n self.stderr.write(\n \"You don't have any API Keys in the database. Did you forget to add\"\n \" them?\"\n )\n return\n\n for model in model_list:\n for api_key in api_qs:\n self.sync_model(model, api_key=api_key)\n\n def _should_sync_model(self, model):\n if not issubclass(model, StripeBaseModel):\n return False, \"not a StripeModel\"\n\n if model.stripe_class is None:\n return False, \"no stripe_class\"\n\n if not hasattr(model.stripe_class, \"list\"):\n if model in (\n models.ApplicationFeeRefund,\n models.LineItem,\n models.TransferReversal,\n models.TaxId,\n models.UsageRecordSummary,\n ):\n return True, \"\"\n return False, \"no stripe_class.list\"\n\n if model is models.UpcomingInvoice:\n return False, \"Upcoming Invoices are virtual only\"\n\n if not djstripe_settings.STRIPE_LIVE_MODE:\n if model is models.ScheduledQueryRun:\n return False, \"only available in live mode\"\n\n return True, \"\"\n\n def sync_model(self, model, api_key: str):\n model_name = model.__name__\n\n should_sync, reason = self._should_sync_model(model)\n if not should_sync:\n self.stderr.write(f\"Skipping {model}: {reason}\")\n return\n\n self.stdout.write(f\"Syncing {model_name} for key {api_key}:\")\n\n count = 0\n try:\n # todo convert get_list_kwargs into a generator to make the code memory effecient.\n for list_kwargs in self.get_list_kwargs(model, api_key=api_key.secret):\n stripe_account = list_kwargs.get(\"stripe_account\", \"\")\n\n if (\n model is models.Account\n and stripe_account\n == models.Account.get_default_account(api_key=api_key.secret).id\n ):\n # special case, since own account isn't returned by Account.api_list\n stripe_obj = models.Account.stripe_class.retrieve(\n api_key=api_key.secret,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n )\n\n djstripe_obj = model.sync_from_stripe_data(\n stripe_obj, api_key=api_key.secret\n )\n self.stdout.write(\n f\" id={djstripe_obj.id},\"\n f\" pk={djstripe_obj.pk} ({djstripe_obj} on {stripe_account} for\"\n f\" {api_key})\"\n )\n\n # syncing BankAccount and Card objects of Stripe Connected Express and Custom Accounts\n self.sync_bank_accounts_and_cards(\n djstripe_obj,\n stripe_account=stripe_account,\n api_key=api_key.secret,\n )\n count += 1\n\n try:\n for stripe_obj in model.api_list(**list_kwargs):\n # Skip model instances that throw an error\n try:\n djstripe_obj = model.sync_from_stripe_data(\n stripe_obj, api_key=api_key.secret\n )\n self.stdout.write(\n f\" id={djstripe_obj.id},\"\n f\" pk={djstripe_obj.pk} ({djstripe_obj} on\"\n f\" {stripe_account} for {api_key})\"\n )\n # syncing BankAccount and Card objects of Stripe Connected Express and Custom Accounts\n self.sync_bank_accounts_and_cards(\n djstripe_obj,\n stripe_account=stripe_account,\n api_key=api_key.secret,\n )\n count += 1\n except Exception as e:\n self.stderr.write(f\"Skipping {stripe_obj.get('id')}: {e}\")\n\n continue\n except Exception as e:\n self.stderr.write(f\"Skipping: {e}\")\n\n if count == 0:\n self.stdout.write(\" (no results)\")\n else:\n self.stdout.write(f\" Synced {count} {model_name} for {api_key}\")\n\n except Exception as e:\n self.stderr.write(str(e))\n\n @classmethod\n def get_stripe_account(cls, api_key: str, *args, **kwargs):\n \"\"\"Get set of all stripe account ids including the Platform Acccount\"\"\"\n accs_set = set()\n\n # special case, since own account isn't returned by Account.api_list\n stripe_platform_obj = models.Account.stripe_class.retrieve(\n api_key=api_key,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n )\n accs_set.add(stripe_platform_obj.id)\n\n for stripe_connected_obj in models.Account.api_list(api_key=api_key, **kwargs):\n accs_set.add(stripe_connected_obj.id)\n\n return accs_set\n\n # todo simplfy this code by spliting into 1-2 functions\n @staticmethod\n def get_default_list_kwargs(model, accounts_set, api_key: str):\n \"\"\"Returns default sequence of kwargs to sync\n all Stripe Accounts\"\"\"\n expand = []\n\n try:\n # get all forward and reverse relations for given cls\n for field in model.expand_fields:\n # add expand_field on the current model\n expand.append(f\"data.{field}\")\n\n try:\n field_inst = model._meta.get_field(field)\n\n # get expand_fields on Forward FK and OneToOneField relations on the current model\n if isinstance(\n field_inst,\n (django_models.ForeignKey, django_models.OneToOneField),\n ):\n try:\n for (\n related_model_expand_field\n ) in field_inst.related_model.expand_fields:\n # add expand_field on the current model\n expand.append(\n f\"data.{field}.{related_model_expand_field}\"\n )\n\n related_model_expand_field_inst = (\n field_inst.related_model._meta.get_field(\n related_model_expand_field\n )\n )\n\n # get expand_fields on Forward FK and OneToOneField relations on the current model\n if isinstance(\n related_model_expand_field_inst,\n (\n django_models.ForeignKey,\n django_models.OneToOneField,\n ),\n ):\n try:\n # need to prepend \"field_name.\" to each of the entry in the expand_fields list\n related_model_expand_fields = map(\n lambda i: f\"data.{field_inst.name}.{related_model_expand_field}.{i}\",\n related_model_expand_field_inst.related_model.expand_fields,\n )\n\n expand = [\n *expand,\n *related_model_expand_fields,\n ]\n except AttributeError:\n continue\n except AttributeError:\n continue\n except FieldDoesNotExist:\n pass\n except AttributeError:\n pass\n\n if expand:\n default_list_kwargs = [\n {\n \"expand\": expand,\n \"stripe_account\": account,\n \"api_key\": api_key,\n }\n for account in accounts_set\n ]\n\n else:\n default_list_kwargs = [\n {\n \"stripe_account\": account,\n \"api_key\": api_key,\n }\n for account in accounts_set\n ]\n\n return default_list_kwargs\n\n @staticmethod\n def get_list_kwargs_il(default_list_kwargs):\n \"\"\"Returns sequence of kwargs to sync Line Items for\n all Stripe Accounts\"\"\"\n\n all_list_kwargs = []\n\n for def_kwarg in default_list_kwargs:\n stripe_account = def_kwarg.get(\"stripe_account\")\n api_key = def_kwarg.get(\"api_key\")\n for stripe_invoice in models.Invoice.api_list(\n stripe_account=stripe_account, api_key=api_key\n ):\n all_list_kwargs.append({\"id\": stripe_invoice.id, **def_kwarg})\n\n return all_list_kwargs\n\n @staticmethod\n def get_list_kwargs_pm(default_list_kwargs):\n \"\"\"Returns sequence of kwargs to sync Payment Methods for\n all Stripe Accounts\"\"\"\n\n all_list_kwargs = []\n payment_method_types = enums.PaymentMethodType.__members__\n\n for def_kwarg in default_list_kwargs:\n stripe_account = def_kwarg.get(\"stripe_account\")\n api_key = def_kwarg.get(\"api_key\")\n for stripe_customer in models.Customer.api_list(\n stripe_account=stripe_account, api_key=api_key\n ):\n for type in payment_method_types:\n all_list_kwargs.append(\n {\"customer\": stripe_customer.id, \"type\": type, **def_kwarg}\n )\n\n return all_list_kwargs\n\n @staticmethod\n def get_list_kwargs_si(default_list_kwargs):\n \"\"\"Returns sequence of kwargs to sync Subscription Items for\n all Stripe Accounts\"\"\"\n\n all_list_kwargs = []\n for def_kwarg in default_list_kwargs:\n stripe_account = def_kwarg.get(\"stripe_account\")\n api_key = def_kwarg.get(\"api_key\")\n for subscription in models.Subscription.api_list(\n stripe_account=stripe_account, api_key=api_key\n ):\n all_list_kwargs.append({\"subscription\": subscription.id, **def_kwarg})\n return all_list_kwargs\n\n @staticmethod\n def get_list_kwargs_txcd(default_list_kwargs):\n \"\"\"Returns sequence of kwargs to sync Tax Codes for\n all Stripe Accounts\"\"\"\n\n # tax codes are the same for all Stripe Accounts\n return [{}]\n\n @staticmethod\n def get_list_kwargs_trr(default_list_kwargs):\n \"\"\"Returns sequence of kwargs to sync Transfer Reversals for\n all Stripe Accounts\"\"\"\n all_list_kwargs = []\n for def_kwarg in default_list_kwargs:\n stripe_account = def_kwarg.get(\"stripe_account\")\n api_key = def_kwarg.get(\"api_key\")\n for transfer in models.Transfer.api_list(\n stripe_account=stripe_account, api_key=api_key\n ):\n all_list_kwargs.append({\"id\": transfer.id, **def_kwarg})\n\n return all_list_kwargs\n\n @staticmethod\n def get_list_kwargs_fee_refund(default_list_kwargs):\n \"\"\"Returns sequence of kwargs to sync Application Fee Refunds for\n all Stripe Accounts\"\"\"\n all_list_kwargs = []\n for def_kwarg in default_list_kwargs:\n stripe_account = def_kwarg.get(\"stripe_account\")\n api_key = def_kwarg.get(\"api_key\")\n for fee in models.ApplicationFee.api_list(\n stripe_account=stripe_account, api_key=api_key\n ):\n all_list_kwargs.append({\"id\": fee.id, **def_kwarg})\n\n return all_list_kwargs\n\n @staticmethod\n def get_list_kwargs_tax_id(default_list_kwargs):\n \"\"\"Returns sequence of kwargs to sync Tax Ids for\n all Stripe Accounts\"\"\"\n all_list_kwargs = []\n for def_kwarg in default_list_kwargs:\n stripe_account = def_kwarg.get(\"stripe_account\")\n api_key = def_kwarg.get(\"api_key\")\n for customer in models.Customer.api_list(\n stripe_account=stripe_account, api_key=api_key\n ):\n all_list_kwargs.append({\"id\": customer.id, **def_kwarg})\n\n return all_list_kwargs\n\n @staticmethod\n def get_list_kwargs_sis(default_list_kwargs):\n \"\"\"Returns sequence of kwargs to sync Usage Record Summarys for\n all Stripe Accounts\"\"\"\n all_list_kwargs = []\n for def_kwarg in default_list_kwargs:\n stripe_account = def_kwarg.get(\"stripe_account\")\n api_key = def_kwarg.get(\"api_key\")\n for subscription in models.Subscription.api_list(\n stripe_account=stripe_account, api_key=api_key\n ):\n for subscription_item in models.SubscriptionItem.api_list(\n subscription=subscription.id,\n stripe_account=stripe_account,\n api_key=api_key,\n ):\n all_list_kwargs.append({\"id\": subscription_item.id, **def_kwarg})\n\n return all_list_kwargs\n\n # todo handle supoorting double + nested fields like data.invoice.subscriptions.customer etc?\n def get_list_kwargs(self, model, api_key: str):\n \"\"\"\n Returns a sequence of kwargs dicts to pass to model.api_list\n\n This allows us to sync models that require parameters to api_list\n\n :param model:\n :return: Sequence[dict]\n \"\"\"\n\n list_kwarg_handlers_dict = {\n \"LineItem\": self.get_list_kwargs_il,\n \"PaymentMethod\": self.get_list_kwargs_pm,\n \"SubscriptionItem\": self.get_list_kwargs_si,\n \"TransferReversal\": self.get_list_kwargs_trr,\n \"ApplicationFeeRefund\": self.get_list_kwargs_fee_refund,\n \"TaxCode\": self.get_list_kwargs_txcd,\n \"TaxId\": self.get_list_kwargs_tax_id,\n \"UsageRecordSummary\": self.get_list_kwargs_sis,\n }\n\n # get all Stripe Accounts for the given platform account.\n # note that we need to fetch from Stripe as we have no way of knowing that the ones in the local db are up to date\n # as this can also be the first time the user runs sync.\n accs_set = self.get_stripe_account(api_key=api_key)\n\n default_list_kwargs = self.get_default_list_kwargs(\n model, accs_set, api_key=api_key\n )\n\n handler = list_kwarg_handlers_dict.get(\n model.__name__, lambda _: default_list_kwargs\n )\n\n return handler(default_list_kwargs)\n\n def sync_bank_accounts_and_cards(self, instance, *, stripe_account, api_key):\n \"\"\"\n Syncs Bank Accounts and Cards for both customers and all external accounts\n \"\"\"\n type = getattr(instance, \"type\", None)\n kwargs = {\n \"id\": instance.id,\n \"api_key\": api_key,\n \"stripe_account\": stripe_account,\n \"stripe_version\": djstripe_settings.STRIPE_API_VERSION,\n }\n\n if type in (\"custom\", \"express\") and isinstance(instance, models.Account):\n # fetch all Card and BankAccount objects associated with the instance\n items = models.Account.stripe_class.list_external_accounts(\n **kwargs\n ).auto_paging_iter()\n\n self.start_sync(items, instance, api_key=api_key)\n elif isinstance(instance, models.Customer):\n for object in (\"card\", \"bank_account\"):\n kwargs[\"object\"] = object\n\n # fetch all Card and BankAccount objects associated with the instance\n items = models.Customer.stripe_class.list_sources(\n **kwargs\n ).auto_paging_iter()\n\n self.start_sync(items, instance, api_key=api_key)\n\n def start_sync(self, items, instance, api_key: str):\n bank_count = 0\n card_count = 0\n for item in items:\n if item.object == \"bank_account\":\n model = models.BankAccount\n bank_count += 1\n elif item.object == \"card\":\n model = models.Card\n card_count += 1\n\n item_obj = model.sync_from_stripe_data(item, api_key=api_key)\n\n self.stdout.write(\n f\"\\tSyncing {model._meta.verbose_name} ({instance}): id={item_obj.id},\"\n f\" pk={item_obj.pk}\"\n )\n\n if bank_count + card_count > 0:\n self.stdout.write(\n f\"\\tSynced {bank_count} BankAccounts and {card_count} Cards\"\n )",
"nameRange": {
"startLine": 42,
"startColumn": 6,
"endLine": 42,
"endColumn": 13
}
}
},
{
"type": "call",
"ref": "djstripe/models/base.py:50",
"range": {
"startLine": 50,
"startColumn": 18,
"endLine": 50,
"endColumn": 59
},
"name": "get",
"expression": "kwargs.get(\"stripe_account\", \"acct_fake\")",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "get",
"ref": "__base_types__:1064",
"definitionRange": {
"startLine": 1064,
"startColumn": 4,
"endLine": 1064,
"endColumn": 49
},
"language": "python",
"snippet": "def get(self, key: _KT, /) -> _VT | None: ...",
"nameRange": {
"startLine": 1064,
"startColumn": 8,
"endLine": 1064,
"endColumn": 11
}
}
},
{
"type": "comment",
"ref": "djstripe/models/base.py:53",
"range": {
"startLine": 53,
"startColumn": 8,
"endLine": 53,
"endColumn": 41
},
"expression": "# Add expand to the provided list"
},
{
"type": "comment",
"ref": "djstripe/models/base.py:59",
"range": {
"startLine": 59,
"startColumn": 8,
"endLine": 59,
"endColumn": 35
},
"expression": "# Keep only unique elements"
},
{
"type": "comment",
"ref": "djstripe/models/base.py:60",
"range": {
"startLine": 60,
"startColumn": 8,
"endLine": 60,
"endColumn": 68
},
"expression": "# Sort it to ensure the items are returned in the same order"
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "djstripe_id",
"ref": "djstripe/models/base.py:97",
"definitionRange": {
"startLine": 97,
"startColumn": 4,
"endLine": 99,
"endColumn": 5
},
"language": "python",
"snippet": "djstripe_id = models.BigAutoField(\n verbose_name=\"ID\", serialize=False, primary_key=True\n )",
"nameRange": {
"startLine": 97,
"startColumn": 4,
"endLine": 97,
"endColumn": 15
},
"references": [
{
"targetRef": "djstripe/models/base.py:97",
"sourceSnippetRange": {
"startLine": 97,
"startColumn": 0,
"endLine": 97,
"endColumn": 39
},
"sourceRef": "djstripe/models/base.py:97",
"type": "from-search",
"snippet": " djstripe_id = models.BigAutoField(\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/base.py:97",
"range": {
"startLine": 97,
"startColumn": 18,
"endLine": 99,
"endColumn": 5
},
"name": "BigAutoField",
"expression": "models.BigAutoField(\n verbose_name=\"ID\", serialize=False, primary_key=True\n )",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "BigAutoField",
"ref": "__base_types__:580",
"definitionRange": {
"startLine": 580,
"startColumn": 0,
"endLine": 608,
"endColumn": 18
},
"language": "python",
"snippet": "class BigAutoField(AutoFieldMixin, BigIntegerField[int]):\n def __new__(\n cls,\n verbose_name: str | None = ...,\n name: str | None = ...,\n max_digits: int = ...,\n decimal_places: int = ...,\n primary_key: Literal[True] = ...,\n max_length: int | None = ...,\n unique: bool = ...,\n blank: Literal[True] = ...,\n null: bool = ...,\n db_index: bool = ...,\n default: int | Callable[[], int] | None = ...,\n editable: bool = ...,\n auto_created: bool = ...,\n serialize: bool = ...,\n unique_for_date: str | None = ...,\n unique_for_month: str | None = ...,\n unique_for_year: str | None = ...,\n choices: Iterable[\n tuple[int, str] | tuple[str, Iterable[tuple[int, str]]]\n ] = ...,\n help_text: str = ...,\n db_column: str | None = ...,\n db_tablespace: str | None = ...,\n validators: Iterable[_ValidatorCallable] = ...,\n error_messages: _ErrorMessagesToOverride | None = ...,\n ) -> Self: ...",
"nameRange": {
"startLine": 580,
"startColumn": 6,
"endLine": 580,
"endColumn": 18
}
}
},
{
"type": "variable",
"ref": "djstripe/models/base.py:97",
"range": {
"startLine": 97,
"startColumn": 18,
"endLine": 97,
"endColumn": 37
},
"name": "models",
"expression": "models.BigAutoField",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/identity.py",
"name": "type",
"ref": "djstripe/models/identity.py:40",
"definitionRange": {
"startLine": 40,
"startColumn": 4,
"endLine": 40,
"endColumn": 55
},
"language": "python",
"snippet": "type = StripeEnumField(enum=enums.VerificationType)",
"nameRange": {
"startLine": 40,
"startColumn": 4,
"endLine": 40,
"endColumn": 8
},
"references": [
{
"targetRef": "djstripe/models/identity.py:40",
"sourceSnippetRange": {
"startLine": 22,
"startColumn": 0,
"endLine": 22,
"endColumn": 56
},
"sourceRef": "djstripe/models/identity.py:22",
"type": "from-search",
"snippet": " type = StripeEnumField(enum=enums.VerificationType)\n"
},
{
"targetRef": "djstripe/models/identity.py:40",
"sourceSnippetRange": {
"startLine": 40,
"startColumn": 0,
"endLine": 40,
"endColumn": 56
},
"sourceRef": "djstripe/models/identity.py:40",
"type": "from-search",
"snippet": " type = StripeEnumField(enum=enums.VerificationType)\n"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/identity.py:40",
"range": {
"startLine": 40,
"startColumn": 11,
"endLine": 40,
"endColumn": 55
},
"name": "StripeEnumField",
"expression": "StripeEnumField(enum=enums.VerificationType)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "StripeEnumField",
"ref": "djstripe/fields.py:106",
"definitionRange": {
"startLine": 106,
"startColumn": 0,
"endLine": 117,
"endColumn": 39
},
"language": "python",
"snippet": "class StripeEnumField(FieldDeconstructMixin, models.CharField):\n def __init__(self, enum, *args, **kwargs):\n self.enum = enum\n choices = enum.choices\n defaults = {\"choices\": choices, \"max_length\": 255}\n defaults.update(kwargs)\n super().__init__(*args, **defaults)\n\n def deconstruct(self):\n name, path, args, kwargs = super().deconstruct()\n kwargs[\"enum\"] = self.enum\n return name, path, args, kwargs",
"nameRange": {
"startLine": 106,
"startColumn": 6,
"endLine": 106,
"endColumn": 21
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:40",
"range": {
"startLine": 40,
"startColumn": 27,
"endLine": 40,
"endColumn": 54
},
"name": "VerificationType",
"expression": "enum=enums.VerificationType",
"definition": {
"type": "class",
"filePath": "djstripe/enums.py",
"name": "VerificationType",
"ref": "djstripe/enums.py:831",
"definitionRange": {
"startLine": 831,
"startColumn": 0,
"endLine": 837,
"endColumn": 30
},
"language": "python",
"snippet": "class VerificationType(Enum):\n \"\"\"\n https://stripe.com/docs/api/identity/verification_sessions/object#identity_verification_session_object-type\n \"\"\"\n\n document = _(\"Document\")\n id_number = _(\"ID number\")",
"nameRange": {
"startLine": 831,
"startColumn": 6,
"endLine": 831,
"endColumn": 22
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:40",
"range": {
"startLine": 40,
"startColumn": 32,
"endLine": 40,
"endColumn": 54
},
"name": "enums",
"expression": "enums.VerificationType",
"definition": {
"type": "import",
"filePath": "djstripe/enums.py",
"name": "operator",
"ref": "djstripe/enums.py:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 15
},
"language": "python",
"snippet": "import operator",
"nameRange": {
"startLine": 0,
"startColumn": 7,
"endLine": 0,
"endColumn": 15
}
}
}
]
},
{
"type": "class",
"filePath": "djstripe/models/identity.py",
"name": "VerificationSession",
"ref": "djstripe/models/identity.py:8",
"definitionRange": {
"startLine": 8,
"startColumn": 0,
"endLine": 26,
"endColumn": 24
},
"language": "python",
"snippet": "class VerificationSession(StripeModel):\n \"\"\"\n Stripe documentation: https://stripe.com/docs/api/identity/verification_sessions\n \"\"\"\n\n stripe_class = stripe.identity.VerificationSession\n\n last_error = JSONField(null=True, blank=True)\n last_verification_report = StripeForeignKey(\n \"djstripe.VerificationReport\", on_delete=models.SET_NULL, null=True, blank=True\n )\n redaction = JSONField(null=True, blank=True)\n verified_outputs = JSONField(null=True, blank=True)\n status = StripeEnumField(enum=enums.VerificationSessionStatus)\n type = StripeEnumField(enum=enums.VerificationType)\n\n # The following attributes are not stored because they are sensitive.\n url = None\n client_secret = None",
"nameRange": {
"startLine": 8,
"startColumn": 6,
"endLine": 8,
"endColumn": 25
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/event_handlers.py:218",
"targetRef": "djstripe/models/identity.py:8",
"sourceSnippetRange": {
"startLine": 218,
"startColumn": 46,
"endLine": 218,
"endColumn": 65
},
"snippet": "VerificationSession"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/__init__.py:40",
"targetRef": "djstripe/models/identity.py:8",
"sourceSnippetRange": {
"startLine": 40,
"startColumn": 42,
"endLine": 40,
"endColumn": 61
},
"snippet": "VerificationSession"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/__init__.py:92",
"targetRef": "djstripe/models/identity.py:8",
"sourceSnippetRange": {
"startLine": 92,
"startColumn": 5,
"endLine": 92,
"endColumn": 24
},
"snippet": "VerificationSession"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/models/identity.py:8",
"range": {
"startLine": 8,
"startColumn": 25,
"endLine": 8,
"endColumn": 38
},
"name": "StripeModel",
"expression": "(StripeModel)",
"definition": {
"type": "class",
"filePath": "djstripe/models/base.py",
"name": "StripeModel",
"ref": "djstripe/models/base.py:88",
"definitionRange": {
"startLine": 88,
"startColumn": 0,
"endLine": 1120,
"endColumn": 32
},
"language": "python",
"snippet": "class StripeModel(StripeBaseModel):\n # This must be defined in descendants of this model/mixin\n # e.g. Event, Charge, Customer, etc.\n expand_fields: List[str] = []\n stripe_dashboard_item_name = \"\"\n\n objects = models.Manager()\n stripe_objects = StripeModelManager()\n\n djstripe_id = models.BigAutoField(\n verbose_name=\"ID\", serialize=False, primary_key=True\n )\n id = StripeIdField(unique=True)\n\n djstripe_owner_account: Optional[StripeForeignKey] = StripeForeignKey(\n \"djstripe.Account\",\n on_delete=models.CASCADE,\n to_field=\"id\",\n null=True,\n blank=True,\n help_text=\"The Stripe Account this object belongs to.\",\n )\n\n livemode = models.BooleanField(\n null=True,\n default=None,\n blank=True,\n help_text=(\n \"Null here indicates that the livemode status is unknown or was previously\"\n \" unrecorded. Otherwise, this field indicates whether this record comes\"\n \" from Stripe test mode or live mode operation.\"\n ),\n )\n created = StripeDateTimeField(\n null=True,\n blank=True,\n help_text=\"The datetime this object was created in stripe.\",\n )\n metadata = JSONField(\n null=True,\n blank=True,\n help_text=(\n \"A set of key/value pairs that you can attach to an object. \"\n \"It can be useful for storing additional information about an object in \"\n \"a structured format.\"\n ),\n )\n description = models.TextField(\n null=True, blank=True, help_text=\"A description of this object.\"\n )\n\n class Meta(StripeBaseModel.Meta):\n abstract = True\n get_latest_by = \"created\"\n\n def _get_base_stripe_dashboard_url(self):\n owner_path_prefix = (\n (self.djstripe_owner_account.id + \"/\")\n if self.djstripe_owner_account\n else \"\"\n )\n suffix = \"test/\" if not self.livemode else \"\"\n return f\"https://dashboard.stripe.com/{owner_path_prefix}{suffix}\"\n\n def get_stripe_dashboard_url(self) -> str:\n \"\"\"Get the stripe dashboard url for this object.\"\"\"\n if not self.stripe_dashboard_item_name or not self.id:\n return \"\"\n else:\n base_url = self._get_base_stripe_dashboard_url()\n item = self.stripe_dashboard_item_name\n return f\"{base_url}{item}/{self.id}\"\n\n @property\n def default_api_key(self) -> str:\n # If the class is abstract (StripeModel), fall back to default key.\n if not self._meta.abstract:\n if self.djstripe_owner_account:\n return self.djstripe_owner_account.get_default_api_key(self.livemode)\n return djstripe_settings.get_default_api_key(self.livemode)\n\n def _get_stripe_account_id(self, api_key=None) -> Optional[str]:\n \"\"\"\n Call the stripe API's retrieve operation for this model.\n\n :param api_key: The api key to use for this request. \\\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n \"\"\"\n from djstripe.models import Account\n\n api_key = api_key or self.default_api_key\n\n try:\n djstripe_owner_account = self.djstripe_owner_account\n if djstripe_owner_account is not None:\n return djstripe_owner_account.id\n except (AttributeError, KeyError, ValueError):\n pass\n\n # Get reverse foreign key relations to Account in case we need to\n # retrieve ourselves using that Account ID.\n reverse_account_relations = (\n field\n for field in self._meta.get_fields(include_parents=True)\n if field.is_relation\n and field.one_to_many\n and field.related_model is Account\n )\n\n # Handle case where we have a reverse relation to Account and should pass\n # that account ID to the retrieve call.\n for field in reverse_account_relations:\n # Grab the related object, using the first one we find.\n reverse_lookup_attr = field.get_accessor_name()\n try:\n account = getattr(self, reverse_lookup_attr).first()\n except ValueError:\n if isinstance(self, Account):\n # return the id if self is the Account model itself.\n return self.id\n else:\n if account is not None:\n return account.id\n\n return None\n\n def api_retrieve(self, api_key=None, stripe_account=None):\n \"\"\"\n Call the stripe API's retrieve operation for this model.\n\n :param api_key: The api key to use for this request. \\\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n \"\"\"\n api_key = api_key or self.default_api_key\n\n # Prefer passed in stripe_account if set.\n if not stripe_account:\n stripe_account = self._get_stripe_account_id(api_key)\n\n return self.stripe_class.retrieve(\n id=self.id,\n api_key=api_key,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n expand=self.expand_fields,\n stripe_account=stripe_account,\n )\n\n @classmethod\n def _api_create(cls, api_key=djstripe_settings.STRIPE_SECRET_KEY, **kwargs):\n \"\"\"\n Call the stripe API's create operation for this model.\n\n :param api_key: The api key to use for this request. \\\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n \"\"\"\n\n return cls.stripe_class.create(\n api_key=api_key,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n **kwargs,\n )\n\n def _api_delete(self, api_key=None, stripe_account=None, **kwargs):\n \"\"\"\n Call the stripe API's delete operation for this model\n\n :param api_key: The api key to use for this request. \\\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n \"\"\"\n api_key = api_key or self.default_api_key\n\n # Prefer passed in stripe_account if set.\n if not stripe_account:\n stripe_account = self._get_stripe_account_id(api_key)\n\n return self.stripe_class.delete(\n self.id,\n api_key=api_key,\n stripe_account=stripe_account,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n **kwargs,\n )\n\n def _api_update(self, api_key=None, stripe_account=None, **kwargs):\n \"\"\"\n Call the stripe API's modify operation for this model\n\n :param api_key: The api key to use for this request.\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n \"\"\"\n api_key = api_key or self.default_api_key\n\n # Prefer passed in stripe_account if set.\n if not stripe_account:\n stripe_account = self._get_stripe_account_id(api_key)\n\n return self.stripe_class.modify(\n self.id,\n api_key=api_key,\n stripe_account=stripe_account,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n **kwargs,\n )\n\n @classmethod\n def _manipulate_stripe_object_hook(cls, data):\n \"\"\"\n Gets called by this object's stripe object conversion method just before\n conversion.\n Use this to populate custom fields in a StripeModel from stripe data.\n \"\"\"\n return data\n\n @classmethod\n def _find_owner_account(cls, data, api_key=djstripe_settings.STRIPE_SECRET_KEY):\n \"\"\"\n Fetches the Stripe Account (djstripe_owner_account model field)\n linked to the class, cls.\n Tries to retreive using the Stripe_account if given.\n Otherwise uses the api_key.\n \"\"\"\n from .account import Account\n\n # try to fetch by stripe_account. Also takes care of Stripe Connected Accounts\n if data:\n # case of Webhook Event Trigger\n if data.get(\"object\") == \"event\":\n # if account key exists and has a not null value\n stripe_account_id = get_id_from_stripe_data(data.get(\"account\"))\n if stripe_account_id:\n return Account._get_or_retrieve(\n id=stripe_account_id, api_key=api_key\n )\n\n else:\n stripe_account = getattr(data, \"stripe_account\", None)\n stripe_account_id = get_id_from_stripe_data(stripe_account)\n if stripe_account_id:\n return Account._get_or_retrieve(\n id=stripe_account_id, api_key=api_key\n )\n\n # try to fetch by the given api_key.\n return Account.get_or_retrieve_for_api_key(api_key)\n\n @classmethod\n def _stripe_object_to_record(\n cls,\n data: dict,\n current_ids=None,\n pending_relations: list = None,\n stripe_account: str = None,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n ) -> Dict:\n \"\"\"\n This takes an object, as it is formatted in Stripe's current API for our object\n type. In return, it provides a dict. The dict can be used to create a record or\n to update a record\n\n This function takes care of mapping from one field name to another, converting\n from cents to dollars, converting timestamps, and eliminating unused fields\n (so that an objects.create() call would not fail).\n\n :param data: the object, as sent by Stripe. Parsed from JSON, into a dict\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n :param pending_relations: list of tuples of relations to be attached post-save\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :return: All the members from the input, translated, mutated, etc\n \"\"\"\n from .webhooks import WebhookEndpoint\n\n manipulated_data = cls._manipulate_stripe_object_hook(data)\n if not cls.is_valid_object(manipulated_data):\n raise ValueError(\n \"Trying to fit a %r into %r. Aborting.\"\n % (manipulated_data.get(\"object\", \"\"), cls.__name__)\n )\n\n # By default we put the raw stripe data in the stripe_data json field\n result = {\"stripe_data\": data}\n\n if current_ids is None:\n current_ids = set()\n\n # Iterate over all the fields that we know are related to Stripe,\n # let each field work its own magic\n ignore_fields = [\n \"date_purged\",\n \"subscriber\",\n \"stripe_data\",\n ] # XXX: Customer hack\n\n # get all forward and reverse relations for given cls\n for field in cls._meta.get_fields():\n if field.name.startswith(\"djstripe_\") or field.name in ignore_fields:\n continue\n\n # todo add support reverse ManyToManyField sync\n if isinstance(\n field, (models.ManyToManyRel, models.ManyToOneRel)\n ) and not isinstance(field, models.OneToOneRel):\n # We don't currently support syncing from\n # reverse side of Many relationship\n continue\n\n # todo for ManyToManyField one would also need to handle the case of an intermediate model being used\n # todo add support ManyToManyField sync\n if field.many_to_many:\n # We don't currently support syncing ManyToManyField\n continue\n\n # will work for Forward FK and OneToOneField relations and reverse OneToOneField relations\n if isinstance(field, (models.ForeignKey, models.OneToOneRel)):\n field_data, skip, is_nulled = cls._stripe_object_field_to_foreign_key(\n field=field,\n manipulated_data=manipulated_data,\n current_ids=current_ids,\n pending_relations=pending_relations,\n stripe_account=stripe_account,\n api_key=api_key,\n )\n\n if skip and not is_nulled:\n continue\n else:\n if hasattr(field, \"stripe_to_db\"):\n field_data = field.stripe_to_db(manipulated_data)\n else:\n field_data = manipulated_data.get(field.name)\n\n if (\n isinstance(field, (models.CharField, models.TextField))\n and field_data is None\n ):\n # do not add empty secret field for WebhookEndpoint model\n # as stripe does not return the secret except for the CREATE call\n if cls is WebhookEndpoint and field.name == \"secret\":\n continue\n else:\n # TODO - this applies to StripeEnumField as well, since it\n # sub-classes CharField, is that intentional?\n field_data = \"\"\n\n result[field.name] = field_data\n\n # For all objects other than the account object itself, get the API key\n # attached to the request, and get the matching Account for that key.\n owner_account = cls._find_owner_account(data, api_key=api_key)\n if owner_account:\n result[\"djstripe_owner_account\"] = owner_account\n\n return result\n\n @classmethod\n def _stripe_object_field_to_foreign_key(\n cls,\n field,\n manipulated_data,\n current_ids=None,\n pending_relations=None,\n stripe_account=None,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n ):\n \"\"\"\n This converts a stripe API field to the dj stripe object it references,\n so that foreign keys can be connected up automatically.\n\n :param field:\n :type field: models.ForeignKey\n :param manipulated_data:\n :type manipulated_data: dict\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n :param pending_relations: list of tuples of relations to be attached post-save\n :type pending_relations: list\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n :return:\n \"\"\"\n from djstripe.models import DjstripePaymentMethod\n\n field_data = None\n field_name = field.name\n refetch = False\n skip = False\n # a flag to indicate if the given field is null upstream on Stripe\n is_nulled = False\n\n if current_ids is None:\n current_ids = set()\n\n if issubclass(field.related_model, (StripeModel, DjstripePaymentMethod)):\n if field_name in manipulated_data:\n raw_field_data = manipulated_data.get(field_name)\n\n # field's value is None. Skip syncing but set as None.\n # Otherwise nulled FKs sync gets skipped.\n if not raw_field_data:\n is_nulled = True\n skip = True\n\n else:\n # field does not exist in manipulated_data dict. Skip Syncing\n skip = True\n raw_field_data = None\n\n id_ = get_id_from_stripe_data(raw_field_data)\n\n if id_ == raw_field_data:\n # A field like {\"subscription\": \"sub_6lsC8pt7IcFpjA\", ...}\n refetch = True\n else:\n # A field like {\"subscription\": {\"id\": sub_6lsC8pt7IcFpjA\", ...}}\n pass\n\n if id_ in current_ids:\n # this object is currently being fetched, don't try to fetch again,\n # to avoid recursion instead, record the relation that should be\n # created once \"object_id\" object exists\n if pending_relations is not None:\n object_id = manipulated_data[\"id\"]\n pending_relations.append((object_id, field, id_))\n skip = True\n\n # sync only if field exists and is not null\n if not skip and not is_nulled:\n # add the id of the current object to the list\n # of ids being processed.\n # This will avoid infinite recursive syncs in case a relatedmodel\n # requests the same object\n current_ids.add(id_)\n\n try:\n (\n field_data,\n _,\n ) = field.related_model._get_or_create_from_stripe_object(\n manipulated_data,\n field_name,\n refetch=refetch,\n current_ids=current_ids,\n pending_relations=pending_relations,\n stripe_account=stripe_account,\n api_key=api_key,\n )\n except ImpossibleAPIRequest:\n # Found to happen in the following situation:\n # Customer has a `default_source` set to a `card_` object,\n # and neither the Customer nor the Card are present in db.\n # This skip is a hack, but it will prevent a crash.\n skip = True\n\n # Remove the id of the current object from the list\n # after it has been created or retrieved\n current_ids.remove(id_)\n\n else:\n # eg PaymentMethod, handled in hooks\n skip = True\n\n return field_data, skip, is_nulled\n\n @classmethod\n def is_valid_object(cls, data):\n \"\"\"\n Returns whether the data is a valid object for the class\n \"\"\"\n # .OBJECT_NAME will not exist on the base type itself\n object_name: str = getattr(cls.stripe_class, \"OBJECT_NAME\", \"\")\n if not object_name:\n return False\n return data and data.get(\"object\") == object_name\n\n def _attach_objects_hook(\n self, cls, data, api_key=djstripe_settings.STRIPE_SECRET_KEY, current_ids=None\n ):\n \"\"\"\n Gets called by this object's create and sync methods just before save.\n Use this to populate fields before the model is saved.\n\n :param cls: The target class for the instantiated object.\n :param data: The data dictionary received from the Stripe API.\n :type data: dict\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n \"\"\"\n\n pass\n\n def _attach_objects_post_save_hook(\n self,\n cls,\n data,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n pending_relations=None,\n ):\n \"\"\"\n Gets called by this object's create and sync methods just after save.\n Use this to populate fields after the model is saved.\n\n :param cls: The target class for the instantiated object.\n :param data: The data dictionary received from the Stripe API.\n :type data: dict\n \"\"\"\n\n unprocessed_pending_relations = []\n if pending_relations is not None:\n for post_save_relation in pending_relations:\n object_id, field, id_ = post_save_relation\n\n if self.id == id_:\n # the target instance now exists\n target = field.model.objects.get(id=object_id)\n setattr(target, field.name, self)\n if isinstance(field, models.OneToOneRel):\n # this is a reverse relationship, so the relation exists on self\n self.save()\n else:\n # this is a forward relation on the target,\n # so we need to save it\n target.save()\n\n # reload so that indirect relations back to this object\n # eg self.charge.invoice = self are set\n # TODO - reverse the field reference here to avoid hitting the DB?\n self.refresh_from_db()\n else:\n unprocessed_pending_relations.append(post_save_relation)\n\n if len(pending_relations) != len(unprocessed_pending_relations):\n # replace in place so passed in list is updated in calling method\n pending_relations[:] = unprocessed_pending_relations\n\n @classmethod\n def _create_from_stripe_object(\n cls,\n data,\n current_ids=None,\n pending_relations=None,\n save=True,\n stripe_account=None,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n ):\n \"\"\"\n Instantiates a model instance using the provided data object received\n from Stripe, and saves it to the database if specified.\n\n :param data: The data dictionary received from the Stripe API.\n :type data: dict\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n :param pending_relations: list of tuples of relations to be attached post-save\n :type pending_relations: list\n :param save: If True, the object is saved after instantiation.\n :type save: bool\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n :returns: The instantiated object.\n \"\"\"\n stripe_data = cls._stripe_object_to_record(\n data,\n current_ids=current_ids,\n pending_relations=pending_relations,\n stripe_account=stripe_account,\n api_key=api_key,\n )\n try:\n id_ = get_id_from_stripe_data(stripe_data)\n if id_ is not None:\n instance = cls.stripe_objects.get(id=id_)\n else:\n # Raise error on purpose to resume the _create_from_stripe_object flow\n raise cls.DoesNotExist\n\n except cls.DoesNotExist:\n # try to create iff instance doesn't already exist in the DB\n # TODO dictionary unpacking will not work if cls has any ManyToManyField\n instance = cls(**stripe_data)\n\n instance._attach_objects_hook(\n cls, data, api_key=api_key, current_ids=current_ids\n )\n\n if save:\n instance.save()\n\n instance._attach_objects_post_save_hook(\n cls, data, api_key=api_key, pending_relations=pending_relations\n )\n\n return instance\n\n @classmethod\n def _get_or_create_from_stripe_object(\n cls,\n data,\n field_name=\"id\",\n refetch=True,\n current_ids=None,\n pending_relations=None,\n save=True,\n stripe_account=None,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n ):\n \"\"\"\n\n :param data:\n :param field_name:\n :param refetch:\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n :param pending_relations: list of tuples of relations to be attached post-save\n :type pending_relations: list\n :param save:\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n :return:\n :rtype: cls, bool\n \"\"\"\n field = data.get(field_name)\n is_nested_data = field_name != \"id\"\n should_expand = False\n if not stripe_account and isinstance(data, StripeObject):\n stripe_account = data.stripe_account\n if pending_relations is None:\n pending_relations = []\n\n id_ = get_id_from_stripe_data(field)\n\n if not field:\n # An empty field - We need to return nothing here because there is\n # no way of knowing what needs to be fetched!\n raise RuntimeError(\n f\"dj-stripe encountered an empty field {cls.__name__}.{field_name} =\"\n f\" {field}\"\n )\n elif id_ == field:\n # A field like {\"subscription\": \"sub_6lsC8pt7IcFpjA\", ...}\n # We'll have to expand if the field is not \"id\" (= is nested)\n should_expand = is_nested_data\n else:\n # A field like {\"subscription\": {\"id\": sub_6lsC8pt7IcFpjA\", ...}}\n data = field\n\n try:\n return cls.stripe_objects.get(id=id_), False\n except cls.DoesNotExist:\n if is_nested_data and refetch:\n # This is what `data` usually looks like:\n # {\"id\": \"cus_XXXX\", \"default_source\": \"card_XXXX\"}\n # Leaving the default field_name (\"id\") will get_or_create the customer.\n # If field_name=\"default_source\", we get_or_create the card instead.\n cls_instance = cls(id=id_)\n try:\n data = cls_instance.api_retrieve(\n stripe_account=stripe_account, api_key=api_key\n )\n except InvalidRequestError as e:\n if \"a similar object exists in\" in str(e):\n # HACK around a Stripe bug.\n # When a File is retrieved from the Account object,\n # a mismatch between live and test mode is possible depending\n # on whether the file (usually the logo) was uploaded in live\n # or test. Reported to Stripe in August 2020.\n # Context: https://github.com/dj-stripe/dj-stripe/issues/830\n pass\n elif \"No such PaymentMethod:\" in str(e):\n # payment methods (card_… etc) can be irretrievably deleted,\n # but still present during sync. For example, if a refund is\n # issued on a charge whose payment method has been deleted.\n return None, False\n elif \"Invalid subscription_item id\" in str(e):\n # subscription items can be irretrievably deleted but still\n # be present during sync. For example, if a line item of type subscription is\n # removed from the subscription, the invoice generated for that billing period\n # will still contain the deleted subscription_item.\n return None, False\n else:\n raise\n should_expand = False\n\n # The next thing to happen will be the \"create from stripe object\" call.\n # At this point, if we don't have data to start with (field is a str),\n # *and* we didn't refetch by id, then `should_expand` is True and we\n # don't have the data to actually create the object.\n # If this happens when syncing Stripe data, it's a djstripe bug. Report it!\n if should_expand:\n raise ValueError(f\"No data to create {cls.__name__} from {field_name}\")\n\n try:\n # We wrap the `_create_from_stripe_object` in a transaction to\n # avoid TransactionManagementError on subsequent queries in case\n # of the IntegrityError catch below. See PR #903\n with transaction.atomic():\n return (\n cls._create_from_stripe_object(\n data,\n current_ids=current_ids,\n pending_relations=pending_relations,\n save=save,\n stripe_account=stripe_account,\n api_key=api_key,\n ),\n True,\n )\n except IntegrityError:\n # Handle the race condition that something else created the object\n # after the `get` and before `_create_from_stripe_object`.\n # This is common during webhook handling, since Stripe sends\n # multiple webhook events simultaneously,\n # each of which will cause recursive syncs. See issue #429\n return cls.stripe_objects.get(id=id_), False\n\n @classmethod\n def _stripe_object_to_customer(\n cls,\n target_cls,\n data,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n current_ids=None,\n ):\n \"\"\"\n Search the given manager for the Customer matching this object's\n ``customer`` field.\n :param target_cls: The target class\n :type target_cls: Customer\n :param data: stripe object\n :type data: dict\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n \"\"\"\n\n if \"customer\" in data and data[\"customer\"]:\n return target_cls._get_or_create_from_stripe_object(\n data, \"customer\", current_ids=current_ids, api_key=api_key\n )[0]\n\n @classmethod\n def _stripe_object_to_default_tax_rates(\n cls, target_cls, data, api_key=djstripe_settings.STRIPE_SECRET_KEY\n ):\n \"\"\"\n Retrieves TaxRates for a Subscription or Invoice\n :param target_cls:\n :param data:\n :param instance:\n :type instance: Union[djstripe.models.Invoice, djstripe.models.Subscription]\n :return:\n \"\"\"\n tax_rates = []\n\n for tax_rate_data in data.get(\"default_tax_rates\", []):\n tax_rate, _ = target_cls._get_or_create_from_stripe_object(\n tax_rate_data, refetch=False, api_key=api_key\n )\n tax_rates.append(tax_rate)\n\n return tax_rates\n\n @classmethod\n def _stripe_object_to_tax_rates(\n cls, target_cls, data, api_key=djstripe_settings.STRIPE_SECRET_KEY\n ):\n \"\"\"\n Retrieves TaxRates for a SubscriptionItem or InvoiceItem\n :param target_cls:\n :param data:\n :return:\n \"\"\"\n tax_rates = []\n\n for tax_rate_data in data.get(\"tax_rates\", []):\n tax_rate, _ = target_cls._get_or_create_from_stripe_object(\n tax_rate_data, refetch=False, api_key=api_key\n )\n tax_rates.append(tax_rate)\n\n return tax_rates\n\n @classmethod\n def _stripe_object_set_total_tax_amounts(\n cls, target_cls, data, instance, api_key=djstripe_settings.STRIPE_SECRET_KEY\n ):\n \"\"\"\n Set total tax amounts on Invoice instance\n :param target_cls:\n :param data:\n :param instance:\n :type instance: djstripe.models.Invoice\n :return:\n \"\"\"\n from .billing import TaxRate\n\n pks = []\n\n for tax_amount_data in data.get(\"total_tax_amounts\", []):\n tax_rate_data = tax_amount_data[\"tax_rate\"]\n if isinstance(tax_rate_data, str):\n tax_rate_data = {\"tax_rate\": tax_rate_data}\n\n tax_rate, _ = TaxRate._get_or_create_from_stripe_object(\n tax_rate_data,\n field_name=\"tax_rate\",\n refetch=True,\n api_key=api_key,\n )\n tax_amount, _ = target_cls.objects.update_or_create(\n invoice=instance,\n tax_rate=tax_rate,\n defaults={\n \"amount\": tax_amount_data[\"amount\"],\n \"inclusive\": tax_amount_data[\"inclusive\"],\n },\n )\n\n pks.append(tax_amount.pk)\n\n instance.total_tax_amounts.exclude(pk__in=pks).delete()\n\n @classmethod\n def _stripe_object_to_line_items(\n cls, target_cls, data, invoice, api_key=djstripe_settings.STRIPE_SECRET_KEY\n ):\n \"\"\"\n Retrieves LineItems for an invoice.\n\n If the line item doesn't exist already then it is created.\n\n If the invoice is an upcoming invoice that doesn't persist to the\n database (i.e. ephemeral) then the line items are also not saved.\n\n :param target_cls: The target class to instantiate per line item.\n :type target_cls: Type[djstripe.models.LineItem]\n :param data: The data dictionary received from the Stripe API.\n :type data: dict\n :param invoice: The invoice object that should hold the line items.\n :type invoice: ``djstripe.models.Invoice``\n \"\"\"\n lines = data.get(\"lines\")\n if not lines:\n return []\n\n lineitems = []\n for line in lines.auto_paging_iter():\n if invoice.id:\n save = True\n line.setdefault(\"invoice\", invoice.id)\n\n else:\n # Don't save invoice items for ephemeral invoices\n save = False\n\n line.setdefault(\"customer\", invoice.customer.id)\n line.setdefault(\"date\", int(dateformat.format(invoice.created, \"U\")))\n\n item, _ = target_cls._get_or_create_from_stripe_object(\n line, refetch=False, save=save, api_key=api_key\n )\n lineitems.append(item)\n\n return lineitems\n\n @classmethod\n def _stripe_object_to_subscription_items(\n cls, target_cls, data, subscription, api_key=djstripe_settings.STRIPE_SECRET_KEY\n ):\n \"\"\"\n Retrieves SubscriptionItems for a subscription.\n\n If the subscription item doesn't exist already then it is created.\n\n :param target_cls: The target class to instantiate per invoice item.\n :type target_cls: Type[djstripe.models.SubscriptionItem]\n :param data: The data dictionary received from the Stripe API.\n :type data: dict\n :param subscription: The subscription object that should hold the items.\n :type subscription: djstripe.models.Subscription\n \"\"\"\n\n items = data.get(\"items\")\n if not items:\n subscription.items.delete()\n return []\n\n pks = []\n subscriptionitems = []\n for item_data in items.auto_paging_iter():\n item, _ = target_cls._get_or_create_from_stripe_object(\n item_data, refetch=False, api_key=api_key\n )\n\n # sync the SubscriptionItem\n target_cls.sync_from_stripe_data(item_data, api_key=api_key)\n\n pks.append(item.pk)\n subscriptionitems.append(item)\n subscription.items.exclude(pk__in=pks).delete()\n\n return subscriptionitems\n\n @classmethod\n def _stripe_object_to_refunds(\n cls, target_cls, data, charge, api_key=djstripe_settings.STRIPE_SECRET_KEY\n ):\n \"\"\"\n Retrieves Refunds for a charge\n :param target_cls: The target class to instantiate per refund\n :type target_cls: Type[djstripe.models.Refund]\n :param data: The data dictionary received from the Stripe API.\n :type data: dict\n :param charge: The charge object that refunds are for.\n :type charge: djstripe.models.Refund\n :return:\n \"\"\"\n stripe_refunds = convert_to_stripe_object(data.get(\"refunds\"))\n\n if not stripe_refunds:\n return []\n\n refund_objs = []\n stripe_account = getattr(stripe_refunds, \"stripe_account\", None)\n for refund_data in stripe_refunds.auto_paging_iter():\n item, _ = target_cls._get_or_create_from_stripe_object(\n refund_data,\n refetch=False,\n api_key=api_key,\n stripe_account=stripe_account,\n )\n refund_objs.append(item)\n\n return refund_objs\n\n @classmethod\n def sync_from_stripe_data(\n cls,\n data,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n ):\n \"\"\"\n Syncs this object from the stripe data provided.\n\n Foreign keys will also be retrieved and synced recursively.\n\n :param data: stripe object\n :type data: dict\n :rtype: cls\n \"\"\"\n current_ids = set()\n data_id = data.get(\"id\")\n stripe_account = getattr(data, \"stripe_account\", None)\n\n if data_id:\n # stop nested objects from trying to retrieve this object before\n # initial sync is complete\n current_ids.add(data_id)\n\n instance, created = cls._get_or_create_from_stripe_object(\n data,\n current_ids=current_ids,\n stripe_account=stripe_account,\n api_key=api_key,\n )\n\n if not created:\n record_data = cls._stripe_object_to_record(\n data, api_key=api_key, stripe_account=stripe_account\n )\n for attr, value in record_data.items():\n setattr(instance, attr, value)\n instance._attach_objects_hook(\n cls, data, api_key=api_key, current_ids=current_ids\n )\n instance.save()\n instance._attach_objects_post_save_hook(cls, data, api_key=api_key)\n\n for field in instance._meta.concrete_fields:\n if isinstance(field, (StripePercentField, models.UUIDField)):\n # get rid of cached values\n delattr(instance, field.name)\n\n return instance\n\n @classmethod\n def _get_or_retrieve(cls, id, stripe_account=None, **kwargs):\n \"\"\"\n Retrieve object from the db, if it exists. If it doesn't, query Stripe to fetch\n the object and sync with the db.\n \"\"\"\n try:\n return cls.objects.get(id=id)\n except cls.DoesNotExist:\n pass\n\n if stripe_account:\n kwargs[\"stripe_account\"] = str(stripe_account)\n\n # If no API key is specified, use the default one for the specified livemode\n # (or if no livemode is specified, the default one altogether)\n kwargs.setdefault(\n \"api_key\",\n djstripe_settings.get_default_api_key(livemode=kwargs.get(\"livemode\")),\n )\n data = cls.stripe_class.retrieve(\n id=id, stripe_version=djstripe_settings.STRIPE_API_VERSION, **kwargs\n )\n instance = cls.sync_from_stripe_data(data, api_key=kwargs.get(\"api_key\"))\n return instance\n\n def __str__(self):\n return f\"<id={self.id}>\"",
"nameRange": {
"startLine": 88,
"startColumn": 6,
"endLine": 88,
"endColumn": 17
}
}
},
{
"type": "comment",
"ref": "djstripe/models/identity.py:9",
"range": {
"startLine": 9,
"startColumn": 4,
"endLine": 11,
"endColumn": 7
},
"expression": "\"\"\"\n Stripe documentation: https://stripe.com/docs/api/identity/verification_sessions\n \"\"\""
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:13",
"range": {
"startLine": 13,
"startColumn": 19,
"endLine": 13,
"endColumn": 34
},
"name": "stripe",
"expression": "stripe.identity",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "Incomplete",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 32
},
"language": "python",
"snippet": "from _typeshed import Incomplete",
"nameRange": {
"startLine": 0,
"startColumn": 22,
"endLine": 0,
"endColumn": 32
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:13",
"range": {
"startLine": 13,
"startColumn": 4,
"endLine": 13,
"endColumn": 54
},
"name": "VerificationSession",
"expression": "stripe_class = stripe.identity.VerificationSession",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "VerificationSession",
"ref": "__base_types__:7",
"definitionRange": {
"startLine": 7,
"startColumn": 0,
"endLine": 10,
"endColumn": 71
},
"language": "python",
"snippet": "class VerificationSession(CreateableAPIResource, ListableAPIResource, UpdateableAPIResource):\n OBJECT_NAME: str\n def cancel(self, idempotency_key: str | None = None, **params): ...\n def redact(self, idempotency_key: str | None = None, **params): ...",
"nameRange": {
"startLine": 7,
"startColumn": 6,
"endLine": 7,
"endColumn": 25
}
}
},
{
"type": "call",
"ref": "djstripe/models/identity.py:15",
"range": {
"startLine": 15,
"startColumn": 17,
"endLine": 15,
"endColumn": 49
},
"name": "JSONField",
"expression": "JSONField(null=True, blank=True)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "JSONField",
"ref": "djstripe/fields.py:149",
"definitionRange": {
"startLine": 149,
"startColumn": 0,
"endLine": 152,
"endColumn": 8
},
"language": "python",
"snippet": "class JSONField(FieldDeconstructMixin, BaseJSONField):\n \"\"\"A field used to define a JSONField value according to djstripe logic.\"\"\"\n\n pass",
"nameRange": {
"startLine": 149,
"startColumn": 6,
"endLine": 149,
"endColumn": 15
}
}
},
{
"type": "call",
"ref": "djstripe/models/identity.py:16",
"range": {
"startLine": 16,
"startColumn": 31,
"endLine": 18,
"endColumn": 5
},
"name": "StripeForeignKey",
"expression": "StripeForeignKey(\n \"djstripe.VerificationReport\", on_delete=models.SET_NULL, null=True, blank=True\n )",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "StripeForeignKey",
"ref": "djstripe/fields.py:31",
"definitionRange": {
"startLine": 31,
"startColumn": 0,
"endLine": 32,
"endColumn": 8
},
"language": "python",
"snippet": "class StripeForeignKey(models.ForeignKey):\n pass",
"nameRange": {
"startLine": 31,
"startColumn": 6,
"endLine": 31,
"endColumn": 22
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:17",
"range": {
"startLine": 17,
"startColumn": 39,
"endLine": 17,
"endColumn": 64
},
"name": "SET_NULL",
"expression": "on_delete=models.SET_NULL",
"definition": {
"type": "function",
"filePath": "__base_types__",
"name": "SET_NULL",
"ref": "__base_types__:14",
"definitionRange": {
"startLine": 14,
"startColumn": 0,
"endLine": 19,
"endColumn": 14
},
"language": "python",
"snippet": "def SET_NULL(\n collector: Collector,\n field: Field[Any, Any],\n sub_objs: Sequence[Model],\n using: str,\n) -> None: ...",
"nameRange": {
"startLine": 14,
"startColumn": 4,
"endLine": 14,
"endColumn": 12
}
}
},
{
"type": "call",
"ref": "djstripe/models/identity.py:21",
"range": {
"startLine": 21,
"startColumn": 13,
"endLine": 21,
"endColumn": 66
},
"name": "StripeEnumField",
"expression": "StripeEnumField(enum=enums.VerificationSessionStatus)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "StripeEnumField",
"ref": "djstripe/fields.py:106",
"definitionRange": {
"startLine": 106,
"startColumn": 0,
"endLine": 117,
"endColumn": 39
},
"language": "python",
"snippet": "class StripeEnumField(FieldDeconstructMixin, models.CharField):\n def __init__(self, enum, *args, **kwargs):\n self.enum = enum\n choices = enum.choices\n defaults = {\"choices\": choices, \"max_length\": 255}\n defaults.update(kwargs)\n super().__init__(*args, **defaults)\n\n def deconstruct(self):\n name, path, args, kwargs = super().deconstruct()\n kwargs[\"enum\"] = self.enum\n return name, path, args, kwargs",
"nameRange": {
"startLine": 106,
"startColumn": 6,
"endLine": 106,
"endColumn": 21
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:21",
"range": {
"startLine": 21,
"startColumn": 29,
"endLine": 21,
"endColumn": 65
},
"name": "VerificationSessionStatus",
"expression": "enum=enums.VerificationSessionStatus",
"definition": {
"type": "class",
"filePath": "djstripe/enums.py",
"name": "VerificationSessionStatus",
"ref": "djstripe/enums.py:820",
"definitionRange": {
"startLine": 820,
"startColumn": 0,
"endLine": 828,
"endColumn": 28
},
"language": "python",
"snippet": "class VerificationSessionStatus(Enum):\n \"\"\"\n https://stripe.com/docs/api/identity/verification_sessions/object#identity_verification_session_object-status\n \"\"\"\n\n requires_input = _(\"Requires input\")\n processing = _(\"Processing\")\n verified = _(\"Verified\")\n canceled = _(\"Canceled\")",
"nameRange": {
"startLine": 820,
"startColumn": 6,
"endLine": 820,
"endColumn": 31
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:21",
"range": {
"startLine": 21,
"startColumn": 34,
"endLine": 21,
"endColumn": 65
},
"name": "enums",
"expression": "enums.VerificationSessionStatus",
"definition": {
"type": "import",
"filePath": "djstripe/enums.py",
"name": "operator",
"ref": "djstripe/enums.py:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 15
},
"language": "python",
"snippet": "import operator",
"nameRange": {
"startLine": 0,
"startColumn": 7,
"endLine": 0,
"endColumn": 15
}
}
},
{
"type": "variable",
"ref": "djstripe/models/identity.py:22",
"range": {
"startLine": 22,
"startColumn": 27,
"endLine": 22,
"endColumn": 54
},
"name": "VerificationType",
"expression": "enum=enums.VerificationType",
"definition": {
"type": "class",
"filePath": "djstripe/enums.py",
"name": "VerificationType",
"ref": "djstripe/enums.py:831",
"definitionRange": {
"startLine": 831,
"startColumn": 0,
"endLine": 837,
"endColumn": 30
},
"language": "python",
"snippet": "class VerificationType(Enum):\n \"\"\"\n https://stripe.com/docs/api/identity/verification_sessions/object#identity_verification_session_object-type\n \"\"\"\n\n document = _(\"Document\")\n id_number = _(\"ID number\")",
"nameRange": {
"startLine": 831,
"startColumn": 6,
"endLine": 831,
"endColumn": 22
}
}
},
{
"type": "comment",
"ref": "djstripe/models/identity.py:24",
"range": {
"startLine": 24,
"startColumn": 4,
"endLine": 24,
"endColumn": 73
},
"expression": "# The following attributes are not stored because they are sensitive."
}
]
},
{
"type": "class_property",
"filePath": "djstripe/models/base.py",
"name": "id",
"ref": "djstripe/models/base.py:100",
"definitionRange": {
"startLine": 100,
"startColumn": 4,
"endLine": 100,
"endColumn": 35
},
"language": "python",
"snippet": "id = StripeIdField(unique=True)",
"nameRange": {
"startLine": 100,
"startColumn": 4,
"endLine": 100,
"endColumn": 6
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/event_handlers.py:499",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 499,
"startColumn": 73,
"endLine": 499,
"endColumn": 75
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_process_events.py:100",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 100,
"startColumn": 60,
"endLine": 100,
"endColumn": 62
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/management/commands/djstripe_sync_models.py:153",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 153,
"startColumn": 82,
"endLine": 153,
"endColumn": 84
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:110",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 110,
"startColumn": 49,
"endLine": 110,
"endColumn": 51
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/account.py:132",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 132,
"startColumn": 17,
"endLine": 132,
"endColumn": 19
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:154",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 154,
"startColumn": 59,
"endLine": 154,
"endColumn": 61
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:159",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 159,
"startColumn": 44,
"endLine": 159,
"endColumn": 46
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:211",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 211,
"startColumn": 32,
"endLine": 211,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:236",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 236,
"startColumn": 20,
"endLine": 236,
"endColumn": 22
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:277",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 277,
"startColumn": 17,
"endLine": 277,
"endColumn": 19
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:302",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 302,
"startColumn": 17,
"endLine": 302,
"endColumn": 19
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:618",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 618,
"startColumn": 24,
"endLine": 618,
"endColumn": 26
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/base.py:1120",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1120,
"startColumn": 27,
"endLine": 1120,
"endColumn": 29
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:724",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 724,
"startColumn": 68,
"endLine": 724,
"endColumn": 70
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:765",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 765,
"startColumn": 32,
"endLine": 765,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:769",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 769,
"startColumn": 40,
"endLine": 769,
"endColumn": 42
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:773",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 773,
"startColumn": 50,
"endLine": 773,
"endColumn": 52
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1247",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1247,
"startColumn": 26,
"endLine": 1247,
"endColumn": 28
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1249",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1249,
"startColumn": 67,
"endLine": 1249,
"endColumn": 69
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1594",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1594,
"startColumn": 24,
"endLine": 1594,
"endColumn": 26
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1979",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1979,
"startColumn": 17,
"endLine": 1979,
"endColumn": 19
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2008",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2008,
"startColumn": 17,
"endLine": 2008,
"endColumn": 19
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2131",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2131,
"startColumn": 36,
"endLine": 2131,
"endColumn": 38
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:2201",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2201,
"startColumn": 25,
"endLine": 2201,
"endColumn": 27
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:218",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 218,
"startColumn": 62,
"endLine": 218,
"endColumn": 64
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/connect.py:290",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 290,
"startColumn": 25,
"endLine": 290,
"endColumn": 27
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:47",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 47,
"startColumn": 22,
"endLine": 47,
"endColumn": 24
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:452",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 452,
"startColumn": 24,
"endLine": 452,
"endColumn": 26
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:838",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 838,
"startColumn": 53,
"endLine": 838,
"endColumn": 55
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:991",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 991,
"startColumn": 40,
"endLine": 991,
"endColumn": 42
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1022",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1022,
"startColumn": 28,
"endLine": 1022,
"endColumn": 30
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1025",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1025,
"startColumn": 26,
"endLine": 1025,
"endColumn": 28
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1093",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1093,
"startColumn": 30,
"endLine": 1093,
"endColumn": 32
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1097",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1097,
"startColumn": 40,
"endLine": 1097,
"endColumn": 42
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1102",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1102,
"startColumn": 26,
"endLine": 1102,
"endColumn": 28
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1132",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1132,
"startColumn": 31,
"endLine": 1132,
"endColumn": 33
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1202",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1202,
"startColumn": 30,
"endLine": 1202,
"endColumn": 32
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1275",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1275,
"startColumn": 56,
"endLine": 1275,
"endColumn": 58
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1300",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1300,
"startColumn": 28,
"endLine": 1300,
"endColumn": 30
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1387",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1387,
"startColumn": 25,
"endLine": 1387,
"endColumn": 27
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1396",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1396,
"startColumn": 61,
"endLine": 1396,
"endColumn": 63
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1401",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1401,
"startColumn": 59,
"endLine": 1401,
"endColumn": 61
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1416",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1416,
"startColumn": 26,
"endLine": 1416,
"endColumn": 28
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/core.py:1586",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1586,
"startColumn": 44,
"endLine": 1586,
"endColumn": 46
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:675",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 675,
"startColumn": 35,
"endLine": 675,
"endColumn": 37
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:706",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 706,
"startColumn": 52,
"endLine": 706,
"endColumn": 54
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:807",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 807,
"startColumn": 27,
"endLine": 807,
"endColumn": 29
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:809",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 809,
"startColumn": 37,
"endLine": 809,
"endColumn": 39
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:816",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 816,
"startColumn": 24,
"endLine": 816,
"endColumn": 26
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:818",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 818,
"startColumn": 31,
"endLine": 818,
"endColumn": 33
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:822",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 822,
"startColumn": 81,
"endLine": 822,
"endColumn": 83
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:875",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 875,
"startColumn": 44,
"endLine": 875,
"endColumn": 46
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:878",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 878,
"startColumn": 32,
"endLine": 878,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/payment_methods.py:907",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 907,
"startColumn": 30,
"endLine": 907,
"endColumn": 32
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/sigma.py:50",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 50,
"startColumn": 37,
"endLine": 50,
"endColumn": 39
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/views.py:103",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 103,
"startColumn": 34,
"endLine": 103,
"endColumn": 36
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/apps/example/views.py:177",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 177,
"startColumn": 30,
"endLine": 177,
"endColumn": 32
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:232",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 232,
"startColumn": 56,
"endLine": 232,
"endColumn": 58
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:507",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 507,
"startColumn": 16,
"endLine": 507,
"endColumn": 18
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:534",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 534,
"startColumn": 36,
"endLine": 534,
"endColumn": 38
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_account.py:845",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 845,
"startColumn": 23,
"endLine": 845,
"endColumn": 25
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:204",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 204,
"startColumn": 66,
"endLine": 204,
"endColumn": 68
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:226",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 226,
"startColumn": 66,
"endLine": 226,
"endColumn": 68
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:234",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 234,
"startColumn": 65,
"endLine": 234,
"endColumn": 67
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:397",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 397,
"startColumn": 26,
"endLine": 397,
"endColumn": 28
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:435",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 435,
"startColumn": 32,
"endLine": 435,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_bank_account.py:479",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 479,
"startColumn": 32,
"endLine": 479,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:171",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 171,
"startColumn": 58,
"endLine": 171,
"endColumn": 60
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:196",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 196,
"startColumn": 58,
"endLine": 196,
"endColumn": 60
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:204",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 204,
"startColumn": 57,
"endLine": 204,
"endColumn": 59
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:349",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 349,
"startColumn": 26,
"endLine": 349,
"endColumn": 28
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:377",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 377,
"startColumn": 32,
"endLine": 377,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_card.py:413",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 413,
"startColumn": 32,
"endLine": 413,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:347",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 347,
"startColumn": 32,
"endLine": 347,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_charge.py:347",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 347,
"startColumn": 52,
"endLine": 347,
"endColumn": 54
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:105",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 105,
"startColumn": 126,
"endLine": 105,
"endColumn": 128
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:109",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 109,
"startColumn": 121,
"endLine": 109,
"endColumn": 123
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:451",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 451,
"startColumn": 57,
"endLine": 451,
"endColumn": 59
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:526",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 526,
"startColumn": 57,
"endLine": 526,
"endColumn": 59
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:534",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 534,
"startColumn": 26,
"endLine": 534,
"endColumn": 28
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:567",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 567,
"startColumn": 26,
"endLine": 567,
"endColumn": 28
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:588",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 588,
"startColumn": 49,
"endLine": 588,
"endColumn": 51
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:588",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 588,
"startColumn": 67,
"endLine": 588,
"endColumn": 69
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:632",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 632,
"startColumn": 49,
"endLine": 632,
"endColumn": 51
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:632",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 632,
"startColumn": 67,
"endLine": 632,
"endColumn": 69
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:684",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 684,
"startColumn": 49,
"endLine": 684,
"endColumn": 51
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:684",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 684,
"startColumn": 67,
"endLine": 684,
"endColumn": 69
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:829",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 829,
"startColumn": 57,
"endLine": 829,
"endColumn": 59
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:903",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 903,
"startColumn": 57,
"endLine": 903,
"endColumn": 59
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1131",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1131,
"startColumn": 79,
"endLine": 1131,
"endColumn": 81
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1456",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1456,
"startColumn": 35,
"endLine": 1456,
"endColumn": 37
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1471",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1471,
"startColumn": 35,
"endLine": 1471,
"endColumn": 37
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1635",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1635,
"startColumn": 55,
"endLine": 1635,
"endColumn": 57
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1671",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1671,
"startColumn": 44,
"endLine": 1671,
"endColumn": 46
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1772",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1772,
"startColumn": 35,
"endLine": 1772,
"endColumn": 37
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1772",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1772,
"startColumn": 56,
"endLine": 1772,
"endColumn": 58
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1772",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1772,
"startColumn": 85,
"endLine": 1772,
"endColumn": 87
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1832",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1832,
"startColumn": 35,
"endLine": 1832,
"endColumn": 37
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1832",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1832,
"startColumn": 54,
"endLine": 1832,
"endColumn": 56
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1832",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1832,
"startColumn": 83,
"endLine": 1832,
"endColumn": 85
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1910",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1910,
"startColumn": 35,
"endLine": 1910,
"endColumn": 37
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:1945",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1945,
"startColumn": 35,
"endLine": 1945,
"endColumn": 37
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2067",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2067,
"startColumn": 55,
"endLine": 2067,
"endColumn": 57
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2156",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2156,
"startColumn": 54,
"endLine": 2156,
"endColumn": 56
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2183",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2183,
"startColumn": 54,
"endLine": 2183,
"endColumn": 56
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2237",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2237,
"startColumn": 53,
"endLine": 2237,
"endColumn": 55
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2276",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2276,
"startColumn": 42,
"endLine": 2276,
"endColumn": 44
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2333",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2333,
"startColumn": 33,
"endLine": 2333,
"endColumn": 35
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2333",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2333,
"startColumn": 52,
"endLine": 2333,
"endColumn": 54
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2333",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2333,
"startColumn": 81,
"endLine": 2333,
"endColumn": 83
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_customer.py:2494",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2494,
"startColumn": 55,
"endLine": 2494,
"endColumn": 57
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_discount.py:90",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 90,
"startColumn": 34,
"endLine": 90,
"endColumn": 36
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_dispute.py:114",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 114,
"startColumn": 23,
"endLine": 114,
"endColumn": 25
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_dispute.py:156",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 156,
"startColumn": 23,
"endLine": 156,
"endColumn": 25
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:219",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 219,
"startColumn": 32,
"endLine": 219,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:317",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 317,
"startColumn": 32,
"endLine": 317,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:414",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 414,
"startColumn": 33,
"endLine": 414,
"endColumn": 35
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:512",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 512,
"startColumn": 33,
"endLine": 512,
"endColumn": 35
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:607",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 607,
"startColumn": 75,
"endLine": 607,
"endColumn": 77
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:642",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 642,
"startColumn": 73,
"endLine": 642,
"endColumn": 75
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:677",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 677,
"startColumn": 71,
"endLine": 677,
"endColumn": 73
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:858",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 858,
"startColumn": 60,
"endLine": 858,
"endColumn": 62
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:934",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 934,
"startColumn": 60,
"endLine": 934,
"endColumn": 62
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:1010",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1010,
"startColumn": 60,
"endLine": 1010,
"endColumn": 62
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:1100",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1100,
"startColumn": 60,
"endLine": 1100,
"endColumn": 62
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:1224",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1224,
"startColumn": 40,
"endLine": 1224,
"endColumn": 42
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:1242",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1242,
"startColumn": 40,
"endLine": 1242,
"endColumn": 42
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:1506",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1506,
"startColumn": 33,
"endLine": 1506,
"endColumn": 35
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:1557",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1557,
"startColumn": 33,
"endLine": 1557,
"endColumn": 35
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:1607",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1607,
"startColumn": 33,
"endLine": 1607,
"endColumn": 35
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:1657",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1657,
"startColumn": 33,
"endLine": 1657,
"endColumn": 35
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:1712",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1712,
"startColumn": 33,
"endLine": 1712,
"endColumn": 35
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:1768",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1768,
"startColumn": 33,
"endLine": 1768,
"endColumn": 35
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:1793",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1793,
"startColumn": 30,
"endLine": 1793,
"endColumn": 32
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:2549",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2549,
"startColumn": 24,
"endLine": 2549,
"endColumn": 26
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:2624",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2624,
"startColumn": 21,
"endLine": 2624,
"endColumn": 23
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:2966",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 2966,
"startColumn": 21,
"endLine": 2966,
"endColumn": 23
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:3012",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 3012,
"startColumn": 32,
"endLine": 3012,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_event_handlers.py:3042",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 3042,
"startColumn": 32,
"endLine": 3042,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_file_upload.py:44",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 44,
"startColumn": 33,
"endLine": 44,
"endColumn": 35
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_file_upload.py:47",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 47,
"startColumn": 43,
"endLine": 47,
"endColumn": 45
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_file_upload.py:51",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 51,
"startColumn": 33,
"endLine": 51,
"endColumn": 35
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_file_upload.py:54",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 54,
"startColumn": 43,
"endLine": 54,
"endColumn": 45
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_file_upload.py:70",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 70,
"startColumn": 20,
"endLine": 70,
"endColumn": 22
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:568",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 568,
"startColumn": 23,
"endLine": 568,
"endColumn": 25
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1136",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1136,
"startColumn": 55,
"endLine": 1136,
"endColumn": 57
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1259",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1259,
"startColumn": 55,
"endLine": 1259,
"endColumn": 57
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1320",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1320,
"startColumn": 55,
"endLine": 1320,
"endColumn": 57
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1516",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1516,
"startColumn": 55,
"endLine": 1516,
"endColumn": 57
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1649",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1649,
"startColumn": 55,
"endLine": 1649,
"endColumn": 57
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_invoice.py:1757",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 1757,
"startColumn": 55,
"endLine": 1757,
"endColumn": 57
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_line_item.py:128",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 128,
"startColumn": 28,
"endLine": 128,
"endColumn": 30
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:277",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 277,
"startColumn": 42,
"endLine": 277,
"endColumn": 44
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:278",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 278,
"startColumn": 42,
"endLine": 278,
"endColumn": 44
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:279",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 279,
"startColumn": 42,
"endLine": 279,
"endColumn": 44
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:282",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 282,
"startColumn": 30,
"endLine": 282,
"endColumn": 32
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:285",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 285,
"startColumn": 28,
"endLine": 285,
"endColumn": 30
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:288",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 288,
"startColumn": 33,
"endLine": 288,
"endColumn": 35
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:291",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 291,
"startColumn": 29,
"endLine": 291,
"endColumn": 31
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_managers.py:294",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 294,
"startColumn": 29,
"endLine": 294,
"endColumn": 31
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_payment_method.py:96",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 96,
"startColumn": 18,
"endLine": 96,
"endColumn": 20
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_payment_method.py:165",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 165,
"startColumn": 27,
"endLine": 165,
"endColumn": 29
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_plan.py:217",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 217,
"startColumn": 30,
"endLine": 217,
"endColumn": 32
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_plan.py:232",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 232,
"startColumn": 30,
"endLine": 232,
"endColumn": 32
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:188",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 188,
"startColumn": 21,
"endLine": 188,
"endColumn": 23
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:204",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 204,
"startColumn": 21,
"endLine": 204,
"endColumn": 23
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_price.py:220",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 220,
"startColumn": 21,
"endLine": 220,
"endColumn": 23
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_product.py:74",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 74,
"startColumn": 23,
"endLine": 74,
"endColumn": 25
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_shipping_rate.py:29",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 29,
"startColumn": 26,
"endLine": 29,
"endColumn": 28
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_shipping_rate.py:51",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 51,
"startColumn": 26,
"endLine": 51,
"endColumn": 28
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:56",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 56,
"startColumn": 15,
"endLine": 56,
"endColumn": 17
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:88",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 88,
"startColumn": 15,
"endLine": 88,
"endColumn": 17
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_stripe_model.py:125",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 125,
"startColumn": 15,
"endLine": 125,
"endColumn": 17
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription_item.py:148",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 148,
"startColumn": 43,
"endLine": 148,
"endColumn": 45
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription_item.py:201",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 201,
"startColumn": 43,
"endLine": 201,
"endColumn": 45
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_subscription_item.py:277",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 277,
"startColumn": 43,
"endLine": 277,
"endColumn": 45
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_tax_code.py:19",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 19,
"startColumn": 24,
"endLine": 19,
"endColumn": 26
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_tax_id.py:63",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 63,
"startColumn": 22,
"endLine": 63,
"endColumn": 24
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_tax_rates.py:24",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 24,
"startColumn": 21,
"endLine": 24,
"endColumn": 23
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_transfer.py:161",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 161,
"startColumn": 70,
"endLine": 161,
"endColumn": 72
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_usage_record.py:62",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 62,
"startColumn": 38,
"endLine": 62,
"endColumn": 40
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_usage_record_summary.py:66",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 66,
"startColumn": 46,
"endLine": 66,
"endColumn": 48
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_usage_record_summary.py:135",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 135,
"startColumn": 46,
"endLine": 135,
"endColumn": 48
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_views.py:367",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 367,
"startColumn": 66,
"endLine": 367,
"endColumn": 68
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_webhooks.py:606",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 606,
"startColumn": 32,
"endLine": 606,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_webhooks.py:615",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 615,
"startColumn": 32,
"endLine": 615,
"endColumn": 34
},
"snippet": "id"
},
{
"type": "from-parsing",
"sourceRef": "tests/test_webhooks.py:633",
"targetRef": "djstripe/models/base.py:100",
"sourceSnippetRange": {
"startLine": 633,
"startColumn": 32,
"endLine": 633,
"endColumn": 34
},
"snippet": "id"
}
],
"expressions": [
{
"type": "call",
"ref": "djstripe/models/base.py:100",
"range": {
"startLine": 100,
"startColumn": 9,
"endLine": 100,
"endColumn": 35
},
"name": "StripeIdField",
"expression": "StripeIdField(unique=True)",
"definition": {
"type": "class",
"filePath": "djstripe/fields.py",
"name": "StripeIdField",
"ref": "djstripe/fields.py:120",
"definitionRange": {
"startLine": 120,
"startColumn": 0,
"endLine": 134,
"endColumn": 43
},
"language": "python",
"snippet": "class StripeIdField(FieldDeconstructMixin, models.CharField):\n \"\"\"A field with enough space to hold any stripe ID.\"\"\"\n\n def __init__(self, *args, **kwargs):\n \"\"\"\n Assign default args to this field.\n\n As per: https://stripe.com/docs/upgrades\n You can safely assume object IDs we generate will never exceed 255\n characters, but you should be able to handle IDs of up to that\n length.\n \"\"\"\n defaults = {\"max_length\": 255, \"blank\": False, \"null\": False}\n defaults.update(kwargs)\n super().__init__(*args, **defaults)",
"nameRange": {
"startLine": 120,
"startColumn": 6,
"endLine": 120,
"endColumn": 19
}
}
}
]
},
{
"type": "class",
"filePath": "djstripe/managers.py",
"name": "SubscriptionManager",
"ref": "djstripe/managers.py:15",
"definitionRange": {
"startLine": 15,
"startColumn": 0,
"endLine": 66,
"endColumn": 76
},
"language": "python",
"snippet": "class SubscriptionManager(models.Manager):\n \"\"\"Manager used in models.Subscription.\"\"\"\n\n def started_during(self, year, month):\n \"\"\"Return Subscriptions not in trial status between a certain time range.\"\"\"\n return self.exclude(status=\"trialing\").filter(\n start_date__year=year, start_date__month=month\n )\n\n def active(self):\n \"\"\"Return active Subscriptions.\"\"\"\n return self.filter(status=\"active\")\n\n def canceled(self):\n \"\"\"Return canceled Subscriptions.\"\"\"\n return self.filter(status=\"canceled\")\n\n def canceled_during(self, year, month):\n \"\"\"Return Subscriptions canceled during a certain time range.\"\"\"\n return self.canceled().filter(canceled_at__year=year, canceled_at__month=month)\n\n def started_plan_summary_for(self, year, month):\n \"\"\"Return started_during Subscriptions with plan counts annotated.\"\"\"\n return (\n self.started_during(year, month)\n .values(\"plan\")\n .order_by()\n .annotate(count=models.Count(\"plan\"))\n )\n\n def active_plan_summary(self):\n \"\"\"Return active Subscriptions with plan counts annotated.\"\"\"\n return (\n self.active().values(\"plan\").order_by().annotate(count=models.Count(\"plan\"))\n )\n\n def canceled_plan_summary_for(self, year, month):\n \"\"\"\n Return Subscriptions canceled within a time range with plan counts annotated.\n \"\"\"\n return (\n self.canceled_during(year, month)\n .values(\"plan\")\n .order_by()\n .annotate(count=models.Count(\"plan\"))\n )\n\n def churn(self):\n \"\"\"Return number of canceled Subscriptions divided by active Subscriptions.\"\"\"\n canceled = self.canceled().count()\n active = self.active().count()\n return decimal.Decimal(str(canceled)) / decimal.Decimal(str(active))",
"nameRange": {
"startLine": 15,
"startColumn": 6,
"endLine": 15,
"endColumn": 25
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:24",
"targetRef": "djstripe/managers.py:15",
"sourceSnippetRange": {
"startLine": 24,
"startColumn": 23,
"endLine": 24,
"endColumn": 42
},
"snippet": "SubscriptionManager"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/billing.py:1559",
"targetRef": "djstripe/managers.py:15",
"sourceSnippetRange": {
"startLine": 1559,
"startColumn": 14,
"endLine": 1559,
"endColumn": 33
},
"snippet": "SubscriptionManager"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/managers.py:15",
"range": {
"startLine": 15,
"startColumn": 25,
"endLine": 15,
"endColumn": 41
},
"name": "Manager",
"expression": "(models.Manager)",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Manager",
"ref": "__base_types__:39",
"definitionRange": {
"startLine": 39,
"startColumn": 0,
"endLine": 40,
"endColumn": 39
},
"language": "python",
"snippet": "class Manager(BaseManager[_T]):\n _queryset_class: type[QuerySet[_T]]",
"nameRange": {
"startLine": 39,
"startColumn": 6,
"endLine": 39,
"endColumn": 13
}
}
},
{
"type": "variable",
"ref": "djstripe/managers.py:15",
"range": {
"startLine": 15,
"startColumn": 26,
"endLine": 15,
"endColumn": 40
},
"name": "models",
"expression": "models.Manager",
"definition": {
"type": "import",
"filePath": "__base_types__",
"name": "functions",
"ref": "__base_types__:0",
"definitionRange": {
"startLine": 0,
"startColumn": 0,
"endLine": 0,
"endColumn": 51
},
"language": "python",
"snippet": "from django.db.models import functions as functions",
"nameRange": {
"startLine": 0,
"startColumn": 42,
"endLine": 0,
"endColumn": 51
}
}
},
{
"type": "comment",
"ref": "djstripe/managers.py:16",
"range": {
"startLine": 16,
"startColumn": 4,
"endLine": 16,
"endColumn": 46
},
"expression": "\"\"\"Manager used in models.Subscription.\"\"\""
},
{
"type": "comment",
"ref": "djstripe/managers.py:19",
"range": {
"startLine": 19,
"startColumn": 8,
"endLine": 19,
"endColumn": 84
},
"expression": "\"\"\"Return Subscriptions not in trial status between a certain time range.\"\"\""
},
{
"type": "call",
"ref": "djstripe/managers.py:20",
"range": {
"startLine": 20,
"startColumn": 15,
"endLine": 20,
"endColumn": 46
},
"name": "exclude",
"expression": "self.exclude(status=\"trialing\")",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "exclude",
"ref": "__base_types__:139",
"definitionRange": {
"startLine": 139,
"startColumn": 4,
"endLine": 139,
"endColumn": 61
},
"language": "python",
"snippet": "def exclude(self, *args: Any, **kwargs: Any) -> Self: ...",
"nameRange": {
"startLine": 139,
"startColumn": 8,
"endLine": 139,
"endColumn": 15
}
}
},
{
"type": "variable",
"ref": "djstripe/managers.py:21",
"range": {
"startLine": 21,
"startColumn": 12,
"endLine": 21,
"endColumn": 33
},
"name": "year",
"expression": "start_date__year=year",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "started_during",
"ref": "djstripe/managers.py:18",
"definitionRange": {
"startLine": 18,
"startColumn": 4,
"endLine": 22,
"endColumn": 9
},
"language": "python",
"snippet": "def started_during(self, year, month):\n \"\"\"Return Subscriptions not in trial status between a certain time range.\"\"\"\n return self.exclude(status=\"trialing\").filter(\n start_date__year=year, start_date__month=month\n )",
"nameRange": {
"startLine": 18,
"startColumn": 8,
"endLine": 18,
"endColumn": 22
}
}
},
{
"type": "comment",
"ref": "djstripe/managers.py:25",
"range": {
"startLine": 25,
"startColumn": 8,
"endLine": 25,
"endColumn": 42
},
"expression": "\"\"\"Return active Subscriptions.\"\"\""
},
{
"type": "comment",
"ref": "djstripe/managers.py:29",
"range": {
"startLine": 29,
"startColumn": 8,
"endLine": 29,
"endColumn": 44
},
"expression": "\"\"\"Return canceled Subscriptions.\"\"\""
},
{
"type": "comment",
"ref": "djstripe/managers.py:33",
"range": {
"startLine": 33,
"startColumn": 8,
"endLine": 33,
"endColumn": 72
},
"expression": "\"\"\"Return Subscriptions canceled during a certain time range.\"\"\""
},
{
"type": "call",
"ref": "djstripe/managers.py:34",
"range": {
"startLine": 34,
"startColumn": 15,
"endLine": 34,
"endColumn": 30
},
"name": "canceled",
"expression": "self.canceled()",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "canceled",
"ref": "djstripe/managers.py:28",
"definitionRange": {
"startLine": 28,
"startColumn": 4,
"endLine": 30,
"endColumn": 45
},
"language": "python",
"snippet": "def canceled(self):\n \"\"\"Return canceled Subscriptions.\"\"\"\n return self.filter(status=\"canceled\")",
"nameRange": {
"startLine": 28,
"startColumn": 8,
"endLine": 28,
"endColumn": 16
}
}
},
{
"type": "variable",
"ref": "djstripe/managers.py:34",
"range": {
"startLine": 34,
"startColumn": 38,
"endLine": 34,
"endColumn": 60
},
"name": "year",
"expression": "canceled_at__year=year",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "canceled_during",
"ref": "djstripe/managers.py:32",
"definitionRange": {
"startLine": 32,
"startColumn": 4,
"endLine": 34,
"endColumn": 87
},
"language": "python",
"snippet": "def canceled_during(self, year, month):\n \"\"\"Return Subscriptions canceled during a certain time range.\"\"\"\n return self.canceled().filter(canceled_at__year=year, canceled_at__month=month)",
"nameRange": {
"startLine": 32,
"startColumn": 8,
"endLine": 32,
"endColumn": 23
}
}
},
{
"type": "comment",
"ref": "djstripe/managers.py:37",
"range": {
"startLine": 37,
"startColumn": 8,
"endLine": 37,
"endColumn": 77
},
"expression": "\"\"\"Return started_during Subscriptions with plan counts annotated.\"\"\""
},
{
"type": "variable",
"ref": "djstripe/managers.py:39",
"range": {
"startLine": 39,
"startColumn": 31,
"endLine": 39,
"endColumn": 44
},
"name": "year",
"expression": "(year, month)",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "started_plan_summary_for",
"ref": "djstripe/managers.py:36",
"definitionRange": {
"startLine": 36,
"startColumn": 4,
"endLine": 43,
"endColumn": 9
},
"language": "python",
"snippet": "def started_plan_summary_for(self, year, month):\n \"\"\"Return started_during Subscriptions with plan counts annotated.\"\"\"\n return (\n self.started_during(year, month)\n .values(\"plan\")\n .order_by()\n .annotate(count=models.Count(\"plan\"))\n )",
"nameRange": {
"startLine": 36,
"startColumn": 8,
"endLine": 36,
"endColumn": 32
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:39",
"range": {
"startLine": 39,
"startColumn": 12,
"endLine": 40,
"endColumn": 27
},
"name": "values",
"expression": "self.started_during(year, month)\n .values(\"plan\")",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "values",
"ref": "__base_types__:119",
"definitionRange": {
"startLine": 119,
"startColumn": 4,
"endLine": 121,
"endColumn": 48
},
"language": "python",
"snippet": "def values(\n self, *fields: str | Combinable, **expressions: Any\n ) -> ValuesQuerySet[_T, dict[str, Any]]: ...",
"nameRange": {
"startLine": 119,
"startColumn": 8,
"endLine": 119,
"endColumn": 14
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:39",
"range": {
"startLine": 39,
"startColumn": 12,
"endLine": 41,
"endColumn": 23
},
"name": "order_by",
"expression": "self.started_during(year, month)\n .values(\"plan\")\n .order_by()",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "order_by",
"ref": "__base_types__:157",
"definitionRange": {
"startLine": 157,
"startColumn": 4,
"endLine": 157,
"endColumn": 54
},
"language": "python",
"snippet": "def order_by(self, *field_names: Any) -> Self: ...",
"nameRange": {
"startLine": 157,
"startColumn": 8,
"endLine": 157,
"endColumn": 16
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:39",
"range": {
"startLine": 39,
"startColumn": 12,
"endLine": 42,
"endColumn": 49
},
"name": "annotate",
"expression": "self.started_during(year, month)\n .values(\"plan\")\n .order_by()\n .annotate(count=models.Count(\"plan\"))",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "annotate",
"ref": "__base_types__:155",
"definitionRange": {
"startLine": 155,
"startColumn": 4,
"endLine": 155,
"endColumn": 62
},
"language": "python",
"snippet": "def annotate(self, *args: Any, **kwargs: Any) -> Self: ...",
"nameRange": {
"startLine": 155,
"startColumn": 8,
"endLine": 155,
"endColumn": 16
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:42",
"range": {
"startLine": 42,
"startColumn": 28,
"endLine": 42,
"endColumn": 48
},
"name": "Count",
"expression": "models.Count(\"plan\")",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Count",
"ref": "__base_types__:17",
"definitionRange": {
"startLine": 17,
"startColumn": 0,
"endLine": 17,
"endColumn": 27
},
"language": "python",
"snippet": "class Count(Aggregate): ...",
"nameRange": {
"startLine": 17,
"startColumn": 6,
"endLine": 17,
"endColumn": 11
}
}
},
{
"type": "comment",
"ref": "djstripe/managers.py:46",
"range": {
"startLine": 46,
"startColumn": 8,
"endLine": 46,
"endColumn": 69
},
"expression": "\"\"\"Return active Subscriptions with plan counts annotated.\"\"\""
},
{
"type": "call",
"ref": "djstripe/managers.py:48",
"range": {
"startLine": 48,
"startColumn": 12,
"endLine": 48,
"endColumn": 25
},
"name": "active",
"expression": "self.active()",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "active",
"ref": "djstripe/managers.py:24",
"definitionRange": {
"startLine": 24,
"startColumn": 4,
"endLine": 26,
"endColumn": 43
},
"language": "python",
"snippet": "def active(self):\n \"\"\"Return active Subscriptions.\"\"\"\n return self.filter(status=\"active\")",
"nameRange": {
"startLine": 24,
"startColumn": 8,
"endLine": 24,
"endColumn": 14
}
}
},
{
"type": "comment",
"ref": "djstripe/managers.py:52",
"range": {
"startLine": 52,
"startColumn": 8,
"endLine": 54,
"endColumn": 11
},
"expression": "\"\"\"\n Return Subscriptions canceled within a time range with plan counts annotated.\n \"\"\""
},
{
"type": "variable",
"ref": "djstripe/managers.py:56",
"range": {
"startLine": 56,
"startColumn": 32,
"endLine": 56,
"endColumn": 45
},
"name": "year",
"expression": "(year, month)",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "canceled_plan_summary_for",
"ref": "djstripe/managers.py:51",
"definitionRange": {
"startLine": 51,
"startColumn": 4,
"endLine": 60,
"endColumn": 9
},
"language": "python",
"snippet": "def canceled_plan_summary_for(self, year, month):\n \"\"\"\n Return Subscriptions canceled within a time range with plan counts annotated.\n \"\"\"\n return (\n self.canceled_during(year, month)\n .values(\"plan\")\n .order_by()\n .annotate(count=models.Count(\"plan\"))\n )",
"nameRange": {
"startLine": 51,
"startColumn": 8,
"endLine": 51,
"endColumn": 33
}
}
},
{
"type": "comment",
"ref": "djstripe/managers.py:63",
"range": {
"startLine": 63,
"startColumn": 8,
"endLine": 63,
"endColumn": 86
},
"expression": "\"\"\"Return number of canceled Subscriptions divided by active Subscriptions.\"\"\""
},
{
"type": "call",
"ref": "djstripe/managers.py:64",
"range": {
"startLine": 64,
"startColumn": 19,
"endLine": 64,
"endColumn": 42
},
"name": "count",
"expression": "self.canceled().count()",
"definition": {
"type": "method",
"filePath": "__base_types__",
"name": "count",
"ref": "__base_types__:141",
"definitionRange": {
"startLine": 141,
"startColumn": 4,
"endLine": 141,
"endColumn": 31
},
"language": "python",
"snippet": "def count(self) -> int: ...",
"nameRange": {
"startLine": 141,
"startColumn": 8,
"endLine": 141,
"endColumn": 13
}
}
},
{
"type": "call",
"ref": "djstripe/managers.py:66",
"range": {
"startLine": 66,
"startColumn": 15,
"endLine": 66,
"endColumn": 45
},
"name": "Decimal",
"expression": "decimal.Decimal(str(canceled))",
"definition": {
"type": "class",
"filePath": "__base_types__",
"name": "Decimal",
"ref": "__base_types__:69",
"definitionRange": {
"startLine": 69,
"startColumn": 0,
"endLine": 168,
"endColumn": 86
},
"language": "python",
"snippet": "class Decimal:\n def __new__(cls, value: _DecimalNew = ..., context: Context | None = ...) -> Self: ...\n @classmethod\n def from_float(cls, f: float, /) -> Self: ...\n def __bool__(self) -> bool: ...\n def compare(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def __hash__(self) -> int: ...\n def as_tuple(self) -> DecimalTuple: ...\n def as_integer_ratio(self) -> tuple[int, int]: ...\n def to_eng_string(self, context: Context | None = None) -> str: ...\n def __abs__(self) -> Decimal: ...\n def __add__(self, value: _Decimal, /) -> Decimal: ...\n def __divmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]: ...\n def __eq__(self, value: object, /) -> bool: ...\n def __floordiv__(self, value: _Decimal, /) -> Decimal: ...\n def __ge__(self, value: _ComparableNum, /) -> bool: ...\n def __gt__(self, value: _ComparableNum, /) -> bool: ...\n def __le__(self, value: _ComparableNum, /) -> bool: ...\n def __lt__(self, value: _ComparableNum, /) -> bool: ...\n def __mod__(self, value: _Decimal, /) -> Decimal: ...\n def __mul__(self, value: _Decimal, /) -> Decimal: ...\n def __neg__(self) -> Decimal: ...\n def __pos__(self) -> Decimal: ...\n def __pow__(self, value: _Decimal, mod: _Decimal | None = None, /) -> Decimal: ...\n def __radd__(self, value: _Decimal, /) -> Decimal: ...\n def __rdivmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]: ...\n def __rfloordiv__(self, value: _Decimal, /) -> Decimal: ...\n def __rmod__(self, value: _Decimal, /) -> Decimal: ...\n def __rmul__(self, value: _Decimal, /) -> Decimal: ...\n def __rsub__(self, value: _Decimal, /) -> Decimal: ...\n def __rtruediv__(self, value: _Decimal, /) -> Decimal: ...\n def __sub__(self, value: _Decimal, /) -> Decimal: ...\n def __truediv__(self, value: _Decimal, /) -> Decimal: ...\n def remainder_near(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def __float__(self) -> float: ...\n def __int__(self) -> int: ...\n def __trunc__(self) -> int: ...\n @property\n def real(self) -> Decimal: ...\n @property\n def imag(self) -> Decimal: ...\n def conjugate(self) -> Decimal: ...\n def __complex__(self) -> complex: ...\n @overload\n def __round__(self) -> int: ...\n @overload\n def __round__(self, ndigits: int, /) -> Decimal: ...\n def __floor__(self) -> int: ...\n def __ceil__(self) -> int: ...\n def fma(self, other: _Decimal, third: _Decimal, context: Context | None = None) -> Decimal: ...\n def __rpow__(self, value: _Decimal, mod: Context | None = None, /) -> Decimal: ...\n def normalize(self, context: Context | None = None) -> Decimal: ...\n def quantize(self, exp: _Decimal, rounding: str | None = None, context: Context | None = None) -> Decimal: ...\n def same_quantum(self, other: _Decimal, context: Context | None = None) -> bool: ...\n def to_integral_exact(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...\n def to_integral_value(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...\n def to_integral(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...\n def sqrt(self, context: Context | None = None) -> Decimal: ...\n def max(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def min(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def adjusted(self) -> int: ...\n def canonical(self) -> Decimal: ...\n def compare_signal(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def compare_total(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def compare_total_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def copy_abs(self) -> Decimal: ...\n def copy_negate(self) -> Decimal: ...\n def copy_sign(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def exp(self, context: Context | None = None) -> Decimal: ...\n def is_canonical(self) -> bool: ...\n def is_finite(self) -> bool: ...\n def is_infinite(self) -> bool: ...\n def is_nan(self) -> bool: ...\n def is_normal(self, context: Context | None = None) -> bool: ...\n def is_qnan(self) -> bool: ...\n def is_signed(self) -> bool: ...\n def is_snan(self) -> bool: ...\n def is_subnormal(self, context: Context | None = None) -> bool: ...\n def is_zero(self) -> bool: ...\n def ln(self, context: Context | None = None) -> Decimal: ...\n def log10(self, context: Context | None = None) -> Decimal: ...\n def logb(self, context: Context | None = None) -> Decimal: ...\n def logical_and(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def logical_invert(self, context: Context | None = None) -> Decimal: ...\n def logical_or(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def logical_xor(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def max_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def min_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def next_minus(self, context: Context | None = None) -> Decimal: ...\n def next_plus(self, context: Context | None = None) -> Decimal: ...\n def next_toward(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def number_class(self, context: Context | None = None) -> str: ...\n def radix(self) -> Decimal: ...\n def rotate(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def scaleb(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def shift(self, other: _Decimal, context: Context | None = None) -> Decimal: ...\n def __reduce__(self) -> tuple[type[Self], tuple[str]]: ...\n def __copy__(self) -> Self: ...\n def __deepcopy__(self, memo: Any, /) -> Self: ...\n def __format__(self, specifier: str, context: Context | None = ..., /) -> str: ...",
"nameRange": {
"startLine": 69,
"startColumn": 6,
"endLine": 69,
"endColumn": 13
}
}
},
{
"type": "variable",
"ref": "djstripe/managers.py:66",
"range": {
"startLine": 66,
"startColumn": 34,
"endLine": 66,
"endColumn": 44
},
"name": "canceled",
"expression": "(canceled)",
"definition": {
"type": "method",
"filePath": "djstripe/managers.py",
"name": "churn",
"ref": "djstripe/managers.py:62",
"definitionRange": {
"startLine": 62,
"startColumn": 4,
"endLine": 66,
"endColumn": 76
},
"language": "python",
"snippet": "def churn(self):\n \"\"\"Return number of canceled Subscriptions divided by active Subscriptions.\"\"\"\n canceled = self.canceled().count()\n active = self.active().count()\n return decimal.Decimal(str(canceled)) / decimal.Decimal(str(active))",
"nameRange": {
"startLine": 62,
"startColumn": 8,
"endLine": 62,
"endColumn": 13
}
}
}
]
},
{
"type": "class",
"filePath": "djstripe/models/identity.py",
"name": "VerificationReport",
"ref": "djstripe/models/identity.py:29",
"definitionRange": {
"startLine": 29,
"startColumn": 0,
"endLine": 40,
"endColumn": 55
},
"language": "python",
"snippet": "class VerificationReport(StripeModel):\n \"\"\"\n Stripe documentation: https://stripe.com/docs/api/identity/verification_reports\n \"\"\"\n\n stripe_class = stripe.identity.VerificationReport\n\n document = JSONField(null=True, blank=True)\n id_number = JSONField(null=True, blank=True)\n options = JSONField(null=True, blank=True)\n selfie = JSONField(null=True, blank=True)\n type = StripeEnumField(enum=enums.VerificationType)",
"nameRange": {
"startLine": 29,
"startColumn": 6,
"endLine": 29,
"endColumn": 24
},
"references": [
{
"type": "from-parsing",
"sourceRef": "djstripe/models/__init__.py:40",
"targetRef": "djstripe/models/identity.py:29",
"sourceSnippetRange": {
"startLine": 40,
"startColumn": 22,
"endLine": 40,
"endColumn": 40
},
"snippet": "VerificationReport"
},
{
"type": "from-parsing",
"sourceRef": "djstripe/models/__init__.py:91",
"targetRef": "djstripe/models/identity.py:29",
"sourceSnippetRange": {
"startLine": 91,
"startColumn": 5,
"endLine": 91,
"endColumn": 23
},
"snippet": "VerificationReport"
}
],
"expressions": [
{
"type": "variable",
"ref": "djstripe/models/identity.py:29",
"range": {
"startLine": 29,
"startColumn": 24,
"endLine": 29,
"endColumn": 37
},
"name": "StripeModel",
"expression": "(StripeModel)",
"definition": {
"type": "class",
"filePath": "djstripe/models/base.py",
"name": "StripeModel",
"ref": "djstripe/models/base.py:88",
"definitionRange": {
"startLine": 88,
"startColumn": 0,
"endLine": 1120,
"endColumn": 32
},
"language": "python",
"snippet": "class StripeModel(StripeBaseModel):\n # This must be defined in descendants of this model/mixin\n # e.g. Event, Charge, Customer, etc.\n expand_fields: List[str] = []\n stripe_dashboard_item_name = \"\"\n\n objects = models.Manager()\n stripe_objects = StripeModelManager()\n\n djstripe_id = models.BigAutoField(\n verbose_name=\"ID\", serialize=False, primary_key=True\n )\n id = StripeIdField(unique=True)\n\n djstripe_owner_account: Optional[StripeForeignKey] = StripeForeignKey(\n \"djstripe.Account\",\n on_delete=models.CASCADE,\n to_field=\"id\",\n null=True,\n blank=True,\n help_text=\"The Stripe Account this object belongs to.\",\n )\n\n livemode = models.BooleanField(\n null=True,\n default=None,\n blank=True,\n help_text=(\n \"Null here indicates that the livemode status is unknown or was previously\"\n \" unrecorded. Otherwise, this field indicates whether this record comes\"\n \" from Stripe test mode or live mode operation.\"\n ),\n )\n created = StripeDateTimeField(\n null=True,\n blank=True,\n help_text=\"The datetime this object was created in stripe.\",\n )\n metadata = JSONField(\n null=True,\n blank=True,\n help_text=(\n \"A set of key/value pairs that you can attach to an object. \"\n \"It can be useful for storing additional information about an object in \"\n \"a structured format.\"\n ),\n )\n description = models.TextField(\n null=True, blank=True, help_text=\"A description of this object.\"\n )\n\n class Meta(StripeBaseModel.Meta):\n abstract = True\n get_latest_by = \"created\"\n\n def _get_base_stripe_dashboard_url(self):\n owner_path_prefix = (\n (self.djstripe_owner_account.id + \"/\")\n if self.djstripe_owner_account\n else \"\"\n )\n suffix = \"test/\" if not self.livemode else \"\"\n return f\"https://dashboard.stripe.com/{owner_path_prefix}{suffix}\"\n\n def get_stripe_dashboard_url(self) -> str:\n \"\"\"Get the stripe dashboard url for this object.\"\"\"\n if not self.stripe_dashboard_item_name or not self.id:\n return \"\"\n else:\n base_url = self._get_base_stripe_dashboard_url()\n item = self.stripe_dashboard_item_name\n return f\"{base_url}{item}/{self.id}\"\n\n @property\n def default_api_key(self) -> str:\n # If the class is abstract (StripeModel), fall back to default key.\n if not self._meta.abstract:\n if self.djstripe_owner_account:\n return self.djstripe_owner_account.get_default_api_key(self.livemode)\n return djstripe_settings.get_default_api_key(self.livemode)\n\n def _get_stripe_account_id(self, api_key=None) -> Optional[str]:\n \"\"\"\n Call the stripe API's retrieve operation for this model.\n\n :param api_key: The api key to use for this request. \\\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n \"\"\"\n from djstripe.models import Account\n\n api_key = api_key or self.default_api_key\n\n try:\n djstripe_owner_account = self.djstripe_owner_account\n if djstripe_owner_account is not None:\n return djstripe_owner_account.id\n except (AttributeError, KeyError, ValueError):\n pass\n\n # Get reverse foreign key relations to Account in case we need to\n # retrieve ourselves using that Account ID.\n reverse_account_relations = (\n field\n for field in self._meta.get_fields(include_parents=True)\n if field.is_relation\n and field.one_to_many\n and field.related_model is Account\n )\n\n # Handle case where we have a reverse relation to Account and should pass\n # that account ID to the retrieve call.\n for field in reverse_account_relations:\n # Grab the related object, using the first one we find.\n reverse_lookup_attr = field.get_accessor_name()\n try:\n account = getattr(self, reverse_lookup_attr).first()\n except ValueError:\n if isinstance(self, Account):\n # return the id if self is the Account model itself.\n return self.id\n else:\n if account is not None:\n return account.id\n\n return None\n\n def api_retrieve(self, api_key=None, stripe_account=None):\n \"\"\"\n Call the stripe API's retrieve operation for this model.\n\n :param api_key: The api key to use for this request. \\\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n \"\"\"\n api_key = api_key or self.default_api_key\n\n # Prefer passed in stripe_account if set.\n if not stripe_account:\n stripe_account = self._get_stripe_account_id(api_key)\n\n return self.stripe_class.retrieve(\n id=self.id,\n api_key=api_key,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n expand=self.expand_fields,\n stripe_account=stripe_account,\n )\n\n @classmethod\n def _api_create(cls, api_key=djstripe_settings.STRIPE_SECRET_KEY, **kwargs):\n \"\"\"\n Call the stripe API's create operation for this model.\n\n :param api_key: The api key to use for this request. \\\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n \"\"\"\n\n return cls.stripe_class.create(\n api_key=api_key,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n **kwargs,\n )\n\n def _api_delete(self, api_key=None, stripe_account=None, **kwargs):\n \"\"\"\n Call the stripe API's delete operation for this model\n\n :param api_key: The api key to use for this request. \\\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n \"\"\"\n api_key = api_key or self.default_api_key\n\n # Prefer passed in stripe_account if set.\n if not stripe_account:\n stripe_account = self._get_stripe_account_id(api_key)\n\n return self.stripe_class.delete(\n self.id,\n api_key=api_key,\n stripe_account=stripe_account,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n **kwargs,\n )\n\n def _api_update(self, api_key=None, stripe_account=None, **kwargs):\n \"\"\"\n Call the stripe API's modify operation for this model\n\n :param api_key: The api key to use for this request.\n Defaults to djstripe_settings.STRIPE_SECRET_KEY.\n :type api_key: string\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n \"\"\"\n api_key = api_key or self.default_api_key\n\n # Prefer passed in stripe_account if set.\n if not stripe_account:\n stripe_account = self._get_stripe_account_id(api_key)\n\n return self.stripe_class.modify(\n self.id,\n api_key=api_key,\n stripe_account=stripe_account,\n stripe_version=djstripe_settings.STRIPE_API_VERSION,\n **kwargs,\n )\n\n @classmethod\n def _manipulate_stripe_object_hook(cls, data):\n \"\"\"\n Gets called by this object's stripe object conversion method just before\n conversion.\n Use this to populate custom fields in a StripeModel from stripe data.\n \"\"\"\n return data\n\n @classmethod\n def _find_owner_account(cls, data, api_key=djstripe_settings.STRIPE_SECRET_KEY):\n \"\"\"\n Fetches the Stripe Account (djstripe_owner_account model field)\n linked to the class, cls.\n Tries to retreive using the Stripe_account if given.\n Otherwise uses the api_key.\n \"\"\"\n from .account import Account\n\n # try to fetch by stripe_account. Also takes care of Stripe Connected Accounts\n if data:\n # case of Webhook Event Trigger\n if data.get(\"object\") == \"event\":\n # if account key exists and has a not null value\n stripe_account_id = get_id_from_stripe_data(data.get(\"account\"))\n if stripe_account_id:\n return Account._get_or_retrieve(\n id=stripe_account_id, api_key=api_key\n )\n\n else:\n stripe_account = getattr(data, \"stripe_account\", None)\n stripe_account_id = get_id_from_stripe_data(stripe_account)\n if stripe_account_id:\n return Account._get_or_retrieve(\n id=stripe_account_id, api_key=api_key\n )\n\n # try to fetch by the given api_key.\n return Account.get_or_retrieve_for_api_key(api_key)\n\n @classmethod\n def _stripe_object_to_record(\n cls,\n data: dict,\n current_ids=None,\n pending_relations: list = None,\n stripe_account: str = None,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n ) -> Dict:\n \"\"\"\n This takes an object, as it is formatted in Stripe's current API for our object\n type. In return, it provides a dict. The dict can be used to create a record or\n to update a record\n\n This function takes care of mapping from one field name to another, converting\n from cents to dollars, converting timestamps, and eliminating unused fields\n (so that an objects.create() call would not fail).\n\n :param data: the object, as sent by Stripe. Parsed from JSON, into a dict\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n :param pending_relations: list of tuples of relations to be attached post-save\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :return: All the members from the input, translated, mutated, etc\n \"\"\"\n from .webhooks import WebhookEndpoint\n\n manipulated_data = cls._manipulate_stripe_object_hook(data)\n if not cls.is_valid_object(manipulated_data):\n raise ValueError(\n \"Trying to fit a %r into %r. Aborting.\"\n % (manipulated_data.get(\"object\", \"\"), cls.__name__)\n )\n\n # By default we put the raw stripe data in the stripe_data json field\n result = {\"stripe_data\": data}\n\n if current_ids is None:\n current_ids = set()\n\n # Iterate over all the fields that we know are related to Stripe,\n # let each field work its own magic\n ignore_fields = [\n \"date_purged\",\n \"subscriber\",\n \"stripe_data\",\n ] # XXX: Customer hack\n\n # get all forward and reverse relations for given cls\n for field in cls._meta.get_fields():\n if field.name.startswith(\"djstripe_\") or field.name in ignore_fields:\n continue\n\n # todo add support reverse ManyToManyField sync\n if isinstance(\n field, (models.ManyToManyRel, models.ManyToOneRel)\n ) and not isinstance(field, models.OneToOneRel):\n # We don't currently support syncing from\n # reverse side of Many relationship\n continue\n\n # todo for ManyToManyField one would also need to handle the case of an intermediate model being used\n # todo add support ManyToManyField sync\n if field.many_to_many:\n # We don't currently support syncing ManyToManyField\n continue\n\n # will work for Forward FK and OneToOneField relations and reverse OneToOneField relations\n if isinstance(field, (models.ForeignKey, models.OneToOneRel)):\n field_data, skip, is_nulled = cls._stripe_object_field_to_foreign_key(\n field=field,\n manipulated_data=manipulated_data,\n current_ids=current_ids,\n pending_relations=pending_relations,\n stripe_account=stripe_account,\n api_key=api_key,\n )\n\n if skip and not is_nulled:\n continue\n else:\n if hasattr(field, \"stripe_to_db\"):\n field_data = field.stripe_to_db(manipulated_data)\n else:\n field_data = manipulated_data.get(field.name)\n\n if (\n isinstance(field, (models.CharField, models.TextField))\n and field_data is None\n ):\n # do not add empty secret field for WebhookEndpoint model\n # as stripe does not return the secret except for the CREATE call\n if cls is WebhookEndpoint and field.name == \"secret\":\n continue\n else:\n # TODO - this applies to StripeEnumField as well, since it\n # sub-classes CharField, is that intentional?\n field_data = \"\"\n\n result[field.name] = field_data\n\n # For all objects other than the account object itself, get the API key\n # attached to the request, and get the matching Account for that key.\n owner_account = cls._find_owner_account(data, api_key=api_key)\n if owner_account:\n result[\"djstripe_owner_account\"] = owner_account\n\n return result\n\n @classmethod\n def _stripe_object_field_to_foreign_key(\n cls,\n field,\n manipulated_data,\n current_ids=None,\n pending_relations=None,\n stripe_account=None,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n ):\n \"\"\"\n This converts a stripe API field to the dj stripe object it references,\n so that foreign keys can be connected up automatically.\n\n :param field:\n :type field: models.ForeignKey\n :param manipulated_data:\n :type manipulated_data: dict\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n :param pending_relations: list of tuples of relations to be attached post-save\n :type pending_relations: list\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n :return:\n \"\"\"\n from djstripe.models import DjstripePaymentMethod\n\n field_data = None\n field_name = field.name\n refetch = False\n skip = False\n # a flag to indicate if the given field is null upstream on Stripe\n is_nulled = False\n\n if current_ids is None:\n current_ids = set()\n\n if issubclass(field.related_model, (StripeModel, DjstripePaymentMethod)):\n if field_name in manipulated_data:\n raw_field_data = manipulated_data.get(field_name)\n\n # field's value is None. Skip syncing but set as None.\n # Otherwise nulled FKs sync gets skipped.\n if not raw_field_data:\n is_nulled = True\n skip = True\n\n else:\n # field does not exist in manipulated_data dict. Skip Syncing\n skip = True\n raw_field_data = None\n\n id_ = get_id_from_stripe_data(raw_field_data)\n\n if id_ == raw_field_data:\n # A field like {\"subscription\": \"sub_6lsC8pt7IcFpjA\", ...}\n refetch = True\n else:\n # A field like {\"subscription\": {\"id\": sub_6lsC8pt7IcFpjA\", ...}}\n pass\n\n if id_ in current_ids:\n # this object is currently being fetched, don't try to fetch again,\n # to avoid recursion instead, record the relation that should be\n # created once \"object_id\" object exists\n if pending_relations is not None:\n object_id = manipulated_data[\"id\"]\n pending_relations.append((object_id, field, id_))\n skip = True\n\n # sync only if field exists and is not null\n if not skip and not is_nulled:\n # add the id of the current object to the list\n # of ids being processed.\n # This will avoid infinite recursive syncs in case a relatedmodel\n # requests the same object\n current_ids.add(id_)\n\n try:\n (\n field_data,\n _,\n ) = field.related_model._get_or_create_from_stripe_object(\n manipulated_data,\n field_name,\n refetch=refetch,\n current_ids=current_ids,\n pending_relations=pending_relations,\n stripe_account=stripe_account,\n api_key=api_key,\n )\n except ImpossibleAPIRequest:\n # Found to happen in the following situation:\n # Customer has a `default_source` set to a `card_` object,\n # and neither the Customer nor the Card are present in db.\n # This skip is a hack, but it will prevent a crash.\n skip = True\n\n # Remove the id of the current object from the list\n # after it has been created or retrieved\n current_ids.remove(id_)\n\n else:\n # eg PaymentMethod, handled in hooks\n skip = True\n\n return field_data, skip, is_nulled\n\n @classmethod\n def is_valid_object(cls, data):\n \"\"\"\n Returns whether the data is a valid object for the class\n \"\"\"\n # .OBJECT_NAME will not exist on the base type itself\n object_name: str = getattr(cls.stripe_class, \"OBJECT_NAME\", \"\")\n if not object_name:\n return False\n return data and data.get(\"object\") == object_name\n\n def _attach_objects_hook(\n self, cls, data, api_key=djstripe_settings.STRIPE_SECRET_KEY, current_ids=None\n ):\n \"\"\"\n Gets called by this object's create and sync methods just before save.\n Use this to populate fields before the model is saved.\n\n :param cls: The target class for the instantiated object.\n :param data: The data dictionary received from the Stripe API.\n :type data: dict\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n \"\"\"\n\n pass\n\n def _attach_objects_post_save_hook(\n self,\n cls,\n data,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n pending_relations=None,\n ):\n \"\"\"\n Gets called by this object's create and sync methods just after save.\n Use this to populate fields after the model is saved.\n\n :param cls: The target class for the instantiated object.\n :param data: The data dictionary received from the Stripe API.\n :type data: dict\n \"\"\"\n\n unprocessed_pending_relations = []\n if pending_relations is not None:\n for post_save_relation in pending_relations:\n object_id, field, id_ = post_save_relation\n\n if self.id == id_:\n # the target instance now exists\n target = field.model.objects.get(id=object_id)\n setattr(target, field.name, self)\n if isinstance(field, models.OneToOneRel):\n # this is a reverse relationship, so the relation exists on self\n self.save()\n else:\n # this is a forward relation on the target,\n # so we need to save it\n target.save()\n\n # reload so that indirect relations back to this object\n # eg self.charge.invoice = self are set\n # TODO - reverse the field reference here to avoid hitting the DB?\n self.refresh_from_db()\n else:\n unprocessed_pending_relations.append(post_save_relation)\n\n if len(pending_relations) != len(unprocessed_pending_relations):\n # replace in place so passed in list is updated in calling method\n pending_relations[:] = unprocessed_pending_relations\n\n @classmethod\n def _create_from_stripe_object(\n cls,\n data,\n current_ids=None,\n pending_relations=None,\n save=True,\n stripe_account=None,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n ):\n \"\"\"\n Instantiates a model instance using the provided data object received\n from Stripe, and saves it to the database if specified.\n\n :param data: The data dictionary received from the Stripe API.\n :type data: dict\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n :param pending_relations: list of tuples of relations to be attached post-save\n :type pending_relations: list\n :param save: If True, the object is saved after instantiation.\n :type save: bool\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n :returns: The instantiated object.\n \"\"\"\n stripe_data = cls._stripe_object_to_record(\n data,\n current_ids=current_ids,\n pending_relations=pending_relations,\n stripe_account=stripe_account,\n api_key=api_key,\n )\n try:\n id_ = get_id_from_stripe_data(stripe_data)\n if id_ is not None:\n instance = cls.stripe_objects.get(id=id_)\n else:\n # Raise error on purpose to resume the _create_from_stripe_object flow\n raise cls.DoesNotExist\n\n except cls.DoesNotExist:\n # try to create iff instance doesn't already exist in the DB\n # TODO dictionary unpacking will not work if cls has any ManyToManyField\n instance = cls(**stripe_data)\n\n instance._attach_objects_hook(\n cls, data, api_key=api_key, current_ids=current_ids\n )\n\n if save:\n instance.save()\n\n instance._attach_objects_post_save_hook(\n cls, data, api_key=api_key, pending_relations=pending_relations\n )\n\n return instance\n\n @classmethod\n def _get_or_create_from_stripe_object(\n cls,\n data,\n field_name=\"id\",\n refetch=True,\n current_ids=None,\n pending_relations=None,\n save=True,\n stripe_account=None,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n ):\n \"\"\"\n\n :param data:\n :param field_name:\n :param refetch:\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n :param pending_relations: list of tuples of relations to be attached post-save\n :type pending_relations: list\n :param save:\n :param stripe_account: The optional connected account \\\n for which this request is being made.\n :type stripe_account: string\n :return:\n :rtype: cls, bool\n \"\"\"\n field = data.get(field_name)\n is_nested_data = field_name != \"id\"\n should_expand = False\n if not stripe_account and isinstance(data, StripeObject):\n stripe_account = data.stripe_account\n if pending_relations is None:\n pending_relations = []\n\n id_ = get_id_from_stripe_data(field)\n\n if not field:\n # An empty field - We need to return nothing here because there is\n # no way of knowing what needs to be fetched!\n raise RuntimeError(\n f\"dj-stripe encountered an empty field {cls.__name__}.{field_name} =\"\n f\" {field}\"\n )\n elif id_ == field:\n # A field like {\"subscription\": \"sub_6lsC8pt7IcFpjA\", ...}\n # We'll have to expand if the field is not \"id\" (= is nested)\n should_expand = is_nested_data\n else:\n # A field like {\"subscription\": {\"id\": sub_6lsC8pt7IcFpjA\", ...}}\n data = field\n\n try:\n return cls.stripe_objects.get(id=id_), False\n except cls.DoesNotExist:\n if is_nested_data and refetch:\n # This is what `data` usually looks like:\n # {\"id\": \"cus_XXXX\", \"default_source\": \"card_XXXX\"}\n # Leaving the default field_name (\"id\") will get_or_create the customer.\n # If field_name=\"default_source\", we get_or_create the card instead.\n cls_instance = cls(id=id_)\n try:\n data = cls_instance.api_retrieve(\n stripe_account=stripe_account, api_key=api_key\n )\n except InvalidRequestError as e:\n if \"a similar object exists in\" in str(e):\n # HACK around a Stripe bug.\n # When a File is retrieved from the Account object,\n # a mismatch between live and test mode is possible depending\n # on whether the file (usually the logo) was uploaded in live\n # or test. Reported to Stripe in August 2020.\n # Context: https://github.com/dj-stripe/dj-stripe/issues/830\n pass\n elif \"No such PaymentMethod:\" in str(e):\n # payment methods (card_… etc) can be irretrievably deleted,\n # but still present during sync. For example, if a refund is\n # issued on a charge whose payment method has been deleted.\n return None, False\n elif \"Invalid subscription_item id\" in str(e):\n # subscription items can be irretrievably deleted but still\n # be present during sync. For example, if a line item of type subscription is\n # removed from the subscription, the invoice generated for that billing period\n # will still contain the deleted subscription_item.\n return None, False\n else:\n raise\n should_expand = False\n\n # The next thing to happen will be the \"create from stripe object\" call.\n # At this point, if we don't have data to start with (field is a str),\n # *and* we didn't refetch by id, then `should_expand` is True and we\n # don't have the data to actually create the object.\n # If this happens when syncing Stripe data, it's a djstripe bug. Report it!\n if should_expand:\n raise ValueError(f\"No data to create {cls.__name__} from {field_name}\")\n\n try:\n # We wrap the `_create_from_stripe_object` in a transaction to\n # avoid TransactionManagementError on subsequent queries in case\n # of the IntegrityError catch below. See PR #903\n with transaction.atomic():\n return (\n cls._create_from_stripe_object(\n data,\n current_ids=current_ids,\n pending_relations=pending_relations,\n save=save,\n stripe_account=stripe_account,\n api_key=api_key,\n ),\n True,\n )\n except IntegrityError:\n # Handle the race condition that something else created the object\n # after the `get` and before `_create_from_stripe_object`.\n # This is common during webhook handling, since Stripe sends\n # multiple webhook events simultaneously,\n # each of which will cause recursive syncs. See issue #429\n return cls.stripe_objects.get(id=id_), False\n\n @classmethod\n def _stripe_object_to_customer(\n cls,\n target_cls,\n data,\n api_key=djstripe_settings.STRIPE_SECRET_KEY,\n current_ids=None,\n ):\n \"\"\"\n Search the given manager for the Customer matching this object's\n ``customer`` field.\n :param target_cls: The target class\n :type target_cls: Customer\n :param data: stripe object\n :type data: dict\n :param current_ids: stripe ids of objects that are currently being processed\n :type current_ids: set\n \"\"\"\n\n if \"customer\" in data and data[\"customer\"]:\n return target_cls._get_or_create_from_stripe_object(\n data, \"customer\", current_ids=current_ids, api_key=api_key\n )[0]\n\n @classmethod\n def _stripe_object_to_default_tax_rates(\n cls, target_cls, data, api_key=djstripe_settings.STRIPE_SECRET_KEY\n ):\n \"\"\"\n Retrieves TaxRates for a Subscription or Invoice\n :param target_cls:\n :param data:\n :param instance:\n :type instance: Union[djstripe.models.Invoice, djstripe.models.Subscription]\n :return:\n \"\"\"\n tax_rates = []\n\n for tax_rate_data in data.get(\"default_tax_rates\", []):\n tax_rate, _ = target_cls._get_or_create_from_stripe_object(\n tax_rate_data, refetch=False, api_key=api_key\n )\n tax_rates.append(tax_rate)\n\n return tax_rates\n\n @classmethod\n def _stripe_object_to_tax_rates(\n cls, target_cls, data, api_key=djstripe_settings.STRIPE_SECRET_KEY\n ):\n \"\"\"\n Retrieves TaxRates for a SubscriptionItem or InvoiceItem\n :param target_cls:\n :param data:\n :return:\n \"\"\"\n tax_rates = []\n\n for tax_rate_data in data.get(\"tax_rates\", []):\n tax_rate, _ = target_cls._get_or_create_from_stripe_object(\n tax_rate_data, refetch=False, api_key=api_key\n )\n tax_rates.append(tax_rate)\n\n return tax_rates\n\n @classmethod\n def _stripe_object_set_total_tax_amounts(\n cls, target_cls, data, instance, api_key=djstripe_settings.STRIPE_SECRET_KEY\n ):\n \"\"\"\n Set total tax amounts on Invoice instance\n :param target_cls:\n :param data:\n :param instance:\n :type instance: djstripe.models.Invoice\n :return:\n \"\"\"\n from .billing import TaxRate\n\n pks = []\n\n for tax_amount_data in data.get(\"total_tax_amounts\", []):\n tax_rate_data = tax_amount_data[\"tax_rate\"]\n if isinstance(tax_rate_data, str):\n tax_rate_data = {\"tax_rate\": tax_rate_data}\n\n tax_rate, _ = TaxRate._get_or_create_from_stripe_object(\n tax_rate_data,\n field_name=\"tax_rate\",\n refetch=True,\n api_key=api_key,\n )\n tax_amount, _ = target_cls.objects.update_or_create(\n invoice=instance,\n tax_rate=tax_rate,\n defaults={\n \"amount\": tax_amount_data[\"amount\"],\n \"inclusive\": tax_amount_data[\"inclusive\"],\n },\n )\n\n pks.append(tax_amount.pk)\n\n instance.total_tax_amounts.exclude(pk__in=pks).delete()\n\n @classmethod\n def _stripe_object_to_line_items(\n cls, target_cls, data, invoice, api_key=djstripe_settings.STRIPE_SECRET_KEY\n ):\n \"\"\"\n Retrieves LineItems for an invoice.\n\n If the line item doesn't exist already then it is created.\n\n If the invoice is an upcoming invoice that doesn't persist to the\n database (i.e. ephemeral) then the line items are also not saved.\n\n :param target_cls: The target class to instantiate per line item.\n :type target_cls: Type[djstripe.models.LineItem]\n :param data: The data dictionary received from the Stripe API.\n :type data: dict\n :param in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment