From 8602c0d3b08f27800b07ec4f75b406eb0126a23d Mon Sep 17 00:00:00 2001 From: AlgoFoe Date: Fri, 2 Jan 2026 23:28:42 +0530 Subject: [PATCH 1/8] Support list-based commands in safe_execute_command --- brainglobe_utils/general/system.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brainglobe_utils/general/system.py b/brainglobe_utils/general/system.py index ee4ba202..fba5c850 100644 --- a/brainglobe_utils/general/system.py +++ b/brainglobe_utils/general/system.py @@ -414,6 +414,7 @@ def safe_execute_command(cmd, log_file_path=None, error_file_path=None): error_file_path = os.path.abspath( os.path.join(gettempdir(), "safe_execute_command.err") ) + shell = isinstance(cmd, str) with ( open(log_file_path, "w") as log_file, @@ -421,7 +422,7 @@ def safe_execute_command(cmd, log_file_path=None, error_file_path=None): ): try: subprocess.check_call( - cmd, stdout=log_file, stderr=error_file, shell=True + cmd, stdout=log_file, stderr=error_file, shell=shell, ) except subprocess.CalledProcessError: hline = "-" * 25 From 2db66d70d70be9c7ab3e76d1a88cadf769593ed6 Mon Sep 17 00:00:00 2001 From: AlgoFoe Date: Sat, 3 Jan 2026 01:05:38 +0530 Subject: [PATCH 2/8] Add numpydoc validation pre-commit hook --- .pre-commit-config.yaml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0ea74d5f..58d31ab4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,12 +23,16 @@ repos: rev: 25.11.0 hooks: - id: black - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.19.0 - hooks: - - id: mypy - args: [--config-file, pyproject.toml] - additional_dependencies: - - numpy - - types-setuptools - - types-requests + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.19.0 + hooks: + - id: mypy + args: [--config-file, pyproject.toml] + additional_dependencies: + - numpy + - types-setuptools + - types-requests + - repo: https://github.com/numpy/numpydoc + rev: v1.7.0 + hooks: + - id: numpydoc-validation \ No newline at end of file From 5f38a517e75e1f95c202121a75c2cd9b9fe4d5ab Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 2 Jan 2026 19:43:02 +0000 Subject: [PATCH 3/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .pre-commit-config.yaml | 2 +- brainglobe_utils/general/system.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 58d31ab4..ef408260 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,4 +35,4 @@ repos: - repo: https://github.com/numpy/numpydoc rev: v1.7.0 hooks: - - id: numpydoc-validation \ No newline at end of file + - id: numpydoc-validation diff --git a/brainglobe_utils/general/system.py b/brainglobe_utils/general/system.py index fba5c850..72c34841 100644 --- a/brainglobe_utils/general/system.py +++ b/brainglobe_utils/general/system.py @@ -422,7 +422,10 @@ def safe_execute_command(cmd, log_file_path=None, error_file_path=None): ): try: subprocess.check_call( - cmd, stdout=log_file, stderr=error_file, shell=shell, + cmd, + stdout=log_file, + stderr=error_file, + shell=shell, ) except subprocess.CalledProcessError: hline = "-" * 25 From 77894e153c367d24ee15a7d7d601360fa0711741 Mon Sep 17 00:00:00 2001 From: AlgoFoe Date: Wed, 7 Jan 2026 00:28:19 +0530 Subject: [PATCH 4/8] Fix existing docstrings to satisfy numpydoc validation --- brainglobe_utils/IO/__init__.py | 3 +++ brainglobe_utils/IO/cells.py | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/brainglobe_utils/IO/__init__.py b/brainglobe_utils/IO/__init__.py index e69de29b..7a4b4b43 100644 --- a/brainglobe_utils/IO/__init__.py +++ b/brainglobe_utils/IO/__init__.py @@ -0,0 +1,3 @@ +""" +I/O utilities for reading and writing BrainGlobe cell data. +""" \ No newline at end of file diff --git a/brainglobe_utils/IO/cells.py b/brainglobe_utils/IO/cells.py index e6adec44..5edbf791 100644 --- a/brainglobe_utils/IO/cells.py +++ b/brainglobe_utils/IO/cells.py @@ -78,8 +78,21 @@ def get_cells( def raise_cell_read_error( cells_file_path: str | Path, e: Exception | None = None ) -> NoReturn: - """Raise a NotImplementedError, with an informative message including the - cells file path""" + """ + Raise a NotImplementedError for unsupported or invalid cell file formats. + + Parameters + ---------- + cells_file_path : str or pathlib.Path + Path to the cells file that could not be read. + e : Exception or None, optional + Original exception to chain, if available. + + Raises + ------ + NotImplementedError + If the file format is unsupported or contains errors. + """ logging.error( "File format of: {} is not supported or contains errors. Please " "supply an XML or YAML file, or a directory of files with positions " @@ -353,7 +366,7 @@ def cells_to_yml( def cells_xml_to_df(xml_file_path): - """Read cells from xml file and convert to dataframe""" + """Read cells from xml file and convert to dataframe.""" cells = get_cells(xml_file_path) return cells_to_dataframe(cells) @@ -451,7 +464,7 @@ def deal_with_artifacts(cell_dict, artifact_keep=True): return cell_dict -def make_type_dict(cell_list): +def make_type_dict(cell_list): # noqa: D401 """Convert a list of Cells to a dictionary with keys of cell type and values of the list of corresponding cells.""" types = sorted(set([cell.type for cell in cell_list])) @@ -505,7 +518,7 @@ def find_relevant_tiffs(tiffs, cell_def): ] -def _dict_to_yaml_string(data: dict) -> bytearray | bytes: +def _dict_to_yaml_string(data: dict) -> bytearray | bytes: # noqa: D401 """ Dump dict to yaml and return it as a buffer. From 61dacd58fda3efe82eb927e2e16750e08b8429f9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 Jan 2026 18:58:41 +0000 Subject: [PATCH 5/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- brainglobe_utils/IO/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brainglobe_utils/IO/__init__.py b/brainglobe_utils/IO/__init__.py index 7a4b4b43..14ad3b52 100644 --- a/brainglobe_utils/IO/__init__.py +++ b/brainglobe_utils/IO/__init__.py @@ -1,3 +1,3 @@ """ I/O utilities for reading and writing BrainGlobe cell data. -""" \ No newline at end of file +""" From d623d57c625b7a95aec3e55b33ba206c00256758 Mon Sep 17 00:00:00 2001 From: AlgoFoe Date: Wed, 7 Jan 2026 00:36:44 +0530 Subject: [PATCH 6/8] Fix existing docstrings to satisfy numpydoc validation --- pyproject.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 5af7a412..a1440efd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -135,3 +135,11 @@ passenv = deps = napari-dev: git+https://github.com/napari/napari """ + +[tool.numpydoc_validation] +checks = [ + "all", # enable all checks by default + "EX01", # ignore missing Examples + "SA01", # ignore missing See Also + "ES01", # ignore missing Extended Summary +] From 4e025c4f1ec2144fe753c4ad48bdfeb3b26986de Mon Sep 17 00:00:00 2001 From: AlgoFoe Date: Wed, 7 Jan 2026 00:40:54 +0530 Subject: [PATCH 7/8] Configure numpydoc-validation to ignore legacy docstring rules --- pyproject.toml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a1440efd..68300aaf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -138,8 +138,16 @@ deps = [tool.numpydoc_validation] checks = [ - "all", # enable all checks by default - "EX01", # ignore missing Examples - "SA01", # ignore missing See Also - "ES01", # ignore missing Extended Summary -] + "all", + "-EX01", # missing Examples + "-SA01", # missing See Also + "-ES01", # missing Extended Summary + "-SS03", # summary punctuation + "-SS05", # infinitive verb rule + "-SS06", # summary length + "-PR01", # undocumented parameters + "-PR09", # parameter punctuation + "-RT01", # missing Returns section + "-GL01", # summary placement + "-GL02", # closing quotes placement +] \ No newline at end of file From ddeee42e03b18c616fdd6fd13b52c3e05ddb9048 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 Jan 2026 19:11:16 +0000 Subject: [PATCH 8/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 68300aaf..0aec801b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -150,4 +150,4 @@ checks = [ "-RT01", # missing Returns section "-GL01", # summary placement "-GL02", # closing quotes placement -] \ No newline at end of file +]