-
Notifications
You must be signed in to change notification settings - Fork 93
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-2353 Improve the reproducer of the S5845 FP when comparing enum objects with types #2166
Conversation
0ea4240
to
1203e18
Compare
…um objects with types
1203e18
to
96dab75
Compare
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.
The actual code looks good to me. I found that the comments documenting the FPs a bit confusing. Maybe you could change those before merging.
Thanks for updating the tests 😊
def test_type_of_enum_and_enum_class(self): | ||
EnumType = Enum("EnumType", names=["one", "two"]) | ||
enum_member = EnumType(1) | ||
# FP SONARPY-2332: EnumType is a proper "type" object as an instance of "Flag", due to it being an Enum |
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.
the FP comment doesn't seem to be correct.
# FP SONARPY-2332: EnumType is a proper "type" object as an instance of "Flag", due to it being an Enum | |
# FP SONARPY-2332: EnumType is a proper "type" object since the Enum constructor with argument creates a new Enum type |
def test_type_of_derived_enum_and_derived_enum_class(self): | ||
DerivedEnumType = DerivedEnumWithoutMembers("DerivedEnumType", names=["one", "two"]) | ||
derived_enum_member = DerivedEnumType(1) | ||
# FP SONARPY-2332: DerivedEnumType is a proper "type" object as an instance of "DerivedEnumWithoutMembers", due to it being an Enum |
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.
Similar to above, I find the wording a bit confusing.
# FP SONARPY-2332: DerivedEnumType is a proper "type" object as an instance of "DerivedEnumWithoutMembers", due to it being an Enum | |
# FP SONARPY-2332: DerivedEnumType is a proper "type" object because `DerivedEnumWithoutMembers(str, list)` will create a new enum, just like `Enum(str, list)` would |
|
||
DerivedEnumTypeFromDict = DerivedEnumWithoutMembers("DerivedEnumType", OrderedDict([("one", 1), ("two", 2)])) | ||
derived_enum_member_from_dict = DerivedEnumTypeFromDict(1) | ||
# FP SONARPY-2332: DerivedEnumTypeFromDict is a proper "type" object as an instance of "DerivedEnumWithoutMembers", due to it being an Enum |
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.
same thing here
Quality Gate passedIssues Measures |
SONARPY-2353
Part of