Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_pydantic_field failes #2392

Open
FantasqueX opened this issue Feb 28, 2024 · 2 comments
Open

test_pydantic_field failes #2392

FantasqueX opened this issue Feb 28, 2024 · 2 comments
Labels
Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning

Comments

@FantasqueX
Copy link

Steps to reproduce

  1. git clone https://github.com/pylint-dev/astroid.git
  2. python3.12 -m virtualenv .venv
  3. source ./.venv/bin/activate.fish
  4. pip install -e .
  5. pip install pydantic
  6. pytest

Current behavior

_________________________________________________ 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

Expected behavior

Test passes.

python -c "from astroid import __pkginfo__; print(__pkginfo__.version)" output

3.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

@Pierre-Sassoulas
Copy link
Member

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).

@Pierre-Sassoulas Pierre-Sassoulas added the Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning label Feb 29, 2024
@mbyrnepr2
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning
Projects
None yet
Development

No branches or pull requests

3 participants