From a0f699fc35c9ed04e685660808e9491b8b4ddac4 Mon Sep 17 00:00:00 2001 From: Kevin Meagher <11620178+kjmeagher@users.noreply.github.com> Date: Thu, 30 Apr 2026 12:48:11 -0500 Subject: [PATCH] python 3.10 and remove pylint --- .pre-commit-config.yaml | 9 +-------- CONTRIBUTING.rst | 2 +- examples/without_tableio.py | 4 ++-- pyproject.toml | 19 ++++--------------- src/simweights/_corsika_weighter.py | 5 +++-- src/simweights/_fluxes.py | 16 +++++++--------- src/simweights/_genie_weighter.py | 5 +++-- src/simweights/_icetop_weighter.py | 6 +++--- src/simweights/_nugen_weighter.py | 4 ++-- src/simweights/_pdgcode.py | 2 -- src/simweights/_powerlaw.py | 2 -- src/simweights/_spatial.py | 5 ++--- src/simweights/_utils.py | 8 ++++---- src/simweights/_weighter.py | 6 ++++-- 14 files changed, 36 insertions(+), 57 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da523eb..5a2c78a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,15 +27,8 @@ repos: hooks: - id: blacken-docs args: [-l 100] - - repo: https://github.com/pycqa/pylint - rev: v4.0.5 - hooks: - - id: pylint - files: simweights - exclude: ^contrib/ - additional_dependencies: [numpy, pandas] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.9 + rev: v0.15.12 hooks: - id: ruff args: [--fix, --show-fixes] diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 860b72d..51f1500 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -70,7 +70,7 @@ To run pre-commit on all files without making a commit you can just run:: in the base of the simweights directory. -The checks include isort, flake8, pylint, and mypy. +The checks include isort, and mypy. Be sure that all checks pass before submitting a pull request. Tests diff --git a/examples/without_tableio.py b/examples/without_tableio.py index 4f23506..30da789 100755 --- a/examples/without_tableio.py +++ b/examples/without_tableio.py @@ -36,8 +36,8 @@ # get the info from the frame info = frame["I3PrimaryInjectorInfo"] - for k in I3PrimaryInjectorInfo: - I3PrimaryInjectorInfo[k].append(getattr(info, k)) + for k, v in I3PrimaryInjectorInfo.items(): + v.append(getattr(info, k)) # if this is a physics event in the right sub-event stream elif frame.Stop == frame.Physics and frame["I3EventHeader"].sub_event_stream == "InIceSplit": diff --git a/pyproject.toml b/pyproject.toml index 2024bb2..f4e00ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,8 +15,6 @@ classifiers = [ 'Operating System :: MacOS :: MacOS X', 'Operating System :: POSIX :: Linux', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', @@ -31,10 +29,10 @@ keywords = ["python", "science", "astronomy", "astrophysics", "IceCube", "neutri license = {file = "LICENSES/BSD-2-Clause.txt"} name = "simweights" readme = "README.rst" -requires-python = "~=3.8" +requires-python = "~=3.10" [project.optional-dependencies] -dev = ["pytest", "pre-commit", "reuse", "ruff", "pylint"] +dev = ["pytest", "pre-commit", "reuse", "ruff"] docs = ["sphinx", "sphinx-rtd-theme", "pandas"] examples = ['matplotlib'] test = [ @@ -69,12 +67,6 @@ source = ["simweights"] [tool.doc8] max-line-length = 128 -[tool.pylint.format] -max-line-length = "128" - -[tool.pylint.messages_control] -disable = "C0114,R0902,R0913,R0917,R0914,R0911" - [tool.pytest.ini_options] addopts = ["-ra", "--strict-config", "--strict-markers", "--cov=simweights", "-W ignore"] filterwarnings = ["error"] @@ -94,19 +86,17 @@ ignore = [ "S101", # assert-used "COM812", # conflicts with ruff formatter "ISC001", # conflicts with ruff formatter - "PLR0913", # Too many arguments in function definition "PLR0911", # Too many return statement "PLW1641" # object does not implement `__hash__` method ] select = ["ALL"] [tool.ruff.lint.per-file-ignores] -"contrib/*" = ["T201"] +"contrib/*" = ["T201"] # flake8-print "examples/*" = [ "D", # pydocstyle "F401", # unused-import "T201", # flake8-print - "PLC0206", # Extracting value from dictionary without calling `.items()` "N802" # Function name should be lowercase ] "tests/*" = [ @@ -114,7 +104,6 @@ select = ["ALL"] "N", # pep8-naming "ANN", # flake8-annotations "PT", # flake8-pytest-style - "PGH001", # eval "SLF001", # private-member-access "PLR2004", # magic-value-comparison "PLR0915", # too-many-statements @@ -128,7 +117,7 @@ convention = "google" [tool.tox] legacy_tox_ini = """ [tox] -envlist = py3{10,11,12,13} +envlist = py3{10,11,12,13,14} isolated_build = True [testenv] diff --git a/src/simweights/_corsika_weighter.py b/src/simweights/_corsika_weighter.py index 7fa20f1..660130f 100644 --- a/src/simweights/_corsika_weighter.py +++ b/src/simweights/_corsika_weighter.py @@ -6,7 +6,7 @@ import numbers import warnings -from typing import TYPE_CHECKING, Any, Mapping +from typing import TYPE_CHECKING, Any import numpy as np @@ -17,6 +17,8 @@ from ._weighter import Weighter if TYPE_CHECKING: + from collections.abc import Mapping + from numpy.typing import NDArray @@ -94,7 +96,6 @@ def weight_map_corsika_surface(table: Any) -> CompositeSurface: def CorsikaWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802 - # pylint: disable=invalid-name """Weighter for CORSIKA-in-ice simulation made with I3CORSIKAReader. I3CORSIKAReader not use S-Frames and stores the surface information in an I3MapStringDouble so that diff --git a/src/simweights/_fluxes.py b/src/simweights/_fluxes.py index 974125a..eb93be4 100644 --- a/src/simweights/_fluxes.py +++ b/src/simweights/_fluxes.py @@ -1,8 +1,7 @@ # SPDX-FileCopyrightText: © 2022 the SimWeights contributors # # SPDX-License-Identifier: BSD-2-Clause -# pylint: disable=too-few-public-methods -# flake8: noqa: N801 N803 +# ruff: noqa: N801 N803 """A collection of cosmic ray flux parametrizations. @@ -19,15 +18,17 @@ from __future__ import annotations from pathlib import Path -from typing import TYPE_CHECKING, Callable, Mapping, Sequence +from typing import TYPE_CHECKING from numpy import asarray, bool_, broadcast_arrays, exp, float64, genfromtxt, int32, piecewise, sqrt from numpy import sum as nsum -from scipy.interpolate import PchipInterpolator # pylint: disable=import-error +from scipy.interpolate import PchipInterpolator from ._pdgcode import PDGCode if TYPE_CHECKING: + from collections.abc import Callable, Mapping, Sequence + from numpy.typing import ArrayLike, NDArray PDGID_4COMP = (PDGCode.PPlus, PDGCode.He4Nucleus, PDGCode.O16Nucleus, PDGCode.Fe56Nucleus) @@ -81,7 +82,6 @@ def _condition( energy: NDArray[float64], # noqa: ARG002 pdgid: NDArray[int32], ) -> list[NDArray[bool_]]: - # pylint: disable=unused-argument return [pdgid == p for p in self.pdgids] def __call__(self: CosmicRayFlux, energy: ArrayLike, pdgid: ArrayLike) -> NDArray[float64]: @@ -144,7 +144,6 @@ class Hoerandel5(CosmicRayFlux): class Hoerandel_IT(CosmicRayFlux): """Modified 5-component Hoerandel spectrum with N and Al replaced by O.""" - # pylint: disable=invalid-name pdgids = PDGID_4COMP _funcs = ( lambda E: 1.1776445965025136 * E**-2.71 * (1 + (E / (4.49e6 * 1)) ** 1.9) ** (-2.1 / 1.9), @@ -240,7 +239,6 @@ class GaisserH4a_IT(CosmicRayFlux): flux\ [#Aartsen]_. """ - # pylint: disable=invalid-name pdgids = PDGID_4COMP _funcs = ( lambda E: ( @@ -324,7 +322,7 @@ class GlobalFitGST(CosmicRayFlux): ) -class GlobalFitGST_IT(CosmicRayFlux): # pylint: disable=invalid-name +class GlobalFitGST_IT(CosmicRayFlux): r"""GlobalFitGST for four components [p, He, O, Fe]. The Oxygen group is the sum of Nitrogen and Aluminum groups of GlobalFitGST. @@ -390,7 +388,7 @@ def __init__(self: GlobalSplineFit5Comp) -> None: super().__init__() -class GlobalSplineFit_IT(GlobalSplineFitBase): # pylint: disable=invalid-name +class GlobalSplineFit_IT(GlobalSplineFitBase): r"""Sum of the flux of the GSF model for the standard 4 components injected by IceCube. [(H), (He), (Li, Be, B, C, N, O, F, Ne), (Na, Mg, Al, Si, P, S, Cl, Ar, K, Ca, Sc, Ti, V, Cr, Mn, Fe, Co, Ni)] diff --git a/src/simweights/_genie_weighter.py b/src/simweights/_genie_weighter.py index ab0e20d..0a2678f 100644 --- a/src/simweights/_genie_weighter.py +++ b/src/simweights/_genie_weighter.py @@ -4,7 +4,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Iterable, Mapping +from typing import TYPE_CHECKING, Any import numpy as np @@ -17,6 +17,8 @@ from ._weighter import Weighter if TYPE_CHECKING: # pragma: no cover + from collections.abc import Iterable, Mapping + from np.typing import ArrayLike, NDArray from simweights._pdgcode import PDGCode @@ -129,7 +131,6 @@ def genie_reader_surface(table: Iterable[Mapping[str, float]]) -> CompositeSurfa def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802 - # pylint: disable=invalid-name """Weighter for GENIE simulation. Reads ``I3GenieInfo`` from S-Frames and ``I3GenieResult`` from Q-Frames for genie-reader files diff --git a/src/simweights/_icetop_weighter.py b/src/simweights/_icetop_weighter.py index 7f59712..e20eae8 100644 --- a/src/simweights/_icetop_weighter.py +++ b/src/simweights/_icetop_weighter.py @@ -3,7 +3,8 @@ # SPDX-License-Identifier: BSD-2-Clause -from typing import Any, Mapping +from collections.abc import Mapping +from typing import Any import numpy as np @@ -40,7 +41,7 @@ def sframe_icetop_surface(table: Any) -> CompositeSurface: for i, nevents in enumerate(n_events): assert power_law_index[i] <= 0 - spectrum = PowerLaw( # pylint: disable=duplicate-code + spectrum = PowerLaw( power_law_index[i], min_energy[i], max_energy[i], @@ -58,7 +59,6 @@ def sframe_icetop_surface(table: Any) -> CompositeSurface: def IceTopWeighter(file_obj: Any) -> Weighter: # noqa: N802 - # pylint: disable=invalid-name """Weighter for IceTop CORSIKA simulation made with I3TopSimulator.cxx.""" surface = sframe_icetop_surface(get_table(file_obj, "I3TopInjectorInfo")) weighter = Weighter([file_obj], surface) diff --git a/src/simweights/_nugen_weighter.py b/src/simweights/_nugen_weighter.py index 7e28f6d..c5a4506 100644 --- a/src/simweights/_nugen_weighter.py +++ b/src/simweights/_nugen_weighter.py @@ -2,7 +2,8 @@ # # SPDX-License-Identifier: BSD-2-Clause -from typing import Any, Mapping +from collections.abc import Mapping +from typing import Any import numpy as np from numpy.typing import NDArray @@ -90,7 +91,6 @@ def nugen_surface(table: Any) -> CompositeSurface: def NuGenWeighter(file_obj: Any, nfiles: float) -> Weighter: # noqa: N802 - # pylint: disable=invalid-name """Weighter for neutrino-generator (NuGen) simulation. Does not use S-Frames and stores the surface information in an I3MapStringDouble so that the user diff --git a/src/simweights/_pdgcode.py b/src/simweights/_pdgcode.py index 7e958e5..414604e 100644 --- a/src/simweights/_pdgcode.py +++ b/src/simweights/_pdgcode.py @@ -13,8 +13,6 @@ class PDGCode(IntEnum): only used for cosmic-ray flux models and is limited to particle types in these models. """ - # pylint: disable=invalid-name - MuMinus = 13 MuPlus = -13 NuE = 12 diff --git a/src/simweights/_powerlaw.py b/src/simweights/_powerlaw.py index 468b837..285aa76 100644 --- a/src/simweights/_powerlaw.py +++ b/src/simweights/_powerlaw.py @@ -36,8 +36,6 @@ class PowerLaw: b (float): Upper bound of the support of the distribution. """ - # pylint: disable=invalid-name - def __init__(self: PowerLaw, g: float, a: float, b: float) -> None: assert b > a self.g = float(g) diff --git a/src/simweights/_spatial.py b/src/simweights/_spatial.py index d36041f..b56f312 100644 --- a/src/simweights/_spatial.py +++ b/src/simweights/_spatial.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: BSD-2-Clause from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import TYPE_CHECKING import numpy as np @@ -150,7 +150,6 @@ def __init__(self: CircleInjector, radius: float, cos_zen_min: float, cos_zen_ma def projected_area(self: CircleInjector, cos_zen: float) -> float: # noqa: ARG002 """Returns the cross sectional area of the injection area in cm^2.""" - # pylint: disable=unused-argument return self._cap def pdf(self: CircleInjector, cos_zen: ArrayLike) -> NDArray[np.float64]: @@ -174,4 +173,4 @@ def __eq__(self: CircleInjector, other: object) -> bool: ) -SpatialDist = Union[CylinderBase, CircleInjector] +SpatialDist = CylinderBase | CircleInjector diff --git a/src/simweights/_utils.py b/src/simweights/_utils.py index 7d2d11b..add4a17 100644 --- a/src/simweights/_utils.py +++ b/src/simweights/_utils.py @@ -4,18 +4,18 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Union +from typing import TYPE_CHECKING, Any import numpy as np -from numpy.random import Generator, RandomState # pylint: disable=no-name-in-module +from numpy.random import Generator, RandomState from ._pdgcode import PDGCode if TYPE_CHECKING: # pragma: no cover from numpy.typing import ArrayLike, NDArray -GeneratorType = Union[Generator, RandomState] -SeedType = Union[GeneratorType, int, None] +GeneratorType = Generator | RandomState +SeedType = GeneratorType | int | None class Column: diff --git a/src/simweights/_weighter.py b/src/simweights/_weighter.py index d8b619d..7e8c843 100644 --- a/src/simweights/_weighter.py +++ b/src/simweights/_weighter.py @@ -6,15 +6,17 @@ import inspect import warnings -from typing import TYPE_CHECKING, Any, Callable, Iterable +from typing import TYPE_CHECKING, Any import numpy as np -from scipy.integrate import quad # pylint: disable=import-error +from scipy.integrate import quad from ._generation_surface import CompositeSurface from ._utils import get_column, get_table if TYPE_CHECKING: + from collections.abc import Callable, Iterable + from numpy.typing import ArrayLike, NDArray