koxudaxi / pydantic-pycharm-plugin

PyCharm plugin for pydantic. This plugin provides autocompletion, inspection, type-checking, inserting unfilled argument, and more.
https://koxudaxi.github.io/pydantic-pycharm-plugin/
MIT License
437 stars 14 forks source link

Does not mark unresolved references for optional inner models #927

Open chbndrhnns opened 2 months ago

chbndrhnns commented 2 months ago

Describe the bug Missing warning for unresolved reference.

To Reproduce

from typing import Optional

from pydantic import BaseModel

class Inner(BaseModel):
    id: int
    name: str

class Outer(BaseModel):
    inner: Optional[Inner] = None

def test_():
    actual = Outer()
    assert actual.other
    assert actual.inner.other

Expected behavior PyCharm points out that other is no field on inner. Compare with actual.other where the unresolved reference is triggering a warning.

Screenshots

Screenshot 2024-04-22 at 13 38 57

Environments (please complete the following information):

Additional context Add any other context about the problem here.

chbndrhnns commented 2 months ago

Reproduction: https://github.com/chbndrhnns/pydantic-pycharm-plugin/tree/optional-inner