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

@pydantic.dataclasses.dataclass not working as @dataclasses.dataclass #920

Open
trim21 opened this issue Apr 14, 2024 · 1 comment
Open

Comments

@trim21
Copy link

trim21 commented Apr 14, 2024

Describe the bug
A clear and concise description of what the bug is.

@pydantic.dataclasses.dataclass's __init__ type hint stop working

To Reproduce
Steps to reproduce the behavior:

  1. install ide, plugin and pydantic
  2. copy file content
  3. try auto-complete
  4. and it's not woking

Expected behavior
A clear and concise description of what you expected to happen.
should work as stdlib dataclasses
image

Screenshots
If applicable, add screenshots to help explain your problem.
Also, gif movies are recommended.

Environments (please complete the following information):

  • IDE: PyCharm Pro 2024.1
  • OS: win10
  • Pydantic Version: 2.7.0
  • Plugin version: 0.4.12
  • Python version: 3.11.9

Additional context
Add any other context about the problem here.

import enum

import pydantic.dataclasses


@enum.verify(enum.UNIQUE)
class SeedingStrategy(enum.Enum):
    Rolling = "rolling"
    Reserve = "reserve"


@enum.verify(enum.UNIQUE)
class Website(enum.StrEnum):
    a = "a"
    b = "b"

    def category(self):
        if self in [e for e in Website]:
            return self

        raise Exception("missing category config")


@pydantic.dataclasses.dataclass
class Config:
    site: Website
    cluster: str

    strategy: SeedingStrategy

    qb_category: str

    qb_max_queue: int = 5
    qb_tags: list = pydantic.Field([])

    sample_rate: float = pydantic.Field(default=1, gt=0, le=1)


if __name__ == "__main__":
    Config(sa|) # <- cursor here

image

@trim21
Copy link
Author

trim21 commented Apr 14, 2024

emmmm, this can be fixed by changing import pydantic to from pydantic import dataclasses and replace @pydantic.dataclasses.dataclass with @dataclasses.dataclass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant