diff --git a/.pylintrc b/.pylintrc index e050c18..2c39a26 100644 --- a/.pylintrc +++ b/.pylintrc @@ -3,4 +3,4 @@ max-line-length=88 good-names=i,x1,x2,y1,y2 [MESSAGES CONTROL] -disable=missing-docstring,too-many-ancestors,too-few-public-methods,no-else-return,no-member,attribute-defined-outside-init,similarities,import-outside-toplevel,cyclic-import,no-member,no-else-raise,too-many-instance-attributes,too-many-arguments,ungrouped-imports,useless-object-inheritance,no-else-continue +disable=W1201,W1202,W1203,missing-docstring,too-many-ancestors,too-few-public-methods,no-else-return,no-member,attribute-defined-outside-init,similarities,import-outside-toplevel,cyclic-import,no-member,no-else-raise,too-many-instance-attributes,too-many-arguments,ungrouped-imports,useless-object-inheritance,no-else-continue diff --git a/documentcloud/addon.py b/documentcloud/addon.py index 4798ea5..65a6dc2 100644 --- a/documentcloud/addon.py +++ b/documentcloud/addon.py @@ -65,7 +65,7 @@ def _create_client(self, args): self.client.refresh_token = args["refresh_token"] if args["token"] is not None: self.client.session.headers.update( - {"Authorization": "Bearer {}".format(args["token"])} + {"Authorization": f"Bearer {args['token']}"} ) # custom user agent for AddOns diff --git a/documentcloud/base.py b/documentcloud/base.py index ed6eae3..2ba5fba 100644 --- a/documentcloud/base.py +++ b/documentcloud/base.py @@ -98,9 +98,7 @@ def get(self, id_, expand=None): params = {"expand": ",".join(expand)} else: params = {} - response = self.client.get( - "{}/{}/".format(self.api_path, get_id(id_)), params=params - ) + response = self.client.get(f"{self.api_path}/{get_id(id_)}/", params=params) # pylint: disable=not-callable return self.resource(self.client, response.json()) diff --git a/documentcloud/documents.py b/documentcloud/documents.py index 9202e74..17743dd 100644 --- a/documentcloud/documents.py +++ b/documentcloud/documents.py @@ -187,7 +187,10 @@ def get_page_text_url(self, page=1): return f"{self.asset_url}documents/{self.id}/pages/{self.slug}-p{page}.txt" def get_page_position_json_url(self, page=1): - return f"{self.asset_url}documents/{self.id}/pages/{self.slug}-p{page}.position.json" + return ( + f"{self.asset_url}documents/{self.id}/pages/" + f"{self.slug}-p{page}.position.json" + ) def get_json_text_url(self): return f"{self.asset_url}documents/{self.id}/{self.slug}.txt.json" @@ -375,7 +378,7 @@ def upload_directory(self, path, handle_errors=False, extensions=".pdf", **kwarg # Do not set the same title for all documents kwargs.pop("title", None) - # If extensions are specified as None, it will check for all supported filetypes. + # If extensions are specified as None, check for all supported filetypes. if extensions is None: extensions = SUPPORTED_EXTENSIONS diff --git a/documentcloud/projects.py b/documentcloud/projects.py index 09790aa..739f23b 100644 --- a/documentcloud/projects.py +++ b/documentcloud/projects.py @@ -99,18 +99,17 @@ class ProjectClient(BaseAPIClient): def all(self, **params): return self.list(user=self.client.user_id, **params) - def get(self, id=None, title=None): - # pylint:disable=redefined-builtin, arguments-differ + def get(self, id_=None, title=None): # pylint:disable=arguments-renamed # pylint disables are necessary for backward compatibility - if id is not None and title is not None: + if id_ is not None and title is not None: raise ValueError( "You can only retrieve a Project by id or title, not by both" ) - elif id is None and title is None: + elif id_ is None and title is None: raise ValueError("You must provide an id or a title to make a request.") - if id is not None: - return self.get_by_id(id) + if id_ is not None: + return self.get_by_id(id_) else: return self.get_by_title(title) diff --git a/documentcloud/toolbox.py b/documentcloud/toolbox.py index e2c264f..62e7c30 100644 --- a/documentcloud/toolbox.py +++ b/documentcloud/toolbox.py @@ -3,11 +3,11 @@ """ # Third Party +from urllib.parse import urlparse +from itertools import zip_longest import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry -from urllib.parse import urlparse -from itertools import zip_longest def requests_retry_session(