14
14
15
15
"""Exceptions used in the google.auth package."""
16
16
17
+ from typing import Any , Optional
18
+
17
19
18
20
class GoogleAuthError (Exception ):
19
- """Base class for all google.auth errors."""
21
+ """Base class for all google.auth errors.
22
+
23
+ Args:
24
+ retryable (bool): Indicates whether the error is retryable.
25
+ """
20
26
21
- def __init__ (self , * args , ** kwargs ):
22
- super (GoogleAuthError , self ).__init__ (* args )
23
- retryable = kwargs .get ("retryable" , False )
24
- self ._retryable = retryable
27
+ def __init__ (self , * args : Any , ** kwargs : Any ) -> None :
28
+ super ().__init__ (* args )
29
+ self ._retryable : bool = kwargs .get ("retryable" , False )
25
30
26
31
@property
27
- def retryable (self ):
32
+ def retryable (self ) -> bool :
33
+ """Indicates whether the error is retryable."""
28
34
return self ._retryable
29
35
30
36
@@ -33,8 +39,7 @@ class TransportError(GoogleAuthError):
33
39
34
40
35
41
class RefreshError (GoogleAuthError ):
36
- """Used to indicate that an refreshing the credentials' access token
37
- failed."""
42
+ """Used to indicate that refreshing the credentials' access token failed."""
38
43
39
44
40
45
class UserAccessTokenError (GoogleAuthError ):
@@ -46,30 +51,37 @@ class DefaultCredentialsError(GoogleAuthError):
46
51
47
52
48
53
class MutualTLSChannelError (GoogleAuthError ):
49
- """Used to indicate that mutual TLS channel creation is failed, or mutual
50
- TLS channel credentials is missing or invalid."""
54
+ """Used to indicate that mutual TLS channel creation failed, or mutual
55
+ TLS channel credentials are missing or invalid."""
56
+
57
+ @property
58
+ def retryable (self ) -> bool :
59
+ """Overrides retryable to always return False for this error."""
60
+ return False
51
61
52
62
53
63
class ClientCertError (GoogleAuthError ):
54
64
"""Used to indicate that client certificate is missing or invalid."""
55
65
56
66
@property
57
- def retryable (self ):
67
+ def retryable (self ) -> bool :
68
+ """Overrides retryable to always return False for this error."""
58
69
return False
59
70
60
71
61
72
class OAuthError (GoogleAuthError ):
62
- """Used to indicate an error occurred during an OAuth related HTTP
63
- request."""
73
+ """Used to indicate an error occurred during an OAuth-related HTTP request."""
64
74
65
75
66
76
class ReauthFailError (RefreshError ):
67
- """An exception for when reauth failed."""
77
+ """An exception for when reauth failed.
78
+
79
+ Args:
80
+ message (str): Detailed error message.
81
+ """
68
82
69
- def __init__ (self , message = None , ** kwargs ):
70
- super (ReauthFailError , self ).__init__ (
71
- "Reauthentication failed. {0}" .format (message ), ** kwargs
72
- )
83
+ def __init__ (self , message : Optional [str ] = None , ** kwargs : Any ) -> None :
84
+ super ().__init__ (f"Reauthentication failed. { message } " , ** kwargs )
73
85
74
86
75
87
class ReauthSamlChallengeFailError (ReauthFailError ):
@@ -97,7 +109,7 @@ class InvalidType(DefaultCredentialsError, TypeError):
97
109
98
110
99
111
class OSError (DefaultCredentialsError , EnvironmentError ):
100
- """Used to wrap EnvironmentError(OSError after python3 .3)."""
112
+ """Used to wrap EnvironmentError (OSError after Python 3 .3)."""
101
113
102
114
103
115
class TimeoutError (GoogleAuthError ):
0 commit comments