Skip to content

Commit

Permalink
Apply more ruff linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicasyu committed Sep 4, 2024
1 parent a4c1ece commit ac552a2
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 46 deletions.
63 changes: 32 additions & 31 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ matplotlib = "^3.7.2"
[tool.poetry.group.dev.dependencies]
black = "^24.3.0"
isort = "^5.12.0"
mypy = "^1.3.0"
mypy = "^1.10.0"
pylint = "^2.16.2"
pytest = "^7.3.0"
pytest-cov = "^4.0.0"
Expand Down Expand Up @@ -60,6 +60,7 @@ namespace_packages = true
module = [
"matplotlib.*",
"pandas.*",
"ruamel.*",
"simulariumio.*",
"skimage.*",
]
Expand Down
7 changes: 5 additions & 2 deletions src/arcade_collection/output/parse_cells_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ def parse_cells_file(tar: tarfile.TarFile, regions: list[str]) -> pd.DataFrame:
all_cells: list[list[str | int]] = []

for member in tar.getmembers():
tick = int(member.name.replace(".CELLS.json", "").split("_")[-1])

extracted_member = tar.extractfile(member)

if extracted_member is None:
continue

tick = int(member.name.replace(".CELLS.json", "").split("_")[-1])
cells_json = json.loads(extracted_member.read().decode("utf-8"))

cells = [parse_cell_tick(tick, cell, regions) for cell in cells_json]
Expand Down
4 changes: 4 additions & 0 deletions src/arcade_collection/output/parse_growth_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def parse_growth_file(tar: tarfile.TarFile) -> pd.DataFrame:

for member in tar.getmembers():
extracted_member = tar.extractfile(member)

if extracted_member is None:
continue

extracted_json = json.loads(extracted_member.read().decode("utf-8"))

seed = extracted_json["seed"]
Expand Down
7 changes: 5 additions & 2 deletions src/arcade_collection/output/parse_locations_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ def parse_locations_file(tar: tarfile.TarFile, regions: list[str]) -> pd.DataFra
all_locations: list[list[str | int]] = []

for member in tar.getmembers():
tick = int(member.name.replace(".LOCATIONS.json", "").split("_")[-1])

extracted_member = tar.extractfile(member)

if extracted_member is None:
continue

tick = int(member.name.replace(".LOCATIONS.json", "").split("_")[-1])
locations_json = json.loads(extracted_member.read().decode("utf-8"))

locations = [parse_location_tick(tick, cell, regions) for cell in locations_json]
Expand Down
8 changes: 4 additions & 4 deletions tests/arcade_collection/output/test_parse_cells_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def test_parse_cells_file_without_regions(self):
second_member_mock.name: second_member_mock,
}

tar_mock.getmembers.return_value = contents.values()
tar_mock.extractfile.side_effect = lambda member: contents.get(member.name, None)
tar_mock.getmembers.return_value = [*list(contents.values()), None]
tar_mock.extractfile.side_effect = lambda m: None if m is None else contents[m.name]

first_member_contents = [
{
Expand Down Expand Up @@ -97,8 +97,8 @@ def test_parse_cells_file_with_regions(self):
second_member_mock.name: second_member_mock,
}

tar_mock.getmembers.return_value = contents.values()
tar_mock.extractfile.side_effect = lambda member: contents.get(member.name, None)
tar_mock.getmembers.return_value = [*list(contents.values()), None]
tar_mock.extractfile.side_effect = lambda m: None if m is None else contents[m.name]

first_member_contents = [
{
Expand Down
6 changes: 4 additions & 2 deletions tests/arcade_collection/output/test_parse_growth_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ def test_parse_growth_file(self):
second_member_mock.name: second_member_mock,
}

tar_mock.getmembers.return_value = contents.values()
tar_mock.extractfile.side_effect = lambda member: contents.get(member.name, None)
tar_mock.getmembers.return_value = [*list(contents.values()), None]
tar_mock.extractfile.side_effect = lambda member: (
None if member is None else contents[member.name]
)

first_member_contents = {
"seed": 0,
Expand Down
8 changes: 4 additions & 4 deletions tests/arcade_collection/output/test_parse_locations_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def test_parse_locations_file_without_regions(self):
second_member_mock.name: second_member_mock,
}

tar_mock.getmembers.return_value = contents.values()
tar_mock.extractfile.side_effect = lambda member: contents.get(member.name, None)
tar_mock.getmembers.return_value = [*list(contents.values()), None]
tar_mock.extractfile.side_effect = lambda m: None if m is None else contents[m.name]

first_member_contents = [
{
Expand Down Expand Up @@ -96,8 +96,8 @@ def test_parse_locations_file_with_regions(self):
second_member_mock.name: second_member_mock,
}

tar_mock.getmembers.return_value = contents.values()
tar_mock.extractfile.side_effect = lambda member: contents.get(member.name, None)
tar_mock.getmembers.return_value = [*list(contents.values()), None]
tar_mock.extractfile.side_effect = lambda m: None if m is None else contents[m.name]

first_member_contents = [
{
Expand Down

0 comments on commit ac552a2

Please sign in to comment.