-
Notifications
You must be signed in to change notification settings - Fork 94
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
SONARPY-2360 Add unit test case on S5655 when compared types has decorators #2173
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -267,3 +267,15 @@ class EnumA(Enum): | |||||||||
C = 3 | ||||||||||
|
||||||||||
len(EnumA) | ||||||||||
|
||||||||||
def fp_decorated_types(): | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor as suggested in a previous comment, I really think you can get rid of this line. I was able to raise the FP without this |
||||||||||
import dataclasses | ||||||||||
@dataclasses.dataclass | ||||||||||
class DecoratedClass: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
x : int | ||||||||||
|
||||||||||
def decorated_type_expecting_foo(data: DecoratedClass): ... | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
data = dataclasses.replace(DecoratedClass(42)) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
# FP SONARPY-2359 | ||||||||||
decorated_type_expecting_foo(data) # Noncompliant | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be more explicit about the scope of the ticket, I suggest to add a more general test case.
I was going to propose this test but I 'm not able to raise the issue with it. Any idea why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cause in this example it compares AnotherClass to be compatible with DecoratedClass and since it has member
x
asDecoratedClass
has - it says that it is compatible typeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, thanks