Skip to content

Update pre-commit config and fix all issues #604

@ggmarshall

Description

@ggmarshall

This should be the new pre-commit config:

ci:
  autoupdate_commit_msg: "chore: update pre-commit hooks"
  autoupdate_schedule: "quarterly"
  autofix_commit_msg: "style: pre-commit fixes"

exclude: ^(attic|src/pygama/flow/datagroup.py)
repos:
  - repo: https://github.com/adamchainz/blacken-docs
    rev: "1.19.1"
    hooks:
      - id: blacken-docs
        additional_dependencies: [black==23.*]

  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: "v5.0.0"
    hooks:
      - id: check-added-large-files
      - id: check-case-conflict
      - id: check-executables-have-shebangs
      - id: check-merge-conflict
      - id: check-symlinks
      - id: check-yaml
      - id: check-json
      - id: check-toml
      - id: debug-statements
      - id: end-of-file-fixer
      - id: forbid-new-submodules
      - id: mixed-line-ending
      - id: requirements-txt-fixer
      - id: trailing-whitespace

  - repo: https://github.com/kynan/nbstripout
    rev: "0.8.1"
    hooks:
      - id: nbstripout
        args:
          [
            "--drop-empty-cells",
            "--extra-keys",
            "metadata.kernelspec metadata.language_info",
          ]

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: "v0.11.4"
    hooks:
      - id: ruff
        args: ["--fix", "--show-fixes"]
      - id: ruff-format

  - repo: https://github.com/codespell-project/codespell
    rev: "v2.4.1"
    hooks:
      - id: codespell
        additional_dependencies:
          - tomli

  - repo: https://github.com/shellcheck-py/shellcheck-py
    rev: "v0.10.0.1"
    hooks:
      - id: shellcheck

  - repo: https://github.com/pre-commit/pygrep-hooks
    rev: "v1.10.0"
    hooks:
      - id: python-no-log-warn
      - id: rst-backticks
      - id: rst-directive-colons
      - id: rst-inline-touching-normal

  - repo: https://github.com/rbubley/mirrors-prettier
    rev: "v3.5.1"
    hooks:
      - id: prettier
        types_or: [yaml]
      - id: prettier
        types_or: [markdown, html, css, scss, javascript, json]
        args: [--prose-wrap=always]

  - repo: https://github.com/abravalheri/validate-pyproject
    rev: v0.24.1
    hooks:
      - id: validate-pyproject

  - repo: https://github.com/python-jsonschema/check-jsonschema
    rev: 0.32.1
    hooks:
      - id: check-dependabot
      - id: check-github-workflows
      - id: check-readthedocs

And this should be the new pyproject.toml

[build-system]
requires = [
    "setuptools>=61.2",
    "setuptools_scm[toml]>=7",
]
build-backend = "setuptools.build_meta"

[project]
name = "pygama"
description = "Python package for data processing and analysis"
authors = [
    { name = "The LEGEND collaboration" },
]
maintainers = [
    { name = "The LEGEND collaboration" },
]
readme = "README.md"
classifiers = [
    "Development Status :: 4 - Beta",
    "Intended Audience :: Developers",
    "Intended Audience :: Science/Research",
    "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
    "Operating System :: MacOS",
    "Operating System :: POSIX",
    "Operating System :: Unix",
    "Programming Language :: Python",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3 :: Only",
    "Topic :: Scientific/Engineering",
]
requires-python = ">=3.9"
dependencies = [
    "hist",
    "colorlog",
    "dbetto",
    "dspeed>=1.7",
    "h5py>=3.2",
    "iminuit",
    "legend-pydataobj>=1.12",
    "pylegendmeta>=0.9",
    "matplotlib",
    "numba!=0.53.*,!=0.54.*,!=0.57",
    "numpy>=1.21",
    "pandas>=1.4.4",
    "tables",
    "numpy==1.26.4; python_version == '3.9'", # HACK: remove when ending support for python 3.9
    "pandas==1.5.3; python_version == '3.9'", # HACK: remove when ending support for python 3.9
    "tables==3.9.2; python_version == '3.9'", # HACK: remove when ending support for python 3.9
    "pint",
    "pyyaml",
    "scikit-learn",
    "scipy>=1.0.1",
    "tqdm>=4.66",
]
dynamic = [
    "version",
]

[project.urls]
Homepage = "https://github.com/legend-exp/pygama"
"Bug Tracker" = "https://github.com/legend-exp/pygama/issues"
Discussions = "https://github.com/legend-exp/pygama/discussions"
Changelog = "https://github.com/legend-exp/pygama/releases"

[tool.setuptools_scm]
write_to = "src/pygama/_version.py"

[project.optional-dependencies]
all = [
    "pygama[docs,test]",
]
docs = [
    "furo",
    "jupyter",
    "myst-parser",
    "nbsphinx",
    "sphinx",
    "sphinx-copybutton",
    "sphinx-inline-tabs",
]
test = [
    "pre-commit",
    "pylegendtestdata",
    "pytest>=6.0",
    "pytest-cov",
]

[project.scripts]
pygama = "pygama.cli:pygama_cli"

[tool.setuptools]
include-package-data = true
zip-safe = false
license-files = [
    "LICENSE",
]

[tool.setuptools.package-dir]
"" = "src"

[tool.setuptools.packages.find]
where = [
    "src",
]
namespaces = false

[tool.setuptools.package-data]
"*" = [
    "*.json",
]

[tool.codespell]
ignore-words-list = "hist, gaus, nd, ans, crate, nin, puls, spms, fom, FOM"

[tool.pytest.ini_options]
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
log_cli_level = "INFO"
testpaths = "tests"

[tool.coverage]
run.source = ["pygama"]
report.exclude_also = [
  '\.\.\.',
  'if typing.TYPE_CHECKING:',
]

[tool.ruff]
src = ["src"]

[tool.ruff.lint]
extend-select = [
  "B",        # flake8-bugbear
  "I",        # isort
  "ARG",      # flake8-unused-arguments
  "C4",       # flake8-comprehensions
  "EM",       # flake8-errmsg
  "ICN",      # flake8-import-conventions
  "G",        # flake8-logging-format
  "PGH",      # pygrep-hooks
  "PIE",      # flake8-pie
  "PL",       # pylint
  "PT",       # flake8-pytest-style
  "PTH",      # flake8-use-pathlib
  "RET",      # flake8-return
  "RUF",      # Ruff-specific
  "SIM",      # flake8-simplify
  "T20",      # flake8-print
  "UP",       # pyupgrade
  "YTT",      # flake8-2020
  "EXE",      # flake8-executable
  "NPY",      # NumPy specific rules
  "PD",       # pandas-vet
]
ignore = [
  "PLR09",    # Too many <...>
  "PLR2004",  # Magic value used in comparison
  "ISC001",   # Conflicts with formatter
  "PT011",
]
isort.required-imports = ["from __future__ import annotations"]
# Uncomment if using a _compat.typing backport
# typing-modules = ["lgdo._compat.typing"]

[tool.ruff.lint.per-file-ignores]
"tests/**" = ["T20"]
"noxfile.py" = ["T20"]
"docs/source/notebooks/*" = ["T201", "E402"]

[tool.pylint]
py-version = "3.8"
ignore-paths = [".*/_version.py"]
reports.output-format = "colorized"
similarities.ignore-imports = "yes"
messages_control.disable = [
  "design",
  "fixme",
  "line-too-long",
  "missing-module-docstring",
  "wrong-import-position",
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions