Fixing flake8 errors.

This commit is contained in:
Cassowary Rusnov 2021-11-22 10:35:44 -08:00
parent d35a35f6ad
commit b0e8bb1307
3 changed files with 22 additions and 7 deletions

View File

@ -6,12 +6,11 @@ import logging
from typing import List, Optional, Dict, Union from typing import List, Optional, Dict, Union
from bs4 import BeautifulSoup
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
#
# TODOs and FIXMEs # TODOs and FIXMEs
# #
# * come up with a better way to specify `where` clauses. # * come up with a better way to specify `where` clauses.
@ -75,7 +74,7 @@ class APIv4:
""" """
self.session = requests.Session() self.session = requests.Session()
### Perform login post # Perform login post
self.session.cookies.update({"has_js": "1"}) self.session.cookies.update({"has_js": "1"})
postdata = { postdata = {
"name": user, "name": user,
@ -118,7 +117,7 @@ class APIv4:
url = self.api_url+'/'+objName+'/'+action url = self.api_url+'/'+objName+'/'+action
if params: if params:
result = self.session.post(url, params={'params':json.dumps(params)}, data="") result = self.session.post(url, params={'params': json.dumps(params)}, data="")
else: else:
result = self.session.post(url, data="") result = self.session.post(url, data="")
if (not result.ok): if (not result.ok):
@ -188,7 +187,11 @@ class APIv4:
return [x["name"] for x in ent] return [x["name"] for x in ent]
def get(self, objName: str, where: Optional[List]=None, limit: Optional[int]=None, select=Optional[List[str]]) -> List: def get(self,
objName: str,
where: Optional[List] = None,
limit: Optional[int] = None,
select=Optional[List[str]]) -> List:
""" """
Get objects based on a where clause, optional limit and optional field list. Get objects based on a where clause, optional limit and optional field list.
@ -207,7 +210,7 @@ class APIv4:
params["limit"] = limit params["limit"] = limit
if where is not None: if where is not None:
params["where"] = where params["where"] = where
if columns is not None and columns: if select is not None and select:
params["select"] = select params["select"] = select
return self.call_values(objName, "get", params=params) return self.call_values(objName, "get", params=params)

View File

@ -1,3 +1,3 @@
[build-system] [build-system]
requires = ["setuptools", "wheel"] requires = ["setuptools", "wheel"]
build-backend = "setuptools-build_meta"

12
tox.ini
View File

@ -1,3 +1,15 @@
[tox]
envlist = py36, py37, py38, py39
[testenv]
deps =
flake8
mypy
commands =
flake8
mypy civicrmapi4
[flake8] [flake8]
max-line-length = 120 max-line-length = 120
max-complexity = 20 max-complexity = 20