Skip to content

Conversation

@forsyth2
Copy link
Collaborator

@forsyth2 forsyth2 commented Sep 16, 2025

Summary

Objectives:

  • Update Python support to 3.11+

Select one: This pull request is...

  • a bug fix: increment the patch version
  • a small improvement: increment the minor version
  • a new feature: increment the minor version
  • an incompatible (non-backwards compatible) API change: increment the major version

Small Change

  • To merge, I will use "Squash and merge". That is, this change should be a single commit.
  • Logic: I have visually inspected the entire pull request myself.
  • Pre-commit checks: All the pre-commits checks have passed.

@forsyth2 forsyth2 self-assigned this Sep 16, 2025
@forsyth2 forsyth2 added the DevOps CI/CD, configuration, etc. label Sep 16, 2025
@forsyth2
Copy link
Collaborator Author

Testing
lcrc_conda
cd ~/ez/zppy-interfaces
git fetch upstream main
git status
# Check for uncommitted changes
git checkout -b update-python upstream/main
git grep -n python
# Make changes to support python3.11+
rm -rf build
conda clean --all --y
conda env create -f conda/dev.yml -n zi-py-3-11-20250916
conda activate zi-py-3-11-20250916
pre-commit run --all-files
python -m pip install .
pytest tests/unit/global_time_series/test_*.py
# 10 passed in 32.19s
git commit -m "Update Python support"

@forsyth2
Copy link
Collaborator Author

This latest commit works on 3.11, 3.12, and 3.13

However, I tried the following from conda/dev.yml

# Run `pre-commit autoupdate` to get the latest pinned versions of 'rev' in
  # `.pre-commit.config.yaml`, then update the pinned versions here.

and updated conda/dev.yml accordingly.

That produced this diff:

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 90469d1..b4674af 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,10 +1,10 @@
 exclude: "docs|node_modules|migrations|.git|.tox"
-default_stages: [commit]
+default_stages: [pre-commit]
 fail_fast: true
 
 repos:
   - repo: https://github.com/pre-commit/pre-commit-hooks
-    rev: v5.0.0
+    rev: v6.0.0
     hooks:
       - id: trailing-whitespace
       - id: end-of-file-fixer
@@ -13,13 +13,13 @@ repos:
 
   # Can run individually with `pre-commit run black --all-files`
   - repo: https://github.com/psf/black
-    rev: 24.10.0
+    rev: 25.9.0
     hooks:
       - id: black
 
   # Can run individually with `pre-commit run isort --all-files`
   - repo: https://github.com/PyCQA/isort
-    rev: 5.13.2
+    rev: 6.0.1
     hooks:
       - id: isort
 
@@ -27,7 +27,7 @@ repos:
   # Need to use flake8 GitHub mirror due to CentOS git issue with GitLab
   # https://github.com/pre-commit/pre-commit/issues/1206
   - repo: https://github.com/pycqa/flake8
-    rev: 7.1.1
+    rev: 7.3.0
     hooks:
       - id: flake8
         args: ["--config=.flake8"]
@@ -35,7 +35,7 @@ repos:
 
   # Can run individually with `pre-commit run mypy --all-files`
   - repo: https://github.com/pre-commit/mirrors-mypy
-    rev: v1.11.2
+    rev: v1.18.2
     hooks:
       - id: mypy
         args: ["--config=pyproject.toml"]
diff --git a/conda/dev.yml b/conda/dev.yml
index 98e5d51..c00192f 100644
--- a/conda/dev.yml
+++ b/conda/dev.yml
@@ -32,12 +32,12 @@ dependencies:
   # =======================
   # Run `pre-commit autoupdate` to get the latest pinned versions of 'rev' in
   # `.pre-commit.config.yaml`, then update the pinned versions here.
-  - black=24.10.0
-  - flake8=7.1.1
+  - black >=25.9.0
+  - flake8 >=7.3.0
   - flake8-isort=6.1.0
-  - isort=5.13.2
-  - mypy=1.11.2
-  - pre-commit >=3.0.0
+  - isort >=6.0.1
+  - mypy >=1.18.2
+  - pre-commit >=6.0.0
   - types-PyYAML >=6.0.0
   # Developer Tools
   # =======================

