@@ -19,14 +19,13 @@ def __init__(self, token: str | None = None, base_uri: str | None = None):
19
19
"""Create a new client object."""
20
20
self .BASE_URI = base_uri or BaseMuckRockClient .BASE_URI
21
21
if token :
22
- self .token = token
22
+ self .token : str | None = token
23
23
else :
24
- if os .getenv ("MUCKROCK_API_TOKEN" ):
25
- self .token = os .getenv ("MUCKROCK_API_TOKEN" )
26
- else :
27
- self .token = None
24
+ self .token = os .getenv ("MUCKROCK_API_TOKEN" ) or None
28
25
29
- def _get_request (self , url : str , params : dict | None = None , headers : dict | None = None ) -> Any :
26
+ def _get_request (
27
+ self , url : str , params : dict | None = None , headers : dict | None = None
28
+ ) -> Any :
30
29
"""Make a GET request to the Muckrock API.
31
30
32
31
Returns the response as JSON.
@@ -50,7 +49,9 @@ def _get_request(self, url: str, params: dict | None = None, headers: dict | Non
50
49
)
51
50
return response .json ()
52
51
53
- def _post_request (self , url : str , data : dict | None = None , headers : dict | None = None ) -> Any :
52
+ def _post_request (
53
+ self , url : str , data : dict | None = None , headers : dict | None = None
54
+ ) -> Any :
54
55
"""Make a GET request to the Muckrock API.
55
56
56
57
Returns the response as JSON.
@@ -84,7 +85,13 @@ def _post_request(self, url: str, data: dict | None = None, headers: dict | None
84
85
class MuckRock (BaseMuckRockClient ):
85
86
"""The public interface for the DocumentCloud API."""
86
87
87
- def __init__ (self , username : str | None = None , password : str | None = None , token : str | None = None , base_uri : str | None = None ):
88
+ def __init__ (
89
+ self ,
90
+ username : str | None = None ,
91
+ password : str | None = None ,
92
+ token : str | None = None ,
93
+ base_uri : str | None = None ,
94
+ ):
88
95
"""Create an object."""
89
96
# Set all the basic configuration options to this, the parent instance.
90
97
super ().__init__ (token , base_uri )
@@ -99,7 +106,7 @@ def __init__(self, username: str | None = None, password: str | None = None, tok
99
106
class BaseEndpointMixin :
100
107
"""Methods shared by endpoint classes."""
101
108
102
- def get (self , id : str | int ):
109
+ def get (self , id ):
103
110
"""Return a request with the specified identifer."""
104
111
url = self .BASE_URI + self .endpoint + f"/{ id } /"
105
112
r = self ._get_request (url )
@@ -122,7 +129,7 @@ def filter(
122
129
requires_proxy : bool | None = None ,
123
130
) -> Any :
124
131
"""Return a list of requests that match the provide input filters."""
125
- params = {}
132
+ params : dict [ str , Any ] = {}
126
133
if name :
127
134
params ["name" ] = name
128
135
if abbreviation :
@@ -146,9 +153,15 @@ class AgencyEndpoint(BaseMuckRockClient, BaseEndpointMixin):
146
153
147
154
endpoint = "agency"
148
155
149
- def filter (self , name : str | None = None , status : str | None = None , jurisdiction_id : str | int | None = None , requires_proxy : bool | None = None ) -> Any :
156
+ def filter (
157
+ self ,
158
+ name : str | None = None ,
159
+ status : str | None = None ,
160
+ jurisdiction_id : str | int | None = None ,
161
+ requires_proxy : bool | None = None ,
162
+ ) -> Any :
150
163
"""Return a list of requests that match the provide input filters."""
151
- params = {}
164
+ params : dict [ str , Any ] = {}
152
165
if name :
153
166
params ["name" ] = name
154
167
if status :
@@ -214,10 +227,10 @@ def filter(
214
227
agency_id : str | int | None = None ,
215
228
has_datetime_submitted : bool | None = None ,
216
229
has_datetime_done : bool | None = None ,
217
- ordering : str = "-datetime_submitted" ,
230
+ ordering : str = "-datetime_submitted" ,
218
231
) -> Any :
219
232
"""Return a list of requests that match the provide input filters."""
220
- params = {}
233
+ params : dict [ str , Any ] = {}
221
234
if user :
222
235
params ["user" ] = user
223
236
if title :
0 commit comments