Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2023 Norman Fomferra
# Copyright © 2024, 2025 Brockmann Consult
# Permission granted under conditions of the MIT license,
# see https://mit-license.org/

Expand Down
7 changes: 0 additions & 7 deletions .flake8

This file was deleted.

7 changes: 2 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install .[dev,doc]
- name: Lint with flake8
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
ruff check
- name: Test with pytest
run: |
pytest --cov=zappend
Expand Down
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Version 0.8.1 (in development)

* Replaced dev tools black and flake8 by isort and ruff.
* Reformatted code and fixed linter issues.
* Added `environment.yml` to setup a conda/mamba development environment.
* Updated copyright notice.


## Version 0.8.0 (from 2024-10-04)

* Added module `zappend.contrib` that contributes functions to
Expand Down
11 changes: 6 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ checklist are addressed in your PR.

**PR checklist**

* Format code using [black](https://black.readthedocs.io/) with default settings.
* Format code using first [isort](https://pycqa.github.io/isort/)
then [ruff](https://black.readthedocs.io/) with default settings
(`ruff format .`).
Check also section [code style](#code-style) below.
* Your change shall not break existing unit tests.
`pytest` must run without errors.
Expand All @@ -38,10 +40,9 @@ checklist are addressed in your PR.
## Code style

The `zappend` code compliant to [PEP-8](https://pep8.org/) except for a line
length of 88 characters as recommended by [black](https://black.readthedocs.io/).
Since black is un-opinionated regarding the order of imports,
we use the following three import blocks separated by an empty
line:
length of 88 characters as used by `ruff format`.
We structure imports using three blocks separated by an empty
line and sort them using `isort` _before_ applying `ruff`:

1. Python standard library imports, e.g., `os`, `typing`, etc
2. 3rd-party imports, e.g., `xarray`, `zarr`, etc
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![codecov](https://codecov.io/gh/bcdev/zappend/graph/badge.svg?token=B3R6bNmAUp)](https://codecov.io/gh/bcdev/zappend)
[![PyPI Version](https://img.shields.io/pypi/v/zappend)](https://pypi.org/project/zappend/)
[![Conda Version](https://anaconda.org/conda-forge/zappend/badges/version.svg)](https://anaconda.org/conda-forge/zappend)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v0.json)](https://github.com/charliermarsh/ruff)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/bcdev/zappend/HEAD?labpath=examples%2Fzappend-demo.ipynb)
[![GitHub License](https://img.shields.io/github/license/bcdev/zappend)](https://github.com/bcdev/zappend)

Expand Down
5 changes: 3 additions & 2 deletions docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ pytest --cov=zappend tests

### Code Style

`zappend` source code is formatted using the [black](https://black.readthedocs.io/) tool.
`zappend` source code is formatted using the
[ruff](https://github.com/charliermarsh/ruff) tool.

```bash
black zappend
ruff format .
```

### Documentation
Expand Down
34 changes: 34 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: zappend
channels:
- conda-forge
dependencies:
- python >=3.10
# Library Dependencies
- click
- dask
- fsspec
- jsonschema
- numcodecs
- numpy
- pyyaml
- xarray
- zarr >=2.18,<3
# Dev Dependencies
- isort
- pytest
- pytest-cov
- ruff
# Doc Dependencies
- mkdocs
- mkdocs-autorefs
- mkdocs-material
- mkdocstrings
- mkdocstrings-python
# Testing Datasets
- dask
- pandas
- pyproj
- netcdf4
- h5netcdf
- s3fs
- scipy
9 changes: 2 additions & 7 deletions examples/zappend-demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
"outputs": [],
"source": [
"import glob\n",
"import math\n",
"import os\n",
"import os.path\n",
"import shutil\n",
"\n",
"import numpy as np\n",
"import xarray as xr"
]
},
Expand Down Expand Up @@ -2951,10 +2949,7 @@
"id": "e3b5f156-88c7-4ce1-908e-88ddc7b7e18c",
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import Markdown\n",
"from zappend.config import get_config_schema"
]
"source": []
},
{
"cell_type": "code",
Expand Down Expand Up @@ -3023,7 +3018,7 @@
"metadata": {},
"outputs": [],
"source": [
"config_path = f\"zappend-config.yaml\""
"config_path = \"zappend-config.yaml\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ site_name: zappend
repo_url: https://github.com/bcdev/zappend
repo_name: bcdev/zappend

copyright: Copyright &copy; 2024 Brockmann Consult
copyright: Copyright &copy; 2024, 2025 Brockmann Consult and contributors

nav:
- Overview: index.md
Expand Down
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies = [
"numpy",
"pyyaml",
"xarray",
"zarr"
"zarr >=2,<3"
]

[tool.setuptools.dynamic]
Expand All @@ -47,15 +47,14 @@ zappend = "zappend.cli:zappend"

[project.optional-dependencies]
dev = [
"isort",
"pytest",
"pytest-cov",
"black",
"flake8",
"flake8-bugbear",
"h5netcdf",
"s3fs",
"scipy",
"pyproj"
"pyproj",
"ruff",
]
doc = [
"mkdocs",
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright © 2024 Norman Fomferra and contributors
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.
17 changes: 10 additions & 7 deletions tests/config/test_attrs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2024 Norman Fomferra and contributors
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.

Expand All @@ -7,14 +7,17 @@
import unittest

import numpy as np
import xarray as xr
import pytest
import xarray as xr

from zappend.config.attrs import (
ConfigAttrsUserFunctions,
eval_dyn_config_attrs,
eval_expr,
get_dyn_config_attrs_env,
has_dyn_config_attrs,
)

from zappend.config.attrs import ConfigAttrsUserFunctions
from zappend.config.attrs import eval_dyn_config_attrs
from zappend.config.attrs import eval_expr
from zappend.config.attrs import get_dyn_config_attrs_env
from zappend.config.attrs import has_dyn_config_attrs
from ..helpers import make_test_dataset


Expand Down
9 changes: 4 additions & 5 deletions tests/config/test_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2024 Norman Fomferra and contributors
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.

Expand All @@ -11,8 +11,8 @@
from zappend.context import Context
from zappend.fsutil.fileobj import FileObj
from zappend.slice import SliceSource
from ..helpers import clear_memory_fs
from ..helpers import make_test_dataset

from ..helpers import clear_memory_fs, make_test_dataset


class ConfigTest(unittest.TestCase):
Expand Down Expand Up @@ -151,8 +151,7 @@ def test_slice_source_as_type(self):
with pytest.raises(
TypeError,
match=(
"slice_source must a callable"
" or the fully qualified name of a callable"
"slice_source must a callable or the fully qualified name of a callable"
),
):
Config(
Expand Down
9 changes: 4 additions & 5 deletions tests/config/test_normalize.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2024 Norman Fomferra and contributors
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.

Expand All @@ -10,10 +10,9 @@
import pytest
import yaml

from zappend.config import exclude_from_config
from zappend.config import merge_configs
from zappend.config import normalize_config
from zappend.config import exclude_from_config, merge_configs, normalize_config
from zappend.fsutil import FileObj

from ..helpers import clear_memory_fs


Expand Down Expand Up @@ -88,7 +87,7 @@ def test_it_raises_if_config_is_not_object(self):
file_obj.write("what?")
with pytest.raises(
TypeError,
match="Invalid configuration:" " memory://config.yaml: object expected",
match="Invalid configuration: memory://config.yaml: object expected",
):
normalize_config(file_obj)

Expand Down
2 changes: 1 addition & 1 deletion tests/config/test_schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2024 Norman Fomferra and contributors
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.

Expand Down
4 changes: 2 additions & 2 deletions tests/config/test_validate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2024 Norman Fomferra and contributors
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.

Expand All @@ -23,7 +23,7 @@ def test_validate_versions_fail(self):
config = {"zarr_version": 1}
with pytest.raises(
ValueError,
match="Invalid configuration:" " 2 was expected for zarr_version",
match="Invalid configuration: 2 was expected for zarr_version",
):
validate_config(config)

Expand Down
2 changes: 1 addition & 1 deletion tests/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright © 2024 Norman Fomferra and contributors
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.
7 changes: 3 additions & 4 deletions tests/contrib/test_levels.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2024 Norman Fomferra and contributors
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.

Expand All @@ -8,11 +8,10 @@
import pytest
import xarray as xr

from zappend.fsutil import FileObj
from tests.helpers import clear_memory_fs, make_test_dataset
from zappend.contrib import write_levels
from zappend.contrib.levels import get_variables_config
from tests.helpers import clear_memory_fs
from tests.helpers import make_test_dataset
from zappend.fsutil import FileObj

try:
# noinspection PyUnresolvedReferences
Expand Down
2 changes: 1 addition & 1 deletion tests/fsutil/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright © 2024 Norman Fomferra and contributors
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.
6 changes: 3 additions & 3 deletions tests/fsutil/test_fileobj.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright © 2024 Norman Fomferra and contributors
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.

import unittest
import os.path
import unittest
import uuid

import fsspec
Expand All @@ -27,7 +27,7 @@ def test_repr(self):
"FileObj('memory://test.zarr')", repr(FileObj("memory://test.zarr"))
)
self.assertEqual(
"FileObj('memory://test.zarr'," " storage_options={'asynchronous': False})",
"FileObj('memory://test.zarr', storage_options={'asynchronous': False})",
repr(
FileObj("memory://test.zarr", storage_options=dict(asynchronous=False))
),
Expand Down
5 changes: 2 additions & 3 deletions tests/fsutil/test_path.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Copyright © 2024 Norman Fomferra and contributors
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.

import unittest

import pytest

from zappend.fsutil.path import split_components
from zappend.fsutil.path import split_parent
from zappend.fsutil.path import split_components, split_parent


class SplitFilenameTest(unittest.TestCase):
Expand Down
8 changes: 4 additions & 4 deletions tests/fsutil/test_transaction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2024 Norman Fomferra and contributors
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.

Expand All @@ -8,8 +8,8 @@
import pytest

from zappend.fsutil.fileobj import FileObj
from zappend.fsutil.transaction import Transaction
from zappend.fsutil.transaction import ROLLBACK_FILE
from zappend.fsutil.transaction import ROLLBACK_FILE, Transaction

from ..helpers import clear_memory_fs


Expand Down Expand Up @@ -175,7 +175,7 @@ def test_it_raises_if_not_used_with_with(self):
transaction = Transaction(test_root, rollback_dir)
with pytest.raises(
ValueError,
match="Transaction instance must be" " used with the 'with' statement",
match="Transaction instance must be used with the 'with' statement",
):
transaction._add_rollback_action("delete_file", "path", None)

Expand Down
Loading