Which ultimately causes the conda env create -f conda/dev.yml command to fail. Claude suggests it's because these package versions don't exist, which seems to contradict the whole point of the autoupdate command...

@forsyth2 forsyth2 marked this pull request as ready for review September 25, 2025 17:24
@xylar
Copy link
Contributor

xylar commented Sep 27, 2025

Claude suggests it's because these package versions don't exist, which seems to contradict the whole point of the autoupdate command...

The versions of packages from pre-commit autoupdate come from PyPI. It doesn't know about conda or conda-forge. The corresponding versions on conda-forge many not yet be available. The conda solver (libmamba) should be able to tell you what it couldn't find. You can then go to the corresponding feedstock and see what the deal is. Have the maintianers not yet merged that version, perhaps? In that case, the easiest would be to decrement the version to the latest on both PyPI and conda-forge but you could also just keep an eye on the feedstock to see when the version gets merged.

I will take a look at the specifics but I would try to update the versions to be as new as possible as part of this PR.

@xylar
Copy link
Contributor

xylar commented Sep 27, 2025

It appears that black 25.9.0 has not yet been built on conda-forge:
conda-forge/black-feedstock#95
The latest version is 25.1.0:
https://github.com/conda-forge/black-feedstock
https://anaconda.org/conda-forge/black/files

It looks like isort 6.0.1 is available:
https://github.com/conda-forge/isort-feedstock
as is flake8 7.3.0:
https://github.com/conda-forge/flake8-feedstock
and mypy 1.18.2:
https://github.com/conda-forge/mypy-feedstock

The latest pre-commit is 4.3.0. This is not the same thing as the pre-commit-hooks that gets updated to 6.0.0 when you run pre-commit autoupdate. But you should use the latest available pre-commit in the development environment.

I do not think you use flake8-isort, so this maybe can be removed from the conda dev envrionment.

You were switching to:

+  - black >=25.9.0
+  - flake8 >=7.3.0
+  - isort >=6.0.1
+  - mypy >=1.18.2
+  - pre-commit >=6.0.0

While the >= constraint is typically sensible, in the case of these linting and formatting tools, it is important that pre-commit and the conda development environment use the exact same versions. So these need to be ==. Otherwise, local development may result in linting one way (using the conda environment) but CI may results in another (using the versions in in .pre-commit-config.yaml. I think in practice pre-commit installs its own dependencies and ignores the conda versions installed from PyPI but regardless, it would be best to have consistent versions.

+  - black ==25.1.0
+  - flake8 ==7.3.0
+  - isort ==6.0.1
+  - mypy -=1.18.2
+  - pre-commit ==4.3.0

@xylar
Copy link
Contributor

xylar commented Sep 27, 2025

Let's get this straightened out first, then I'll review E3SM-Project/zppy#735 (and E3SM-Project/zstash#384 if you like).

@forsyth2
Copy link
Collaborator Author

forsyth2 commented Oct 1, 2025

@xylar I added b6b87f9. It appears that is passing the GitHub Actions on 3.11, 3.12, and 3.13

Copy link
Contributor

@xylar xylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me!

@forsyth2
Copy link
Collaborator Author

forsyth2 commented Oct 1, 2025

Looks great to me!

Great, I'll merge this then.

Let's get this straightened out first, then I'll review E3SM-Project/zppy#735 (and E3SM-Project/zstash#384 if you like).

Yes, that would be helpful. Thank you!

@forsyth2 forsyth2 merged commit 4f34d48 into main Oct 1, 2025
6 checks passed
@forsyth2 forsyth2 deleted the update-python branch October 1, 2025 19:01
@forsyth2 forsyth2 mentioned this pull request Oct 1, 2025
7 tasks
@forsyth2
Copy link
Collaborator Author

forsyth2 commented Oct 1, 2025

After merging this, I noticed the issue noted in #36. That issue existed before this PR, but #36 should hopefully address that.

@forsyth2 forsyth2 mentioned this pull request Oct 7, 2025
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DevOps CI/CD, configuration, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants