Skip to content

pydantic BaseModel E0611 #7486

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

Closed
vainaixr opened this issue Sep 18, 2022 · 4 comments
Closed

pydantic BaseModel E0611 #7486

vainaixr opened this issue Sep 18, 2022 · 4 comments
Labels

Comments

@vainaixr
Copy link

vainaixr commented Sep 18, 2022

Bug description

I do

from pydantic import BaseModel

pylint says

E0611: No name 'BaseModel' in module 'pydantic' (no-name-in-module)

plus I do,

class UserModel(BaseModel):
    name: str
    age: int

it says R0903, too few public methods

Configuration

No response

Command used

pylint file_name.py

Pylint output

E0611: No name 'BaseModel' in module 'pydantic' (no-name-in-module)
R0903: Too few public methods (too-few-public-methods)

Expected behavior

there should be no issue with importing BaseModel from pydantic
if you see the way pydantic is used, both the issues should not be there

Pylint version

pylint 2.15.2
astroid 2.12.9
Python 3.11.0rc2

OS / Environment

No response

Additional dependencies

No response

@vainaixr vainaixr added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Sep 18, 2022
@mbyrnepr2
Copy link
Member

Thank you for the report @vainaixr.

Using the following option suppresses both issues reported by your example:

pylint  --extension-pkg-whitelist='pydantic' example.py

@Pierre-Sassoulas Pierre-Sassoulas added Question and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 19, 2022
@vainaixr
Copy link
Author

even SQLModel uses similar class attributes convention, do I keep adding all libraries to whitelist.
the whitelist solution is a workaround, could the first one that is no name in the module be solved?
the second one is related to creating a class with only class attributes in it, I think so, that should also be allowed, considering even more libraries use a similar convention.

@Pierre-Sassoulas
Copy link
Member

the whitelist solution is a workaround

You can also use --unsafe-load-any-extension=y. Be aware though that using this flag means that extensions are loaded into the active Python interpreter and may run arbitrary code, which you may not want. This is the reason why we disable by default loading C extensions.

You can disable too-few-public-methods if you don't like it, we're also going to make it optional in #3512

@mbyrnepr2
Copy link
Member

To add to Pierre's update, have a read of this page & it may give some clarity on things @vainaixr

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