SCEDC / ground-motion-packet

Description of GMP —A GeoJSON Specification for Ground Motion Metrics
3 stars 6 forks source link

Not compatible with pydantic 2.0 #48

Closed emthompson-usgs closed 1 year ago

emthompson-usgs commented 1 year ago

Note that we get a new error with pydantic 2.0. We could pin to an older version, but of course it would be better to resolve the error, that I do not yet understand. Here is the error I get when running the gmprocess unit tests:

tests/gmprocess/utils/gmpacket_writer_test.py:12: in <module>
    from gmpacket.packet import GroundMotionPacket
../../../miniconda3/envs/gmprocess/lib/python3.10/site-packages/gmpacket/packet.py:15: in <module>
    from gmpacket.feature import Feature
../../../miniconda3/envs/gmprocess/lib/python3.10/site-packages/gmpacket/feature.py:193: in <module>
    class FeatureGeometry(BaseModel):
../../../miniconda3/envs/gmprocess/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:95: in __new__
    private_attributes = inspect_namespace(
../../../miniconda3/envs/gmprocess/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:328: in inspect_namespace
    raise PydanticUserError(
E   pydantic.errors.PydanticUserError: A non-annotated attribute was detected: `type = 'Point'`. All model fields require a type annotation; if `type` is not meant to be a field, you may be able to resolve this error by annotating it as a `ClassVar` or updating `model_config['ignored_types']`.
E
E   For further information visit https://errors.pydantic.dev/2.0/u/model-field-missing-annotation
====================================== warnings summary =======================================
../../../miniconda3/envs/gmprocess/lib/python3.10/site-packages/pydantic/_internal/_config.py:257
  /Users/emthompson/miniconda3/envs/gmprocess/lib/python3.10/site-packages/pydantic/_internal/_config.py:257: UserWarning: Valid config keys have changed in V2:
  * 'json_encoders' has been removed
    warnings.warn(message, UserWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=================================== short test summary info ===================================
ERROR tests/gmprocess/utils/gmpacket_writer_test.py - pydantic.errors.PydanticUserError: A non-annotated attribute was detected: `type = 'Point'...
!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================= 1 warning, 1 error in 2.02s =================================
emthompson-usgs commented 1 year ago

Closed by #49.