diff --git a/src/psygnal/_evented_model.py b/src/psygnal/_evented_model.py index 684c9308..c3369401 100644 --- a/src/psygnal/_evented_model.py +++ b/src/psygnal/_evented_model.py @@ -363,7 +363,7 @@ class Config: f"{prop!r} is not." ) for field in fields: - if not hasattr(cls, field): + if field not in model_fields and not hasattr(cls, field): warnings.warn( f"property {prop!r} cannot depend on unrecognized attribute " f"name: {field!r}", diff --git a/tests/test_evented_model.py b/tests/test_evented_model.py index c4fcae45..dedcd0fa 100644 --- a/tests/test_evented_model.py +++ b/tests/test_evented_model.py @@ -586,7 +586,7 @@ class Config: def test_unrecognized_property_dependencies(): - with pytest.warns(UserWarning, match="Unrecognized field dependency: 'b'"): + with pytest.warns(UserWarning, match="cannot depend on unrecognized attribute"): class M(EventedModel): x: int