From 7f260ad59bbd6af161af46889cecb238d57a4561 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 29 May 2024 14:21:35 -0700 Subject: [PATCH 1/9] Use modern Jira URL --- doc/lsst.pex.config/CHANGES.rst | 10 +++++----- pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/lsst.pex.config/CHANGES.rst b/doc/lsst.pex.config/CHANGES.rst index ed4998c6..e34351fa 100644 --- a/doc/lsst.pex.config/CHANGES.rst +++ b/doc/lsst.pex.config/CHANGES.rst @@ -4,20 +4,20 @@ lsst-pex-config v26.0.0 (2023-09-22) New Features ------------ -- Added a dynamic-default callback argument to ``RegistryField``. (`DM-31924 `_) -- Introduced ``ConfigurableActions``. These are ``pex_config`` fields and config types which function as a functor, state is set at config time, but the ``ConfigurableActions`` are callable at runtime to produce an action. (`DM-36649 `_) +- Added a dynamic-default callback argument to ``RegistryField``. (`DM-31924 `_) +- Introduced ``ConfigurableActions``. These are ``pex_config`` fields and config types which function as a functor, state is set at config time, but the ``ConfigurableActions`` are callable at runtime to produce an action. (`DM-36649 `_) API Changes ----------- -- The ``loadFromStream`` and ``loadFromString`` methods now take a dictionary as an optional argument which allows specifying additional variables to use in local scope when reading configs. (`DM-40198 `_) +- The ``loadFromStream`` and ``loadFromString`` methods now take a dictionary as an optional argument which allows specifying additional variables to use in local scope when reading configs. (`DM-40198 `_) Other Changes and Additions --------------------------- -- There is now a requirement for configuration parameters to have a non-empty docstring. (`DM-4037 `_) +- There is now a requirement for configuration parameters to have a non-empty docstring. (`DM-4037 `_) lsst-pex-config v25.0.0 (2023-02-28) @@ -26,7 +26,7 @@ lsst-pex-config v25.0.0 (2023-02-28) Other Changes and Additions --------------------------- -- Some sorting now happens when saving config files (via DM-33027). (`DM-35060 `_) +- Some sorting now happens when saving config files (via DM-33027). (`DM-35060 `_) lsst-pex-config v24.0.0 (2022-08-30) diff --git a/pyproject.toml b/pyproject.toml index 7c47cc22..794ded48 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,7 +63,7 @@ line_length = 110 filename = "doc/lsst.pex.config/CHANGES.rst" directory = "doc/changes" title_format = "lsst-pex-config {version} ({project_date})" - issue_format = "`{issue} `_" + issue_format = "`{issue} `_" [[tool.towncrier.type]] directory = "feature" From c295bac98541afd2b07eb831e2bb31e1d0cad081 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 29 May 2024 14:22:06 -0700 Subject: [PATCH 2/9] Refresh pre-commit --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 291a0759..e26e71fc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,12 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 23.12.0 + rev: 24.4.2 hooks: - id: black # It is recommended to specify the latest version of Python @@ -20,15 +20,15 @@ repos: - id: isort name: isort (python) - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 7.0.0 hooks: - id: flake8 - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.1.8 + rev: v0.4.6 hooks: - id: ruff - repo: https://github.com/numpy/numpydoc - rev: "v1.6.0" + rev: "v1.7.0" hooks: - id: numpydoc-validation From dfcf056416b9324ccc4ad9552fa4bf6886df60c2 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 29 May 2024 14:28:27 -0700 Subject: [PATCH 3/9] Use newer action versions --- .github/workflows/build.yaml | 13 +++++++------ .github/workflows/build_docs.yaml | 4 ++-- .github/workflows/docstyle.yaml | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c2b092f2..61205625 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,13 +16,13 @@ jobs: python-version: ["3.10", "3.11"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: # Need to clone everything for the git tags. fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: "pip" @@ -47,9 +47,10 @@ jobs: run: pytest -r a -v -n 3 --open-files --cov=tests --cov=lsst.pex.config --cov-report=xml --cov-report=term - name: Upload coverage to codecov - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v4 with: - file: ./coverage.xml + files: ./coverage.xml + token: ${{ secrets.CODECOV_TOKEN }} pypi: @@ -58,13 +59,13 @@ jobs: if: startsWith(github.ref, 'refs/tags/') steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: # Need to clone everything to embed the version. fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.10" cache: "pip" diff --git a/.github/workflows/build_docs.yaml b/.github/workflows/build_docs.yaml index 5a4d7158..30d41880 100644 --- a/.github/workflows/build_docs.yaml +++ b/.github/workflows/build_docs.yaml @@ -10,13 +10,13 @@ jobs: build_sphinx_docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: # Need to clone everything to determine version from git. fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.10" cache: "pip" diff --git a/.github/workflows/docstyle.yaml b/.github/workflows/docstyle.yaml index 2f22ba93..3dd8da8d 100644 --- a/.github/workflows/docstyle.yaml +++ b/.github/workflows/docstyle.yaml @@ -14,10 +14,10 @@ jobs: numpydoc: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 - name: Install numpydoc run: | From daa4717f10e6627b80a97b1c2fb36667516fd34a Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 29 May 2024 14:29:54 -0700 Subject: [PATCH 4/9] Add release notes --- doc/lsst.pex.config/CHANGES.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/lsst.pex.config/CHANGES.rst b/doc/lsst.pex.config/CHANGES.rst index e34351fa..4611fddf 100644 --- a/doc/lsst.pex.config/CHANGES.rst +++ b/doc/lsst.pex.config/CHANGES.rst @@ -1,3 +1,9 @@ +lsst-pex-config v27.0.0 (2024-05-29) +==================================== + +- Improved all docstrings to make them compliant with Numpydoc. +- Minor code cleanups driven by Ruff linting. (`DM-42116 `_) + lsst-pex-config v26.0.0 (2023-09-22) ==================================== From bc9c4a6cad159869f7cb593dcf702e368e01a571 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 29 May 2024 14:38:38 -0700 Subject: [PATCH 5/9] Reformat using modern black --- python/lsst/pex/config/config.py | 6 ++---- python/lsst/pex/config/configChoiceField.py | 6 ++---- python/lsst/pex/config/configField.py | 6 ++---- .../configurableActions/_configurableActionField.py | 6 ++---- .../_configurableActionStructField.py | 6 ++---- python/lsst/pex/config/configurableField.py | 6 ++---- python/lsst/pex/config/listField.py | 12 ++++-------- setup.cfg | 2 +- 8 files changed, 17 insertions(+), 33 deletions(-) diff --git a/python/lsst/pex/config/config.py b/python/lsst/pex/config/config.py index 7fcdb473..a2800f3c 100644 --- a/python/lsst/pex/config/config.py +++ b/python/lsst/pex/config/config.py @@ -716,14 +716,12 @@ def toDict(self, instance): @overload def __get__( self, instance: None, owner: Any = None, at: Any = None, label: str = "default" - ) -> Field[FieldTypeVar]: - ... + ) -> Field[FieldTypeVar]: ... @overload def __get__( self, instance: Config, owner: Any = None, at: Any = None, label: str = "default" - ) -> FieldTypeVar: - ... + ) -> FieldTypeVar: ... def __get__(self, instance, owner=None, at=None, label="default"): """Define how attribute access should occur on the Config instance diff --git a/python/lsst/pex/config/configChoiceField.py b/python/lsst/pex/config/configChoiceField.py index 54d3bff2..07ea6c6c 100644 --- a/python/lsst/pex/config/configChoiceField.py +++ b/python/lsst/pex/config/configChoiceField.py @@ -519,14 +519,12 @@ def _getOrMake(self, instance, label="default"): @overload def __get__( self, instance: None, owner: Any = None, at: Any = None, label: str = "default" - ) -> ConfigChoiceField: - ... + ) -> ConfigChoiceField: ... @overload def __get__( self, instance: Config, owner: Any = None, at: Any = None, label: str = "default" - ) -> ConfigInstanceDict: - ... + ) -> ConfigInstanceDict: ... def __get__(self, instance, owner=None, at=None, label="default"): if instance is None or not isinstance(instance, Config): diff --git a/python/lsst/pex/config/configField.py b/python/lsst/pex/config/configField.py index 9fecfeab..b5cc8acd 100644 --- a/python/lsst/pex/config/configField.py +++ b/python/lsst/pex/config/configField.py @@ -99,14 +99,12 @@ def __init__(self, doc, dtype=None, default=None, check=None, deprecated=None): @overload def __get__( self, instance: None, owner: Any = None, at: Any = None, label: str = "default" - ) -> "ConfigField[FieldTypeVar]": - ... + ) -> "ConfigField[FieldTypeVar]": ... @overload def __get__( self, instance: Config, owner: Any = None, at: Any = None, label: str = "default" - ) -> FieldTypeVar: - ... + ) -> FieldTypeVar: ... def __get__(self, instance, owner=None, at=None, label="default"): if instance is None or not isinstance(instance, Config): diff --git a/python/lsst/pex/config/configurableActions/_configurableActionField.py b/python/lsst/pex/config/configurableActions/_configurableActionField.py index 3fb9c8d8..2a72c03b 100644 --- a/python/lsst/pex/config/configurableActions/_configurableActionField.py +++ b/python/lsst/pex/config/configurableActions/_configurableActionField.py @@ -93,12 +93,10 @@ def __set__( @overload def __get__( self, instance: None, owner: Any = None, at: Any = None, label: str = "default" - ) -> ConfigurableActionField[ActionTypeVar]: - ... + ) -> ConfigurableActionField[ActionTypeVar]: ... @overload - def __get__(self, instance: Config, owner: Any = None, at: Any = None, label: str = "default") -> Any: - ... + def __get__(self, instance: Config, owner: Any = None, at: Any = None, label: str = "default") -> Any: ... def __get__(self, instance, owner=None, at=None, label="default"): result = super().__get__(instance, owner) diff --git a/python/lsst/pex/config/configurableActions/_configurableActionStructField.py b/python/lsst/pex/config/configurableActions/_configurableActionStructField.py index cb0515a2..73b8f04d 100644 --- a/python/lsst/pex/config/configurableActions/_configurableActionStructField.py +++ b/python/lsst/pex/config/configurableActions/_configurableActionStructField.py @@ -354,14 +354,12 @@ def __set__( @overload def __get__( self, instance: None, owner: Any = None, at: Any = None, label: str = "default" - ) -> ConfigurableActionStruct[ActionTypeVar]: - ... + ) -> ConfigurableActionStruct[ActionTypeVar]: ... @overload def __get__( self, instance: Config, owner: Any = None, at: Any = None, label: str = "default" - ) -> ConfigurableActionStruct[ActionTypeVar]: - ... + ) -> ConfigurableActionStruct[ActionTypeVar]: ... def __get__(self, instance, owner=None, at=None, label="default"): if instance is None or not isinstance(instance, Config): diff --git a/python/lsst/pex/config/configurableField.py b/python/lsst/pex/config/configurableField.py index 51d59595..95e21795 100644 --- a/python/lsst/pex/config/configurableField.py +++ b/python/lsst/pex/config/configurableField.py @@ -360,14 +360,12 @@ def __getOrMake(self, instance, at=None, label="default"): @overload def __get__( self, instance: None, owner: Any = None, at: Any = None, label: str = "default" - ) -> ConfigurableField: - ... + ) -> ConfigurableField: ... @overload def __get__( self, instance: Config, owner: Any = None, at: Any = None, label: str = "default" - ) -> ConfigurableInstance[FieldTypeVar]: - ... + ) -> ConfigurableInstance[FieldTypeVar]: ... def __get__(self, instance, owner=None, at=None, label="default"): if instance is None or not isinstance(instance, Config): diff --git a/python/lsst/pex/config/listField.py b/python/lsst/pex/config/listField.py index c7ed4e3e..d7fdd9b6 100644 --- a/python/lsst/pex/config/listField.py +++ b/python/lsst/pex/config/listField.py @@ -144,8 +144,7 @@ def __len__(self): @overload def __setitem__( self, i: int, x: FieldTypeVar, at: Any = None, label: str = "setitem", setHistory: bool = True - ) -> None: - ... + ) -> None: ... @overload def __setitem__( @@ -155,8 +154,7 @@ def __setitem__( at: Any = None, label: str = "setitem", setHistory: bool = True, - ) -> None: - ... + ) -> None: ... def __setitem__(self, i, x, at=None, label="setitem", setHistory=True): if self._config._frozen: @@ -179,12 +177,10 @@ def __setitem__(self, i, x, at=None, label="setitem", setHistory=True): self.history.append((list(self._list), at, label)) @overload - def __getitem__(self, i: int) -> FieldTypeVar: - ... + def __getitem__(self, i: int) -> FieldTypeVar: ... @overload - def __getitem__(self, i: slice) -> MutableSequence[FieldTypeVar]: - ... + def __getitem__(self, i: slice) -> MutableSequence[FieldTypeVar]: ... def __getitem__(self, i): return self._list[i] diff --git a/setup.cfg b/setup.cfg index 3a680b97..b82bfc6d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [flake8] max-line-length = 110 max-doc-length = 79 -ignore = W503, E203, E228, N802, N803, N806, N812, N815, N816 +ignore = W503, E203, E704, N802, N803, N806, N812, N815, N816 exclude = bin, doc, From f0ec9023a8920fd0b18b7cfeea8282565a723f23 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 29 May 2024 14:48:19 -0700 Subject: [PATCH 6/9] Add python 3.12 to build matrix --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 61205625..703813cc 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 From 51cf66b302b4e3b0d185b7670134ff7b086868c8 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 29 May 2024 14:49:17 -0700 Subject: [PATCH 7/9] Indicate supported versions in pyproject file --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 794ded48..dfeb149a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "lsst-pex-config" +requires-python = ">=3.10.0" description = "A flexible configuration system using Python files." license = {text = "BSD 3-Clause License, GPLv3+"} readme = "README.rst" @@ -18,6 +19,7 @@ classifiers = [ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Scientific/Engineering :: Astronomy", ] keywords = ["lsst"] From 9ddfe197e77852ee625bf861033828ca7e61f780 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 29 May 2024 14:52:10 -0700 Subject: [PATCH 8/9] Remove pytest-opefiles from action Not support in python 3.12 --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 703813cc..da12f684 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -38,13 +38,13 @@ jobs: # We have two cores so we can speed up the testing with xdist - name: Install support package for pytest - run: pip install pytest-xdist pytest-openfiles pytest-cov + run: pip install pytest-xdist pytest-cov - name: Build and install run: pip install --no-deps -v . - name: Run tests - run: pytest -r a -v -n 3 --open-files --cov=tests --cov=lsst.pex.config --cov-report=xml --cov-report=term + run: pytest -r a -v -n 3 --cov=tests --cov=lsst.pex.config --cov-report=xml --cov-report=term - name: Upload coverage to codecov uses: codecov/codecov-action@v4 From 5978c5725c54de89426153d2dfa2c6151a8878af Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 29 May 2024 15:02:29 -0700 Subject: [PATCH 9/9] Use uv to install dependencies --- .github/workflows/build.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index da12f684..d88ad1be 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -31,17 +31,19 @@ jobs: run: sudo apt-get install libyaml-dev - name: Install prereqs for setuptools - run: pip install wheel + run: | + pip install uv + uv pip install --system wheel - name: Install dependencies - run: pip install -r requirements.txt + run: uv pip install --system -r requirements.txt # We have two cores so we can speed up the testing with xdist - name: Install support package for pytest - run: pip install pytest-xdist pytest-cov + run: uv pip install --system pytest pytest-xdist pytest-cov - name: Build and install - run: pip install --no-deps -v . + run: uv pip install --system --no-deps -v . - name: Run tests run: pytest -r a -v -n 3 --cov=tests --cov=lsst.pex.config --cov-report=xml --cov-report=term