-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Missing Member for Pydantic Model #8759
Comments
Thank you @alvinmaottd. This is the same situation as the comment in issue 4562. While the fix in 4562 addressed the false negatives, it didn't address the false positive. I've been thinking about what to do here and I wonder what others think about this: Re-introduce the false-negatives from 4562 while also removing the false positive. The rationale for doing this would be:
Note for simplicity of reproducing, I've re-written your code example: from pydantic import BaseModel
class Response(BaseModel):
versionInfo: dict[str, str]
fm: dict[int, float]
rr = Response(versionInfo={}, fm={})
rr.versionInfo = rr.versionInfo | {"hi":"bye"} # Currently a false-positive but we could change this behaviour to ignore no-member if we find `versionInfo: <some annotation>` on the class @Pierre-Sassoulas do you think this is feasible? |
…ibute that is annotated in a class body. Closes pylint-dev#8759
…ibute that is annotated in a class body. Closes pylint-dev#8759
…ibute that is annotated in a class body. Closes pylint-dev#8759
…ibute that is annotated in a class body. Closes pylint-dev#8759
…ibute that is annotated in a class body. Closes pylint-dev#8759
…ibute that is annotated in a class body. Closes pylint-dev#8759
Bug description
hey team, I'm running into:
E1101: Instance of 'Response' has no 'versionInfo' member (no-member)
Provided the following code:
Running pylint on
main.py
I get the following:main.py:5:16: E1101: Instance of 'Response' has no 'versionInfo' member (no-member)
However,
versionInfo
is defined in theResponse
class.I've got a theory for what's wrong and a work around. Specifically, I think it has something to do with how the
BaseModel
in pydantic isn't defining the fields using self / something more python native. When I replace theBaseModel
with a normal class and define the fields withself
linting passes.Curious what the team thought should be done here. It's not strictly a bug given it's related to a separate dependency in pydantic.
Configuration
pylint 2.17.0 astroid 2.15.0 Python 3.9.6 (default, May 7 2023, 23:32:44) [Clang 14.0.3 (clang-1403.0.22.14.1)]
Command used
Pylint output
Expected behavior
************* Module main
main.py:6:0: C0304: Final newline missing (missing-final-newline)
main.py:1:0: C0114: Missing module docstring (missing-module-docstring)
main.py:1:0: W0611: Unused Response imported from response (unused-import)
^ no more:
main.py:5:16: E1101: Instance of 'Response' has no 'versionInfo' member (no-member)
or the option to do away with it.
Pylint version
OS / Environment
ProductName: macOS
ProductVersion: 13.4
BuildVersion: 22F66
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: