diffsync icon indicating copy to clipboard operation
diffsync copied to clipboard

field "model_flags" conflicts with Pydantic 2 protected namespaces

Open dnewood opened this issue 1 year ago • 7 comments

Environment

  • DiffSync version: 2.0.0
  • Python version Python 3.10.12

Observed Behavior

Getting warning logs from Pydantic about protected namespace violations within the DiffSync library

Expected Behavior

No logging output at the warning level

Steps to Reproduce

  1. python3 -i
  2. from diffsync import DiffSyncModel

Extra Information

Pydantic introduces protected namespaces in their new documentation that places warning logs for things like model_ fields documentation here

potential workaround is to use the ConfigDict to set protected_namespaces to an empty value.

class Device(DiffSyncModel):
    """common model used for Diffsync"""
    
    # Disables new Pydantic v2 protections since diffsync uses model_ fields
    model_config = ConfigDict(
        protected_namespaces=()
    )

However, this does not prevent the log entries from the diffsync BaseModel here: https://github.com/networktocode/diffsync/blob/13f5150d66ec76b637f56c908d1ab300bf63661d/diffsync/init.py#L110

dnewood avatar Feb 12 '24 20:02 dnewood