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

Add conversion from sequence to immutable tuple #401

Conversation

Mizkoeu
Copy link

@Mizkoeu Mizkoeu commented Feb 7, 2020

No description provided.

@Mizkoeu Mizkoeu requested a review from a team February 7, 2020 23:59
Copy link
Member

@c24t c24t left a comment

Choose a reason for hiding this comment

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

The change looks sensible after fixing, but what's the motivation for this change?

Changes like this should also generally come with a test that would fail on the merge base branch, but pass on the feature branch.

opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py Outdated Show resolved Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py Outdated Show resolved Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py Outdated Show resolved Hide resolved
for element in sequence:
if not isinstance(element, first_element_type):
return "different type"
if any(not isinstance(element, first_element_type) for element in sequence):
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this better than the previous implementation?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just a minor detail here. I think the original implementation may be slightly better because it stops at the very first element in sequence that is not an instance of first_element_type. In the proposed implementation here, the whole sequence is iterated through (I think it is, not completely sure), producing a list that then is passed to any.

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense. I have removed this implementation and left it as it was.

@Mizkoeu
Copy link
Author

Mizkoeu commented Feb 8, 2020

PR in response to issue #352 where it's suggested to convert client input sequence into tuple so that it's immutable (safe from odd manipulations of list attribute after setting).

@Mizkoeu
Copy link
Author

Mizkoeu commented Feb 8, 2020

The change looks sensible after fixing, but what's the motivation for this change?

This suggested change is linked to #352 issue where we do not want attr value to be mutable lest the user accidentally modifies it.

Changes like this should also generally come with a test that would fail on the merge base branch, but pass on the feature branch.

Great suggestion! I have updated the test_attributes to assert equal to tuple rather than list. (I'm new to contributing to Open Source projects and Open Telemetry in general, so I'm still learning)

@c24t
Copy link
Member

c24t commented Feb 10, 2020

@Mizkoeu if you sign the CLA this should be good to go.

@c24t c24t requested a review from ocelotl February 13, 2020 21:46
@toumorokoshi
Copy link
Member

@ocelotl is there still a blocking issue for you? Looks like your concern was reverted.

@toumorokoshi
Copy link
Member

@Mizkoeu just a reminder that you'll need to sign the CLA before we can merge. Thanks!

@mauriciovasquezbernal
Copy link
Member

#449 replaced this.

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.

5 participants