IBM / lmctl

Cloud Pak for Network Automation (CP4NA) (previously ALM/TNCO) command line tool
Apache License 2.0
4 stars 19 forks source link

Uplift Pydantic version to V2 #200

Closed Sums047 closed 1 week ago

Sums047 commented 1 month ago

Issue: https://github.com/IBM/lmctl/issues/199

Changes in the PR for uplifting to Pydantic V2

  1. Added more explicit type annotation indicating that the field can be either a string or None e.g endpoint: Optional[str] = None
  2. As parse_obj_as is deprecated, using TypeAdapter for parsing and converting types
  3. Replaced @root_validator(pre=True) to @model_validator(mode='before') and handling values as either ArgsKwargs or a dictionary.
  4. Replaced constr with Annotated for defining string constraints.
  5. There are some differences in how error messages are presented in Pydantic v2, added changes for better readability. For example, the transition from general error types like type_error to more specific ones such as value_error or dict_type is handled.
Sums047 commented 1 month ago

Tested for lmctl config environments on multiple updates. Which excludes fields that have no value and fields that are set to the default value.