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

Lost fields whisper when __init__ is overriden #344

Open
1oglop1 opened this issue Jul 26, 2021 · 5 comments
Open

Lost fields whisper when __init__ is overriden #344

1oglop1 opened this issue Jul 26, 2021 · 5 comments
Labels

Comments

@1oglop1
Copy link

1oglop1 commented Jul 26, 2021

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

To Reproduce

from pydantic import BaseModel

class A(BaseModel):
    a: str

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

class B(A):
    b: str

B()

image

Expected behavior
Completion should whisper arguments
image

Environments (please complete the following information):

  • IDE: PyCharm Pro 2021.1.3
  • OS: ubuntu 21.04
  • Pydantic Version 1.8.2
  • Plugin version 0.3.4

Additional context
Add any other context about the problem here.

@koxudaxi
Copy link
Owner

koxudaxi commented Aug 1, 2021

@1oglop1
Thank you for creating this issue.

There is an option for ignoring the __init__.
You should create pyproject.toml

[tool.pydantic-pycharm-plugin]
ignore-init-method-arguments = true

The detail is in the link.
https://koxudaxi.github.io/pydantic-pycharm-plugin/ignore-init-arguments/

@1oglop1
Copy link
Author

1oglop1 commented Aug 1, 2021

Ooh thanks! I missed that!
However, I'd expect this option to be available via PyCharm UI. I feel like this is a developer-specific option and unrelated to the project. Having this in pyproject.toml forces this setting on other developers editors.

I think that .editorconfig may be a more appropriate file to set this on the repository level.

What do you think about that?

@koxudaxi
Copy link
Owner

koxudaxi commented Aug 3, 2021

@1oglop1
I agree.
We should think that where we should manage the options.

I didn't have the idea of using .editorconfig 👀

I can add the toggle button for the option on PyCharm UI.
But, if the option is set in the file then I don't know what should be the behavior. 🤔
What do you think about it?

@1oglop1
Copy link
Author

1oglop1 commented Aug 4, 2021

hmm, I think following what .editorconfig does should be the behaviour.
Reading the docs: https://www.jetbrains.com/help/pycharm/configuring-code-style.html#editorconfig

If anything is not defined in .editorconfig, it's taken from the project settings.

It feels like .editorconfig is overriding the project settings, unfortunately, it does not mention what really happens when you set a different value in the project Setting while this value comes from the .editorconfig

So I'd say that configuration in .pyproject.toml takes the priority over UI.
I'm not sure how PyCharm handles that exactly but there are few options I have in mind (without understanding the PyCharm API)
So if configuration value is detected in pyproject.toml

  1. PyCharm UI toggle/s is grayed out
  2. PyCharm UI displays a warning that "some options are overridden from pyproject.toml" (or note per option if there is more of them)
  3. PyCharm UI is still toggleable but has no effect.

@linpan
Copy link

linpan commented May 6, 2024

class HeroBase(SQLModel):
name: str = Field(index=True)
secret_name: str
age: int | None = Field(default=None, index=True)

class Hero(HeroBase, table=True):
id: int | None = Field(default=None, primary_key=True),

Here.age not autocomplete.

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

No branches or pull requests

3 participants