Skip to content

enable Python 3.10 support - #6

Merged
gerchowl merged 2 commits into
MorePET:devfrom
bernhard-42:py310
Apr 15, 2026
Merged

gerchowl merged 2 commits into
MorePET:devfrom
bernhard-42:py310

Conversation

@bernhard-42

Copy link
Copy Markdown
Contributor

Description

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

We would like to use py-materials as the materials provider for build123d, see #3
build123d supports Python 3.10 - 3.14
We were wondering whether py-materials could also support Python 3.10

As far as I can see, the only issue is the use of tomllib, however there is a proven workaround with tomli in Python 3.10.

This PR adds tomli conditionally as 3.10 dependency and has a Python version checked import of tomli or tomllib

CC: @gumyr

Changelog Entry

 ### Added
 - Python 3.10 support

Testing

I just ran the pytest suite under Python 3.10 and it created the same result as under Python 3.14

Manual Testing Details

Run the pytest suite under Python 3.10

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

None

Refs:

(#3)

bernhard-42 and others added 2 commits April 15, 2026 14:08
Bernhard's patch (33a86b3) adds Python 3.10 support via a
`tomllib`→`tomli` shim, but did not extend the CI matrix to
actually test on 3.10. Without a matrix cell, the package would
claim support we don't verify.

Adds three new matrix cells so every supported Python gets a
status check on every PR:

- `Tests (py3.10, all)` — tomli shim path
- `Tests (py3.11, all)` — stdlib tomllib, first supported version
- (3.12 and 3.13 cells already existed)

Verified locally: 133 passed / 11 skipped on 3.10 (parity with
3.12). 11 skipped are pymatgen-gated tests that skip on pymatgen's
own Python constraints, not a 3.10 issue.

Also refreshes uv.lock for the relaxed `requires-python = ">=3.10"`.
Some pandas/scipy/pymatgen/pint entries now carry multiple versions
in the universal resolution because they have different Python-
version compatibility windows — standard uv behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@gerchowl
gerchowl changed the base branch from main to dev April 15, 2026 12:10
@gerchowl
gerchowl merged commit 4cf99a1 into MorePET:dev Apr 15, 2026
16 checks passed
gerchowl added a commit that referenced this pull request Apr 15, 2026
- pyproject.toml: version 2.0.5 → 2.1.0
- src/pymat/__init__.py: __version__ synced to 2.1.0
  (was stuck at 2.0.4 after the 2.0.5 release — pre-existing drift)
- CHANGELOG.md: new [2.1.0] section covering everything since v2.0.5:
  Material.molar_mass + pymat.elements (new API), Python 3.10 support
  (#6), enricher docstring rewrite, ADR infrastructure, infrastructure
  work (rulesets, matrix CI, Rust gate, .typos.toml safety net,
  sync-main-to-dev merge-tree fix, template refresh, dependabot
  security bumps).

Semver: MINOR bump justified by new public API surface
(Material.molar_mass, Material.molar_mass_qty, pymat.elements module)
and expanded Python version support (3.10 added). No breaking changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@gerchowl gerchowl mentioned this pull request Apr 15, 2026
6 tasks done
gerchowl added a commit to gerchowl/build123d that referenced this pull request Apr 15, 2026
py-materials 2.1.0 shipped earlier today with Python 3.10 support via
@bernhard-42's own tomli shim (MorePET/mat#6). The two temporary
commits that dropped 3.10 from this PR (bbb193c "temporarily remove
Python 3.10 for compatibility with py-materials" and 6c0699d "use
Python 3.11 instead of 3.10 for CI/CD") are no longer needed.

- pyproject.toml:
  - `requires-python = ">= 3.11, < 3.15"` → `">= 3.10, < 3.15"`
  - `py-materials >= 2.0.5, < 2.1.0` → `py-materials >= 2.1.0, < 3.0.0`
- .readthedocs.yaml: `python: "3.11"` → `"3.10"`
- .github/workflows/{coverage,lint,test,type}.yml: 3.11 → 3.10

Verified on Python 3.10 locally:

- `uv run --python 3.10 --isolated --extra development --extra ocp_vscode`
  installs cleanly with py-materials 2.1.0
- `import build123d` works; 1871 tests collect without error
- `pytest -k "material or mass"` → 32 passed, 2 skipped (pre-existing)
- End-to-end smoke test: `box.material = "brass"` (string catalog
  lookup via py-materials) + `box.mass` returns a real number, not a
  1.0-fallback warning
- Closes the "open blocker" listed in gumyr#1270's description

Refs MorePET/mat#6 (Python 3.10 support in py-materials)
Refs MorePET/mat#3 (overall collaboration thread)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
gerchowl added a commit that referenced this pull request May 5, 2026
…183)

Per ADR-0003, `_stddev` is loader sugar — not a parallel set of
dataclass fields. The existing in-value `{nominal, stddev}` form
remains canonical (now also routed through `_parse_value` for
property scalars, not just compositions). Sibling sugar exists
for hand-edited TOML ergonomics.

Loader (src/pymat/loader.py):
- Two-pass `update_properties`: collect `<base>_stddev` siblings,
  then route each value through `_parse_value` and fold sibling
  stddev into a ufloat at assignment time.
- Hard error on double-specification (in-value `{nominal, stddev}`
  AND sibling `_stddev`) — silent precedence is worse than failure.
- Hard error on orphan stddev (`density_stddev` with no base value).

Boundary helpers (per ADR-0003 #6):
- `Material.density_g_mm3` coerces ufloat → nominal float for
  build123d (which can't accept ufloats in mass calculations).
- pymat-mcp `_nominal()` helper applied at JSON boundaries
  (`_props_dict`, `_brief`, `compute_mass`) so agents never see
  a ufloat that `json.dumps` can't serialize.

Tests:
- `tests/test_stddev_sugar.py` (11 tests): sibling sugar + value form
  + double-spec + orphan + zero stddev + multiple fields per group +
  density_g_mm3 boundary + mass_from_volume_mm3 boundary.
- `clients/python/pymat-mcp/tests/test_tools.py::TestComputeMass::
  test_ufloat_density_returns_plain_floats`: end-to-end JSON round-trip
  with a ufloat density.

Full suite: 499 passed, 11 skipped, no regressions.

Closes #149
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.

2 participants