Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Proposed fix for issue #50 #51

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

Open
pchampin wants to merge 2 commits into digitalbazaar:master
base: master
Choose a base branch
Loading
from pchampin:fix-issue50

Conversation

Copy link

@pchampin pchampin commented Oct 14, 2016

No description provided.

Copy link
Author

I know that some tests are failing, but they did fail (on my machine at least) on branch master as well, so I do not think that this is due to my patch...

if options['strict']:
raise ValueError("Unrecognized key %s" % key)
elif droppedKeys is not None:
droppedKeys.add(key)
Copy link
Contributor

@anatoly-scherbakov anatoly-scherbakov Oct 18, 2023

Choose a reason for hiding this comment

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

Returning a value from a function by modifying an argument is quite an unpopular method with Python programmers. This is a side effect; I would discourage it.

BigBlueHat reacted with thumbs up emoji
Copy link
Contributor

@BigBlueHat BigBlueHat Nov 1, 2023

Choose a reason for hiding this comment

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

@anatoly-scherbakov could you refactor this in a way that still fixes the issue?

anatoly-scherbakov reacted with eyes emoji
Copy link
Author

@pchampin pchampin Nov 9, 2023

Choose a reason for hiding this comment

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

@anatoly-scherbakov I disagree that it is inherently a bad thing for a function to mutate one of its arguments, as long as the contract is clear about it.
That being said, I agree that having this "output argument" included in the "options" argument (which is clearly an input argument otherwise), is not great.

I don't consider that changing the return value of expand, in order to include the information about dropped keys, is desirable (it would break existing code).

I believe that a better solution to be to add a 4th parameter to expand: dropped=None. If that parameter is explicitly specified, it must be an (empty?) list, and the contract would be that this list would be populated with the dropped keys.

Copy link
Contributor

@anatoly-scherbakov anatoly-scherbakov Nov 12, 2023

Choose a reason for hiding this comment

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

Even if the contract is explicitly specified, this is not what a Python developer is expecting from a library, thus violating the Principle of Least Astonishment.

I have proposed a PR: #186 — but its not ready for merge as it should be really targeted at another PR of mine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@BigBlueHat BigBlueHat BigBlueHat left review comments

+1 more reviewer

@anatoly-scherbakov anatoly-scherbakov anatoly-scherbakov requested changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /