diff --git a/droplets/emulsions.py b/droplets/emulsions.py index 5818946..af73b3c 100644 --- a/droplets/emulsions.py +++ b/droplets/emulsions.py @@ -285,7 +285,7 @@ def data(self) -> np.ndarray: if len(classes) > 1: raise TypeError( "Emulsion data cannot be stored contiguously if it contains a " - f"multiple of droplet classes: " + "multiple of droplet classes: " + ", ".join(c.__name__ for c in classes) ) result = np.array([d.data for d in self]) diff --git a/droplets/tools/spherical.py b/droplets/tools/spherical.py index 70b9910..e2b650e 100644 --- a/droplets/tools/spherical.py +++ b/droplets/tools/spherical.py @@ -199,7 +199,7 @@ def make_volume_from_radius_nd_compiled() -> Callable[[TNumArr, int], TNumArr]: """ @register_jitable - def volume_from_radius(radius: TNumArr, dim: int) -> TNumArr: + def volume_from_radius_impl(radius: TNumArr, dim: int) -> TNumArr: if dim == 1: return 2 * radius elif dim == 2: @@ -208,7 +208,7 @@ def volume_from_radius(radius: TNumArr, dim: int) -> TNumArr: return 4 * π / 3 * radius**3 raise NotImplementedError - return volume_from_radius # type: ignore + return volume_from_radius_impl # type: ignore def surface_from_radius(radius: TNumArr, dim: int) -> TNumArr: diff --git a/pyproject.toml b/pyproject.toml index fb82667..a1ce511 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,6 +72,7 @@ select = [ "I", # isort "A", # flake8-builtins "B", # flake8-bugbear + "F", # pyflakes "C4", # flake8-comprehensions "FA", # flake8-future-annotations "ISC", # flake8-implicit-str-concat @@ -86,7 +87,7 @@ select = [ "SIM", # flake8-simplify "PTH", # flake8-use-pathlib ] -ignore = ["B007", "B027", "B028", "SIM108", "ISC001", "PT006", "PT011", "RET504", "RET505", "RET506"] +ignore = ["B007", "B027", "B028", "F401", "F403", "SIM108", "ISC001", "PT006", "PT011", "RET504", "RET505", "RET506"] [tool.ruff.lint.isort] section-order = ["future", "standard-library", "third-party", "first-party", "my-modules", "self", "local-folder"] diff --git a/scripts/format_code.sh b/scripts/format_code.sh index 8608a54..c183843 100755 --- a/scripts/format_code.sh +++ b/scripts/format_code.sh @@ -1,16 +1,11 @@ #!/usr/bin/env bash # This script formats the code of this package -echo "Upgrading python syntax..." -pushd .. > /dev/null -find . -name '*.py' -exec pyupgrade --py39-plus {} + -popd > /dev/null - -echo "Formating import statements..." +echo "Formatting import statements..." ruff check --fix --config=../pyproject.toml .. -echo "Formating docstrings..." +echo "Formatting docstrings..." docformatter --in-place --black --recursive .. -echo "Formating source code..." +echo "Formatting source code..." ruff format --config=../pyproject.toml .. \ No newline at end of file diff --git a/tests/requirements.txt b/tests/requirements.txt index eee7d9c..516cba4 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,6 +1,5 @@ -r ../requirements.txt docformatter>=1.7 -pyupgrade>=3 pytest>=5.4 pytest-cov>=2.8 pytest-xdist>=1.30 diff --git a/tests/test_image_analysis.py b/tests/test_image_analysis.py index 15a085a..b358206 100644 --- a/tests/test_image_analysis.py +++ b/tests/test_image_analysis.py @@ -99,7 +99,7 @@ def test_localization_perturbed_2d(periodic, rng): assert len(emulsion) == 1 d2 = emulsion[0] - msg = "size=%d, periodic=%s, %s != %s" % (size, periodic, d1, d2) + msg = f"{size=}, {periodic=}, {d1} != {d2}" np.testing.assert_almost_equal(d1.position, d2.position, decimal=1, err_msg=msg) assert d1.radius == pytest.approx(d2.radius, rel=1e-5) assert d1.interface_width == pytest.approx(d2.interface_width, rel=1e-3) @@ -129,7 +129,7 @@ def test_localization_perturbed_3d(periodic, rng): assert len(emulsion) == 1 d2 = emulsion[0] - msg = "size=%d, periodic=%s, %s != %s" % (size, periodic, d1, d2) + msg = f"{size=}, {periodic=}, {d1} != {d2}" np.testing.assert_almost_equal(d1.position, d2.position, decimal=1, err_msg=msg) assert d1.radius == pytest.approx(d2.radius, rel=1e-4) assert d1.interface_width == pytest.approx(d2.interface_width, rel=1e-3)