You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_________________________________________________ test_pydantic_field __________________________________________________
def test_pydantic_field() -> None:
"""Test that pydantic.Field attributes are currently Uninferable.
(Eventually, we can extend the brain to support pydantic.Field)
"""
klass, instance = astroid.extract_node(
"""
from pydantic import Field
from pydantic.dataclasses import dataclass
@dataclass
class A:
name: str = Field("hi")
A.name #@
A().name #@
"""
)
inferred = klass.inferred()
assert len(inferred) == 1
> assert inferred[0] is Uninferable
E assert <Instance of pydantic.fields.FieldInfo at 0x140034371510752> is Uninferable
tests/brain/test_dataclasses.py:461: AssertionError
This problem was found when I try to package astroid 2.15.6 for ArchLinux. And I noticed that Gentoo deselected this test since 2.15.6 gentoo/gentoo@70a46fc
The text was updated successfully, but these errors were encountered:
Thank you for opening the issue. It could be that it's now easier to infer the value of pydantic fields when pydantic is actually installed without any help from the brain. Most libs' brains are tested without the lib being instaled in our continuous integration which could explain the issue. (Need investigation this is all intuition and I'm on mobile).
It seems that pydantic is missing from the requirements_full.txt.
Note also a similar test where attrs is required and the test will be skipped if attrs is not installed. attrs is in the requirements_full.txt.
Steps to reproduce
git clone https://github.com/pylint-dev/astroid.git
python3.12 -m virtualenv .venv
source ./.venv/bin/activate.fish
pip install -e .
pip install pydantic
pytest
Current behavior
Expected behavior
Test passes.
python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
output3.2.0-dev0
This problem was found when I try to package astroid 2.15.6 for ArchLinux. And I noticed that Gentoo deselected this test since 2.15.6 gentoo/gentoo@70a46fc
The text was updated successfully, but these errors were encountered: