Skip to content

Fix Python 3.12 compatibility - #362

Merged
mortenwh merged 2 commits into
masterfrom
issue361_py312
Jun 23, 2026
Merged

Fix Python 3.12 compatibility#362
mortenwh merged 2 commits into
masterfrom
issue361_py312

Conversation

@mortenwh

Copy link
Copy Markdown
Collaborator

Replace deprecated pkg_resources.resource_string with importlib.resources.files().joinpath().read_bytes() across all source and test files. pkg_resources is no longer available without an explicit setuptools dependency in Python 3.12+.

Add missing responsible_unit field to storage_information in mmd_elements.yaml to match the MMD XSD schema.

Fix test isolation issue in test_nc_to_mmd.py by closing netCDF4 Dataset handles after use in test_separate_repeated and testNc_to_mmd_get_geographic_extent_polygon.

Update pyproject.toml:

  • Replace Python 3.8 classifier with 3.12
  • Set requires-python >= 3.9 (importlib.resources.files requires Python 3.9+)
  • Relax netCDF4 constraint from ~=1.5 to >=1.5

Fixes #361

Summary: closes #361

Related issue: #361

Suggested reviewer(s):

Reviewer checklist:

  • The headers of all files contain a reference to the repository license (i.e., "License: This file is part of py-mmd-tools, licensed under the Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0)")
  • 100% test coverage of new code - meaning:
    • The overall test coverage increased or remained the same as before
    • Every function is accompanied with a test suite
    • Tests are both positive (testing that the function work as intended with valid data) and negative (testing that the function behaves as expected with invalid data, e.g., that correct exceptions are thrown)
    • Functions with optional arguments have separate tests for all options
  • Examples are supported by doctests
  • All tests are passing
  • All names (e.g., files, classes, functions, variables) are explicit
  • Documentation (as docstrings) is complete and understandable

The checklist is based on the S-ENDA conventions and definition of done (see https://s-enda-documentation.readthedocs.io/en/latest/general_conventions.html). The above points are not necessarily relevant to all contributions. In that case, please add a short explanation to help the reviewer.

Replace deprecated pkg_resources.resource_string with
importlib.resources.files().joinpath().read_bytes() across all
source and test files. pkg_resources is no longer available
without an explicit setuptools dependency in Python 3.12+.

Add missing `responsible_unit` field to storage_information in
mmd_elements.yaml to match the MMD XSD schema.

Fix test isolation issue in test_nc_to_mmd.py by closing
netCDF4 Dataset handles after use in test_separate_repeated
and testNc_to_mmd_get_geographic_extent_polygon.

Update pyproject.toml:
- Replace Python 3.8 classifier with 3.12
- Set requires-python >= 3.9 (importlib.resources.files
  requires Python 3.9+)
- Relax netCDF4 constraint from ~=1.5 to >=1.5

Fixes #361

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mortenwh
mortenwh requested a review from charlienegri June 22, 2026 13:25
Fix 105 E501 line-too-long violations introduced by the
importlib.resources migration:
- Add _mmd_yaml() helper in test_nc_to_mmd.py to replace 104
  repeated inline yaml.load(files(...).read_bytes(), ...) calls
- Break long lines in mmd_to_nc.py, yaml_to_adoc.py and
  test_mmd_yaml_vs_xsd.py

Update GitHub Actions workflows:
- tests.yml: drop Python 3.8, add 3.12 to matrix; bump
  actions/setup-python to v5, actions/checkout to v4,
  codecov/codecov-action to v5
- syntax.yml: bump actions/setup-python to v5,
  actions/checkout to v4
- tagpr.yml: bump actions/checkout to v4

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mortenwh
mortenwh merged commit 21de758 into master Jun 23, 2026
7 checks passed
@mortenwh
mortenwh deleted the issue361_py312 branch June 23, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Python 3.12 compatibility

2 participants