Skip to content

Commit

Permalink
Enable flake8-comprehensions ruff rules
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed May 1, 2024
1 parent d3df34f commit 9cff461
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion bioblend/_tests/TestGalaxyHistories.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_get_histories(self):

# Test keys: check that fields requested are returned
histories_with_keys = self.gi.histories.get_histories(keys=["id", "user_id", "size"])
assert {key for key in histories_with_keys[0]} >= {"id", "user_id", "size"}
assert set(histories_with_keys[0]) >= {"id", "user_id", "size"}

# TODO: check whether deleted history is returned correctly
# At the moment, get_histories() returns only not-deleted histories
Expand Down
48 changes: 26 additions & 22 deletions bioblend/galaxy/dataset_collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,21 @@ def add(self, element: Union["CollectionElement", "SimpleElement"]) -> "HasEleme

class CollectionDescription(HasElements):
def to_dict(self) -> Dict[str, Union[str, List]]:
return dict(name=self.name, collection_type=self.type, element_identifiers=[e.to_dict() for e in self.elements])
return {
"name": self.name,
"collection_type": self.type,
"element_identifiers": [e.to_dict() for e in self.elements],
}


class CollectionElement(HasElements):
def to_dict(self) -> Dict[str, Union[str, List]]:
return dict(
src="new_collection",
name=self.name,
collection_type=self.type,
element_identifiers=[e.to_dict() for e in self.elements],
)
return {
"src": "new_collection",
"name": self.name,
"collection_type": self.type,
"element_identifiers": [e.to_dict() for e in self.elements],
}


class SimpleElement:
Expand All @@ -69,33 +73,33 @@ def to_dict(self) -> Dict[str, str]:
class HistoryDatasetElement(SimpleElement):
def __init__(self, name: str, id: str) -> None:
super().__init__(
dict(
name=name,
src="hda",
id=id,
)
{
"name": name,
"src": "hda",
"id": id,
}
)


class HistoryDatasetCollectionElement(SimpleElement):
def __init__(self, name: str, id: str) -> None:
super().__init__(
dict(
name=name,
src="hdca",
id=id,
)
{
"name": name,
"src": "hdca",
"id": id,
}
)


class LibraryDatasetElement(SimpleElement):
def __init__(self, name: str, id: str) -> None:
super().__init__(
dict(
name=name,
src="ldda",
id=id,
)
{
"name": name,
"src": "ldda",
"id": id,
}
)


Expand Down
6 changes: 3 additions & 3 deletions bioblend/galaxy/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def show_dataset(self, dataset_id: str, hda_ldda: HdaLdda = "hda") -> Dict[str,
:rtype: dict
:return: Information about the HDA or LDDA
"""
params = dict(
hda_ldda=hda_ldda,
)
params = {
"hda_ldda": hda_ldda,
}
return self._get(id=dataset_id, params=params)

def _initiate_download(
Expand Down
14 changes: 7 additions & 7 deletions bioblend/galaxy/histories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,13 +735,13 @@ def create_dataset_collection(
else:
collection_description_dict = collection_description

payload = dict(
name=collection_description_dict["name"],
type="dataset_collection",
collection_type=collection_description_dict["collection_type"],
element_identifiers=collection_description_dict["element_identifiers"],
copy_elements=copy_elements,
)
payload = {
"name": collection_description_dict["name"],
"type": "dataset_collection",
"collection_type": collection_description_dict["collection_type"],
"element_identifiers": collection_description_dict["element_identifiers"],
"copy_elements": copy_elements,
}
return self._post(payload, id=history_id, contents=True)

def delete_history(self, history_id: str, purge: bool = False) -> Dict[str, Any]:
Expand Down
2 changes: 1 addition & 1 deletion bioblend/galaxy/tools/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, value: Any) -> None:
class DatasetParam(Param):
def __init__(self, value: Union[Dict[str, str], str], src: str = "hda") -> None:
if not isinstance(value, dict):
value = dict(src=src, id=value)
value = {"src": src, "id": value}
super().__init__(value)


Expand Down
2 changes: 1 addition & 1 deletion bioblend/toolshed/repositories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def search_repositories(
'page_size': '2',
'total_results': '64'}
"""
params = dict(q=q, page=page, page_size=page_size)
params = {"q": q, "page": page, "page_size": page_size}
return self._get(params=params)

def show_repository(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ isort = true
target-version = "py38"

[tool.ruff.lint]
select = ["E", "F", "B", "UP"]
select = ["E", "F", "B", "C4", "UP"]
# Exceptions:
# B9 flake8-bugbear opinionated warnings
# E501 is line length (delegated to black)
Expand Down

0 comments on commit 9cff461

Please sign in to comment.