Drop pydantic v1 fallback#114
Conversation
The optking/v1/optparams.py module imported from pydantic.v1, whose compatibility shim does not work on Python 3.14. Fedora's RPM build import-checks every submodule and fails on optking.v1.optparams even though the runtime selector never reaches it. Since the package already had a fully migrated optking/v2/optparams.py, drop v1 entirely and require pydantic >= 2. - Remove optking/v1/optparams.py - Always use optking.v2.optparams as op in optking/__init__.py - Drop pydantic.v1.error_wrappers ValidationError import in optwrapper - Bump install_requires to pydantic >= 2 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
@susilehtola, my aim in letting optking keep taking in qcschema v1 and emitting v1 and likewise v2 was so that older codebases needing optking (like psi4 v1.10) could keep working with latest optking rather than retroactively needing an optking version constraint (possible but involved on conda; impossible in general). @AlexHeide, you might try checking the python version and only for <314 importing the |
If I'm understanding things correctly. Adding a version check for python 3.14 won't affect the RPM build system.
Susi, would just adding an exception to the import check so that optking.v1 doesn't get import checked be acceptable/possible? I'm not super familiar with RPM packaging but it looks to me like there's an I'm a little hesitant to drop pydantic v1 right now. I suppose we could rename |
Oh, got it. https://github.com/psi-rking/optking/blob/master/optking/v1/optparams.py#L14 will be ok for submodule import, so it's only the two classes that will be problematic. I don't like indenting most of the file, but you could possibly leave the top and bottom as-is and only define the two classes if <314. possibly have to assign them to |
Summary
Closes #113
optking/v1/optparams.pymodule imports frompydantic.v1, whose compatibility shim is broken on Python 3.14 (raisesRuntimeError: no validator found for <class 'pydantic.v1.fields.UndefinedType'>at module import time).optking.v1.optparams, even though the runtime selector inoptking/__init__.pynever reaches it when pydantic 2 is installed.optking/v2/optparams.pyis already a complete, working pydantic-v2 implementation, drop the v1 fallback entirely.Changes
optking/v1/optparams.py.optking/__init__.py: drop thepydantic.__version__ < 2branch; alwaysfrom .v2 import optparams as op.optking/optwrapper.py: removefrom pydantic.v1.error_wrappers import ValidationError as v1ValidationErrorand collapse the(ValidationError, v1ValidationError)tuples to plainValidationError.setup.py: bumpinstall_requirestopydantic>=2.Test plan
import optkingsucceeds under pydantic 2.12 / Python 3.14OptParamsregex validation still rejects/accepts the same inputs covered bytest_options.py::test_regex_validationCustomHelperround-trip (to_dict->from_dict) works with a v2 QCSchemaOptimizationInput🤖 Generated with Claude Code