From 0f263d69c6d766460d2fcccd825f2a5751b9ea36 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Fri, 17 Jan 2025 17:45:52 +0100 Subject: [PATCH 1/3] replace external "simplejson" backport from Py3 to Py3 with plain "json" module --- docs/requirements.txt | 1 - pyproject.toml | 1 - src/cooler/api.py | 2 +- src/cooler/cli/cload.py | 2 +- src/cooler/cli/info.py | 2 +- src/cooler/cli/load.py | 2 +- src/cooler/create/_create.py | 2 +- src/cooler/fileops.py | 3 +-- tests/test_cli_ingest.py | 2 +- 9 files changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 9f026a3c..fe798702 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -8,4 +8,3 @@ multiprocess click asciitree pyyaml -simplejson diff --git a/pyproject.toml b/pyproject.toml index 19559be5..5f0e97b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,6 @@ dependencies = [ "pyfaidx", "asciitree", "pyyaml", - "simplejson", ] [project.optional-dependencies] diff --git a/src/cooler/api.py b/src/cooler/api.py index e90b54db..fd1f13bf 100644 --- a/src/cooler/api.py +++ b/src/cooler/api.py @@ -1,11 +1,11 @@ from __future__ import annotations +import json import os import h5py import numpy as np import pandas as pd -import simplejson as json from pandas.api.types import is_integer_dtype from scipy.sparse import coo_matrix diff --git a/src/cooler/cli/cload.py b/src/cooler/cli/cload.py index ded4b192..d8dba37a 100644 --- a/src/cooler/cli/cload.py +++ b/src/cooler/cli/cload.py @@ -1,10 +1,10 @@ +import json import sys import click import h5py import numpy as np import pandas as pd -import simplejson as json from cytoolz import compose from multiprocess import Pool diff --git a/src/cooler/cli/info.py b/src/cooler/cli/info.py index eee56868..8a4f4aa7 100644 --- a/src/cooler/cli/info.py +++ b/src/cooler/cli/info.py @@ -1,7 +1,7 @@ +import json import sys import click -import simplejson as json from ..api import Cooler from ..util import attrs_to_jsonable diff --git a/src/cooler/cli/load.py b/src/cooler/cli/load.py index 6717ac4c..9f556c3c 100644 --- a/src/cooler/cli/load.py +++ b/src/cooler/cli/load.py @@ -1,9 +1,9 @@ +import json import sys import click import numpy as np import pandas as pd -import simplejson as json from ..create import ( BIN_DTYPE, diff --git a/src/cooler/create/_create.py b/src/cooler/create/_create.py index 6de40138..3f704d8f 100644 --- a/src/cooler/create/_create.py +++ b/src/cooler/create/_create.py @@ -1,5 +1,6 @@ from __future__ import annotations +import json import os import os.path as op import posixpath @@ -12,7 +13,6 @@ import h5py import numpy as np import pandas as pd -import simplejson as json from .._logging import get_logger from .._typing import Tabular diff --git a/src/cooler/fileops.py b/src/cooler/fileops.py index cdc42f6a..7e77c150 100644 --- a/src/cooler/fileops.py +++ b/src/cooler/fileops.py @@ -3,14 +3,13 @@ import os # from textwrap import dedent +import json import warnings from collections.abc import Callable from datetime import datetime from numbers import Number from typing import Any, Literal -import simplejson as json - try: from simplejson import JSONDecodeError except ImportError: diff --git a/tests/test_cli_ingest.py b/tests/test_cli_ingest.py index ab43469c..875f4db0 100644 --- a/tests/test_cli_ingest.py +++ b/tests/test_cli_ingest.py @@ -1,4 +1,5 @@ # from io import StringIO +import json import os.path as op import tempfile from glob import glob @@ -6,7 +7,6 @@ import numpy as np import pandas as pd import pytest -import simplejson as json # from _common import cooler_cmp from click.testing import CliRunner From 2b3b463e625fb92c9b4a60f8239eb78ada8440da Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Jan 2025 16:47:16 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/cooler/fileops.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cooler/fileops.py b/src/cooler/fileops.py index 7e77c150..b0a5b476 100644 --- a/src/cooler/fileops.py +++ b/src/cooler/fileops.py @@ -1,9 +1,8 @@ from __future__ import annotations -import os - # from textwrap import dedent import json +import os import warnings from collections.abc import Callable from datetime import datetime From 9ebb671b953a1c175717ff384a0cf73bd241bf23 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Fri, 17 Jan 2025 17:48:44 +0100 Subject: [PATCH 3/3] ruff --- src/cooler/fileops.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/cooler/fileops.py b/src/cooler/fileops.py index b0a5b476..00f036e7 100644 --- a/src/cooler/fileops.py +++ b/src/cooler/fileops.py @@ -9,11 +9,6 @@ from numbers import Number from typing import Any, Literal -try: - from simplejson import JSONDecodeError -except ImportError: - JSONDecodeError = ValueError # PY35+ - import h5py import numpy as np from asciitree import BoxStyle, LeftAligned @@ -54,7 +49,7 @@ def decode_attr_value( except ValueError: try: o = json.loads(obj) - except JSONDecodeError: + except ValueError: o = obj else: o = obj