Skip to content

Commit

Permalink
chore: fix line length
Browse files Browse the repository at this point in the history
  • Loading branch information
yannforget committed May 10, 2024
1 parent 46b17b9 commit 440844d
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions openhexa/toolbox/dhis2/dhis2.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ def category_option_combos(self) -> List[dict]:
Id and name of all category option combos.
"""
combos = []
for page in self.client.api.get_paged(
"categoryOptionCombos", params={"fields": "id,name"}, page_size=1000
):
for page in self.client.api.get_paged("categoryOptionCombos", params={"fields": "id,name"}, page_size=1000):
combos += page.json().get("categoryOptionCombos")
return combos

Expand Down Expand Up @@ -487,9 +485,7 @@ def add_org_unit_parent_columns(

for lvl in range(1, len(levels)):
org_units = org_units.with_columns(
pl.col("path")
.apply(lambda path: self._get_uid_from_level(path, lvl))
.alias(f"parent_level_{lvl}_id")
pl.col("path").apply(lambda path: self._get_uid_from_level(path, lvl)).alias(f"parent_level_{lvl}_id")
)

org_units = org_units.join(
Expand All @@ -504,9 +500,7 @@ def add_org_unit_parent_columns(
)

df = df.join(
other=org_units.select(
["id"] + [col for col in org_units.columns if col.startswith("parent_")]
),
other=org_units.select(["id"] + [col for col in org_units.columns if col.startswith("parent_")]),
how="left",
left_on=org_unit_id_column,
right_on="id",
Expand Down Expand Up @@ -692,9 +686,7 @@ def _validate(self, data_values: List[dict]):
raise ValueError(f"Data value {value} is not a valid {value_type}")

elif value_type == "PERCENTAGE":
if (not isinstance(value, float) and not isinstance(value, int)) or not (
value >= 0 and value <= 100
):
if (not isinstance(value, float) and not isinstance(value, int)) or not (value >= 0 and value <= 100):
raise ValueError(f"Data value {value} is not a valid {value_type}")

elif value_type == "INTEGER_POSITIVE":
Expand Down Expand Up @@ -850,12 +842,8 @@ def split_params(self, params: dict) -> List[dict]:
for dim in dimension:
dim_id, dim_items = self.split_dimension_param(dim)
if dim_id in MAX_DIM_ITEMS:
dim_item_chunks = [
item for item in _split_list(dim_items, MAX_DIM_ITEMS.get(dim_id, 50))
]
dim_item_chunks = [
f"{dim_id}:{';'.join(dim_items)}" for dim_items in dim_item_chunks
]
dim_item_chunks = [item for item in _split_list(dim_items, MAX_DIM_ITEMS.get(dim_id, 50))]
dim_item_chunks = [f"{dim_id}:{';'.join(dim_items)}" for dim_items in dim_item_chunks]
dim_chunks.append(dim_item_chunks)
else:
dim_chunks.append([dim])
Expand Down

0 comments on commit 440844d

Please sign in to comment.