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

Fix a false positive for no-member. #8778

Closed

Conversation

mbyrnepr2
Copy link
Member

@mbyrnepr2 mbyrnepr2 commented Jun 14, 2023

Type of Changes

Type
βœ“ πŸ› Bug fix
βœ“ ✨ New feature
πŸ”¨ Refactoring
πŸ“œ Docs

Description

Fix a false positive for no-member when accessing a no-value attribute that is annotated in a class body.

Closes #8759

@codecov
Copy link

codecov bot commented Jun 14, 2023

Codecov Report

Merging #8778 (f056878) into main (6f3030e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #8778   +/-   ##
=======================================
  Coverage   95.75%   95.76%           
=======================================
  Files         173      173           
  Lines       18604    18604           
=======================================
+ Hits        17815    17816    +1     
+ Misses        789      788    -1     
Files Changed Coverage Ξ”
pylint/checkers/typecheck.py 96.71% <100.00%> (+0.10%) ⬆️

@github-actions

This comment has been minimized.

@Pierre-Sassoulas Pierre-Sassoulas added Work in progress False Positive 🦟 A message is emitted but nothing is wrong with the code labels Jun 14, 2023
@mbyrnepr2 mbyrnepr2 force-pushed the 8759_false_positive_no_member branch from b546d7d to 7a8d743 Compare June 15, 2023 11:41
@github-actions

This comment has been minimized.

@mbyrnepr2 mbyrnepr2 force-pushed the 8759_false_positive_no_member branch from 7a8d743 to 5bad8d2 Compare June 21, 2023 15:05
@github-actions

This comment has been minimized.

@mbyrnepr2 mbyrnepr2 force-pushed the 8759_false_positive_no_member branch from 5bad8d2 to 4530e50 Compare July 14, 2023 12:19
@github-actions

This comment has been minimized.

@mbyrnepr2 mbyrnepr2 force-pushed the 8759_false_positive_no_member branch from 4530e50 to 1e43834 Compare July 16, 2023 12:20
@github-actions
Copy link
Contributor

πŸ€– According to the primer, this change has no effect on the checked open source code. πŸ€–πŸŽ‰

This comment was generated for commit 1e43834

@Pierre-Sassoulas
Copy link
Member

Is it still a draft @mbyrnepr2 ?

@mbyrnepr2 mbyrnepr2 marked this pull request as ready for review August 16, 2023 07:10
@mbyrnepr2
Copy link
Member Author

Thanks for the reminder @Pierre-Sassoulas. It’s been a while since I thought about it and I think I must have had a doubt about it to leave it as a draft.
A review/feedback would be helpful to see if this change makes sense.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to do something specific to pydantic(s Base Model to treat it correctly erven if it's dynamic (maybe a brain in astroid, maybe an external plugin) but I'm not a pydantic user so I don't know exactly how BaseModel is supposed to behave.

obj_a = A()
obj_a.value += 1 # [no-member]
obj_a.value += 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A review comment got lost: Here we'd introduce a false negative, running the code raise an error:

Traceback (most recent call last):
  File "/home/pierre/pylint/doc/a.py", line 12, in <module>
    obj_a = A(1)
TypeError: A() takes no arguments

@mbyrnepr2 mbyrnepr2 force-pushed the 8759_false_positive_no_member branch from 1e43834 to f056878 Compare August 30, 2023 20:15
@mbyrnepr2 mbyrnepr2 closed this Apr 5, 2024
@mbyrnepr2 mbyrnepr2 deleted the 8759_false_positive_no_member branch April 5, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing Member for Pydantic Model
2 participants