diff --git a/poetry.lock b/poetry.lock index 28f29ce..ab81e69 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1837,48 +1837,49 @@ files = [ [[package]] name = "mypy" -version = "1.3.0" +version = "1.11.2" description = "Optional static typing for Python" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "mypy-1.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c1eb485cea53f4f5284e5baf92902cd0088b24984f4209e25981cc359d64448d"}, - {file = "mypy-1.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4c99c3ecf223cf2952638da9cd82793d8f3c0c5fa8b6ae2b2d9ed1e1ff51ba85"}, - {file = "mypy-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:550a8b3a19bb6589679a7c3c31f64312e7ff482a816c96e0cecec9ad3a7564dd"}, - {file = "mypy-1.3.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:cbc07246253b9e3d7d74c9ff948cd0fd7a71afcc2b77c7f0a59c26e9395cb152"}, - {file = "mypy-1.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:a22435632710a4fcf8acf86cbd0d69f68ac389a3892cb23fbad176d1cddaf228"}, - {file = "mypy-1.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6e33bb8b2613614a33dff70565f4c803f889ebd2f859466e42b46e1df76018dd"}, - {file = "mypy-1.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7d23370d2a6b7a71dc65d1266f9a34e4cde9e8e21511322415db4b26f46f6b8c"}, - {file = "mypy-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:658fe7b674769a0770d4b26cb4d6f005e88a442fe82446f020be8e5f5efb2fae"}, - {file = "mypy-1.3.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:6e42d29e324cdda61daaec2336c42512e59c7c375340bd202efa1fe0f7b8f8ca"}, - {file = "mypy-1.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:d0b6c62206e04061e27009481cb0ec966f7d6172b5b936f3ead3d74f29fe3dcf"}, - {file = "mypy-1.3.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:76ec771e2342f1b558c36d49900dfe81d140361dd0d2df6cd71b3db1be155409"}, - {file = "mypy-1.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ebc95f8386314272bbc817026f8ce8f4f0d2ef7ae44f947c4664efac9adec929"}, - {file = "mypy-1.3.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:faff86aa10c1aa4a10e1a301de160f3d8fc8703b88c7e98de46b531ff1276a9a"}, - {file = "mypy-1.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:8c5979d0deb27e0f4479bee18ea0f83732a893e81b78e62e2dda3e7e518c92ee"}, - {file = "mypy-1.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c5d2cc54175bab47011b09688b418db71403aefad07cbcd62d44010543fc143f"}, - {file = "mypy-1.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:87df44954c31d86df96c8bd6e80dfcd773473e877ac6176a8e29898bfb3501cb"}, - {file = "mypy-1.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:473117e310febe632ddf10e745a355714e771ffe534f06db40702775056614c4"}, - {file = "mypy-1.3.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:74bc9b6e0e79808bf8678d7678b2ae3736ea72d56eede3820bd3849823e7f305"}, - {file = "mypy-1.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:44797d031a41516fcf5cbfa652265bb994e53e51994c1bd649ffcd0c3a7eccbf"}, - {file = "mypy-1.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ddae0f39ca146972ff6bb4399f3b2943884a774b8771ea0a8f50e971f5ea5ba8"}, - {file = "mypy-1.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1c4c42c60a8103ead4c1c060ac3cdd3ff01e18fddce6f1016e08939647a0e703"}, - {file = "mypy-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e86c2c6852f62f8f2b24cb7a613ebe8e0c7dc1402c61d36a609174f63e0ff017"}, - {file = "mypy-1.3.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:f9dca1e257d4cc129517779226753dbefb4f2266c4eaad610fc15c6a7e14283e"}, - {file = "mypy-1.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:95d8d31a7713510685b05fbb18d6ac287a56c8f6554d88c19e73f724a445448a"}, - {file = "mypy-1.3.0-py3-none-any.whl", hash = "sha256:a8763e72d5d9574d45ce5881962bc8e9046bf7b375b0abf031f3e6811732a897"}, - {file = "mypy-1.3.0.tar.gz", hash = "sha256:e1f4d16e296f5135624b34e8fb741eb0eadedca90862405b1f1fde2040b9bd11"}, + {file = "mypy-1.11.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d42a6dd818ffce7be66cce644f1dff482f1d97c53ca70908dff0b9ddc120b77a"}, + {file = "mypy-1.11.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:801780c56d1cdb896eacd5619a83e427ce436d86a3bdf9112527f24a66618fef"}, + {file = "mypy-1.11.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:41ea707d036a5307ac674ea172875f40c9d55c5394f888b168033177fce47383"}, + {file = "mypy-1.11.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:6e658bd2d20565ea86da7d91331b0eed6d2eee22dc031579e6297f3e12c758c8"}, + {file = "mypy-1.11.2-cp310-cp310-win_amd64.whl", hash = "sha256:478db5f5036817fe45adb7332d927daa62417159d49783041338921dcf646fc7"}, + {file = "mypy-1.11.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:75746e06d5fa1e91bfd5432448d00d34593b52e7e91a187d981d08d1f33d4385"}, + {file = "mypy-1.11.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a976775ab2256aadc6add633d44f100a2517d2388906ec4f13231fafbb0eccca"}, + {file = "mypy-1.11.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:cd953f221ac1379050a8a646585a29574488974f79d8082cedef62744f0a0104"}, + {file = "mypy-1.11.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:57555a7715c0a34421013144a33d280e73c08df70f3a18a552938587ce9274f4"}, + {file = "mypy-1.11.2-cp311-cp311-win_amd64.whl", hash = "sha256:36383a4fcbad95f2657642a07ba22ff797de26277158f1cc7bd234821468b1b6"}, + {file = "mypy-1.11.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:e8960dbbbf36906c5c0b7f4fbf2f0c7ffb20f4898e6a879fcf56a41a08b0d318"}, + {file = "mypy-1.11.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:06d26c277962f3fb50e13044674aa10553981ae514288cb7d0a738f495550b36"}, + {file = "mypy-1.11.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6e7184632d89d677973a14d00ae4d03214c8bc301ceefcdaf5c474866814c987"}, + {file = "mypy-1.11.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:3a66169b92452f72117e2da3a576087025449018afc2d8e9bfe5ffab865709ca"}, + {file = "mypy-1.11.2-cp312-cp312-win_amd64.whl", hash = "sha256:969ea3ef09617aff826885a22ece0ddef69d95852cdad2f60c8bb06bf1f71f70"}, + {file = "mypy-1.11.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:37c7fa6121c1cdfcaac97ce3d3b5588e847aa79b580c1e922bb5d5d2902df19b"}, + {file = "mypy-1.11.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4a8a53bc3ffbd161b5b2a4fff2f0f1e23a33b0168f1c0778ec70e1a3d66deb86"}, + {file = "mypy-1.11.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2ff93107f01968ed834f4256bc1fc4475e2fecf6c661260066a985b52741ddce"}, + {file = "mypy-1.11.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:edb91dded4df17eae4537668b23f0ff6baf3707683734b6a818d5b9d0c0c31a1"}, + {file = "mypy-1.11.2-cp38-cp38-win_amd64.whl", hash = "sha256:ee23de8530d99b6db0573c4ef4bd8f39a2a6f9b60655bf7a1357e585a3486f2b"}, + {file = "mypy-1.11.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:801ca29f43d5acce85f8e999b1e431fb479cb02d0e11deb7d2abb56bdaf24fd6"}, + {file = "mypy-1.11.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:af8d155170fcf87a2afb55b35dc1a0ac21df4431e7d96717621962e4b9192e70"}, + {file = "mypy-1.11.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f7821776e5c4286b6a13138cc935e2e9b6fde05e081bdebf5cdb2bb97c9df81d"}, + {file = "mypy-1.11.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:539c570477a96a4e6fb718b8d5c3e0c0eba1f485df13f86d2970c91f0673148d"}, + {file = "mypy-1.11.2-cp39-cp39-win_amd64.whl", hash = "sha256:3f14cd3d386ac4d05c5a39a51b84387403dadbd936e17cb35882134d4f8f0d24"}, + {file = "mypy-1.11.2-py3-none-any.whl", hash = "sha256:b499bc07dbdcd3de92b0a8b29fdf592c111276f6a12fe29c30f6c417dd546d12"}, + {file = "mypy-1.11.2.tar.gz", hash = "sha256:7f9993ad3e0ffdc95c2a14b66dee63729f021968bff8ad911867579c65d13a79"}, ] [package.dependencies] mypy-extensions = ">=1.0.0" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = ">=3.10" +typing-extensions = ">=4.6.0" [package.extras] dmypy = ["psutil (>=4.0)"] install-types = ["pip"] -python2 = ["typed-ast (>=1.4.0,<2)"] +mypyc = ["setuptools (>=50)"] reports = ["lxml"] [[package]] @@ -4187,4 +4188,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "205876c89f7f7d87debdb88a463d6210f7d2346e828020e0add1beacf4896267" +content-hash = "8e6eff1c0a4314af558ef74343e572d0b8282dab7620f8ab57c9d1fd11887ca0" diff --git a/pyproject.toml b/pyproject.toml index e105c0a..ca35826 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -60,6 +60,7 @@ namespace_packages = true module = [ "matplotlib.*", "pandas.*", + "ruamel.*", "simulariumio.*", "skimage.*", ] diff --git a/src/arcade_collection/output/parse_cells_file.py b/src/arcade_collection/output/parse_cells_file.py index c5f7a5b..cafea6c 100644 --- a/src/arcade_collection/output/parse_cells_file.py +++ b/src/arcade_collection/output/parse_cells_file.py @@ -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] diff --git a/src/arcade_collection/output/parse_growth_file.py b/src/arcade_collection/output/parse_growth_file.py index 1a70e42..58e0e85 100644 --- a/src/arcade_collection/output/parse_growth_file.py +++ b/src/arcade_collection/output/parse_growth_file.py @@ -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"] diff --git a/src/arcade_collection/output/parse_locations_file.py b/src/arcade_collection/output/parse_locations_file.py index 4457a2c..11d1e32 100644 --- a/src/arcade_collection/output/parse_locations_file.py +++ b/src/arcade_collection/output/parse_locations_file.py @@ -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] diff --git a/tests/arcade_collection/output/test_parse_cells_file.py b/tests/arcade_collection/output/test_parse_cells_file.py index b4de772..1a4f94f 100644 --- a/tests/arcade_collection/output/test_parse_cells_file.py +++ b/tests/arcade_collection/output/test_parse_cells_file.py @@ -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 = [ { @@ -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 = [ { diff --git a/tests/arcade_collection/output/test_parse_growth_file.py b/tests/arcade_collection/output/test_parse_growth_file.py index 8774321..34748a3 100644 --- a/tests/arcade_collection/output/test_parse_growth_file.py +++ b/tests/arcade_collection/output/test_parse_growth_file.py @@ -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, diff --git a/tests/arcade_collection/output/test_parse_locations_file.py b/tests/arcade_collection/output/test_parse_locations_file.py index 6cf198d..cb8e9a5 100644 --- a/tests/arcade_collection/output/test_parse_locations_file.py +++ b/tests/arcade_collection/output/test_parse_locations_file.py @@ -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 = [ { @@ -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 = [ {