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

SONARPY-2353 Improve the reproducer of the S5845 FP when comparing enum objects with types #2166

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

thomas-serre-sonarsource
Copy link
Contributor

@thomas-serre-sonarsource thomas-serre-sonarsource commented Nov 19, 2024

SONARPY-2353

Part of

Copy link
Contributor

@Seppli11 Seppli11 left a 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
Copy link
Contributor

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.

Suggested change
# 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
Copy link
Contributor

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.

Suggested change
# 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
Copy link
Contributor

Choose a reason for hiding this comment

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

same thing here

Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@thomas-serre-sonarsource thomas-serre-sonarsource merged commit 8784032 into master Nov 20, 2024
9 of 10 checks passed
@thomas-serre-sonarsource thomas-serre-sonarsource deleted the ts/SONARPY-2353 branch November 20, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants