Skip to content

Commit

Permalink
further ruff linting cleanup #102
Browse files Browse the repository at this point in the history
  • Loading branch information
bensteUEM committed Oct 7, 2024
1 parent 493f6e8 commit 3af967f
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 24 deletions.
11 changes: 5 additions & 6 deletions churchtools_api/churchtools_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,11 @@ def get_services(self, **kwargs):
response_content = json.loads(response.content)
response_data = response_content["data"].copy()

if "returnAsDict" in kwargs and "serviceId" not in kwargs:
if kwargs["returnAsDict"]:
result = {}
for item in response_data:
result[item["id"]] = item
response_data = result
if kwargs.get("returnAsDict", False) and "serviceId" not in kwargs:
result = {}
for item in response_data:
result[item["id"]] = item
response_data = result

logger.debug(
f"Services load successful with {len(response_data)} entries",
Expand Down
3 changes: 2 additions & 1 deletion churchtools_api/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def file_upload(
domain_type: str,
domain_identifier: int,
custom_file_name: Optional[str] = None,
*,
overwrite: bool = False,
) -> bool:
"""Helper function to upload an attachment to any module of ChurchTools.
Expand Down Expand Up @@ -87,7 +88,7 @@ def file_upload(
response_content = json.loads(response.content)
logger.debug(f"Upload successful {response_content}")
return True
except BaseException:
except (json.JSONDecodeError, TypeError, UnicodeDecodeError):
logger.warning(response.content.decode())
return False
else:
Expand Down
1 change: 1 addition & 0 deletions churchtools_api/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ def get_group_members(self, group_id: int, **kwargs) -> list[dict]:
def get_groups_members(
self,
group_ids: Optional[list[int]] = None,
*,
with_deleted: bool = False,
**kwargs,
) -> list[dict]:
Expand Down
1 change: 1 addition & 0 deletions churchtools_api/persons.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def get_persons(self, **kwargs) -> list[dict]:

def get_persons_masterdata(
self,
*,
resultClass: Optional[str] = None,
returnAsDict: bool = False,
**kwargs,
Expand Down
4 changes: 2 additions & 2 deletions churchtools_api/songs.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def get_song_category_map(self) -> dict:

return song_category_dict

def create_song(
def create_song( # noqa: PLR0913
self,
title: str,
songcategory_id: int,
Expand Down Expand Up @@ -157,7 +157,7 @@ def create_song(
logger.info(f"Creating song failed with {response.status_code}")
return None

def edit_song(
def edit_song( # noqa: PLR0913
self,
song_id: int,
songcategory_id=None,
Expand Down
3 changes: 2 additions & 1 deletion main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"from pathlib import Path\n",
"\n",
"from churchtools_api.churchtools_api import ChurchToolsApi\n",
"from secure.config import ct_domain, ct_token\n",
"\n",
"logger = logging.getLogger(__name__)\n",
"\n",
Expand All @@ -34,7 +35,7 @@
" logging.config.dictConfig(config=logging_config)\n",
"\n",
"# Create Session\n",
"from secure.config import ct_domain, ct_token\n",
"\n",
"\n",
"api = ChurchToolsApi(ct_domain)\n",
"api.login_ct_rest_api(ct_token=ct_token)"
Expand Down
31 changes: 18 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,28 @@ ignore = [
"S101", # TODO: Github #104 - pytest asserts
"ANN001","ANN002","ANN003","ANN201",
"FIX002", #Open ToDos
"C901", #complexity
"ARG002",
"FA100",
"FBT001","FBT002",
"TD002","TD003","TD004",
"D100","D101","D102","D104","D107","D205","D415",
"E402","E501",
"DTZ001","DTZ005","DTZ007","DTZ002",
"N801","N802","N803","N806",
"PLR2004","PLR0913","PLR0912",
"PTH110","PTH107","PTH123","PTH118","PTH112","PTH103",
"SIM102","SIM113","SIM115",
"TD002","TD003","TD004", #TODOs
"C901","PLR0912", #complexity
"ARG002",#TODO: Github #110
"FA100", #Python version specific #102
"D100","D101","D102","D104","D107","D205","D415", #Docstrings
"E501", #line too long
"DTZ001","DTZ005","DTZ007","DTZ002", #datetime timezone

"PLR2004", #magic values
"PTH110","PTH107","PTH123","PTH118","PTH112","PTH103", #Path changes
"SIM115", #context manager for files

"SIM102","SIM113",
"G001","G003", "G004",
"A001","A002",
"TRY300",
"BLE001",

"COM812", "ISC001", #disabled for formatter compatibility

"N802", #function lowercase -> breaking change
"N803", #argument lowercase -> breaking change
"N806", #variable name lowercase -> breaking change
]
fixable = [
"ALL",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_churchtools_api_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
logging.config.dictConfig(config=logging_config)


class Test_churchtools_api_resources(TestsChurchToolsApiAbstract):
class TestChurchtoolsApiResources(TestsChurchToolsApiAbstract):
def test_get_resource_masterdata_resourceTypes(self) -> None:
"""Check resourceTypes can be retrieved.
Expand Down

0 comments on commit 3af967f

Please sign in to comment.