|
| 1 | +import dataclasses |
1 | 2 | import sys |
2 | | -from typing import Any, Final, List, Tuple, Union, Dict |
| 3 | +from typing import Any, ClassVar, Final, List, Tuple, Union, Dict |
3 | 4 |
|
4 | 5 | from dlt.common import json, pendulum |
5 | 6 | from dlt.common.configuration.specs.api_credentials import OAuth2Credentials |
|
22 | 23 |
|
23 | 24 | @configspec |
24 | 25 | class GcpCredentials(CredentialsConfiguration): |
25 | | - token_uri: Final[str] = "https://oauth2.googleapis.com/token" |
26 | | - auth_uri: Final[str] = "https://accounts.google.com/o/oauth2/auth" |
| 26 | + token_uri: Final[str] = dataclasses.field( |
| 27 | + default="https://oauth2.googleapis.com/token", init=False, repr=False, compare=False |
| 28 | + ) |
| 29 | + auth_uri: Final[str] = dataclasses.field( |
| 30 | + default="https://accounts.google.com/o/oauth2/auth", init=False, repr=False, compare=False |
| 31 | + ) |
27 | 32 |
|
28 | 33 | project_id: str = None |
29 | 34 |
|
@@ -69,7 +74,9 @@ def to_gcs_credentials(self) -> Dict[str, Any]: |
69 | 74 | class GcpServiceAccountCredentialsWithoutDefaults(GcpCredentials): |
70 | 75 | private_key: TSecretValue = None |
71 | 76 | client_email: str = None |
72 | | - type: Final[str] = "service_account" # noqa: A003 |
| 77 | + type: Final[str] = dataclasses.field( # noqa: A003 |
| 78 | + default="service_account", init=False, repr=False, compare=False |
| 79 | + ) |
73 | 80 |
|
74 | 81 | def parse_native_representation(self, native_value: Any) -> None: |
75 | 82 | """Accepts ServiceAccountCredentials as native value. In other case reverts to serialized services.json""" |
@@ -121,8 +128,10 @@ def __str__(self) -> str: |
121 | 128 | @configspec |
122 | 129 | class GcpOAuthCredentialsWithoutDefaults(GcpCredentials, OAuth2Credentials): |
123 | 130 | # only desktop app supported |
124 | | - refresh_token: TSecretValue |
125 | | - client_type: Final[str] = "installed" |
| 131 | + refresh_token: TSecretValue = None |
| 132 | + client_type: Final[str] = dataclasses.field( |
| 133 | + default="installed", init=False, repr=False, compare=False |
| 134 | + ) |
126 | 135 |
|
127 | 136 | def parse_native_representation(self, native_value: Any) -> None: |
128 | 137 | """Accepts Google OAuth2 credentials as native value. In other case reverts to serialized oauth client secret json""" |
@@ -237,7 +246,7 @@ def __str__(self) -> str: |
237 | 246 |
|
238 | 247 | @configspec |
239 | 248 | class GcpDefaultCredentials(CredentialsWithDefault, GcpCredentials): |
240 | | - _LAST_FAILED_DEFAULT: float = 0.0 |
| 249 | + _LAST_FAILED_DEFAULT: ClassVar[float] = 0.0 |
241 | 250 |
|
242 | 251 | def parse_native_representation(self, native_value: Any) -> None: |
243 | 252 | """Accepts google credentials as native value""" |
|
0 commit comments