Skip to content

Restore order of operators before executing the git command only for < py3.6 #1193

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

Merged
merged 1 commit into from
Mar 13, 2021

Conversation

bertwesarg
Copy link
Contributor

Since Python 3.6 kwargs are stable ordered again and Python 3.5 reached
its end-of-life too, so we can revert 89ade7b
again. Thus make it able to pass ordered options to Git commands again.

Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your contribution, it's much appreciated!

Does that also mean that kwargs are now ordered by default? Or does it mean that the order won't change between calls even though the order is not as specified?
In the latter case, the result might still be considered unstable compared to ordering them.

What do you think?

@bertwesarg
Copy link
Contributor Author

What do you think?

The PEP speaks about preserving order, this should also mean, that the order wont change between calls. I cannot reproduce the example git.remote.pull(), given in the original commit. But I can reproduce the random order of kwargs between two executions of Python 3.5 with this code:

def pkwargs(**kwargs):
    print(kwargs)
pkwargs(**{'one': 1, 'two': 2, 'three': 3, 'four': 4})

This gives me one of these possible outputs:

{'three': 3, 'four': 4, 'one': 1, 'two': 2}
{'two': 2, 'one': 1, 'three': 3, 'four': 4}

For Python 3.6 it is stable and preserves the order:

{'one': 1, 'two': 2, 'three': 3, 'four': 4}

@bertwesarg bertwesarg force-pushed the revert-sorted-kwargs branch from 9ba20a9 to b0422eb Compare March 12, 2021 07:25
@bertwesarg
Copy link
Contributor Author

The PEP link is also in the commit message: https://www.python.org/dev/peps/pep-0468/

@Byron
Copy link
Member

Byron commented Mar 12, 2021

Thanks a lot! Now this PR would be ready for merge even though I feel a little uncomfortable to remove support half a year after py3.5 reached its end of life given that it took 2 years to remove 3.4 support to be able to support inline types which has incredibly high value.

My suggestion is to wait with the merge till Sept. 5, 2020 giving folks another half a year to stop using python 3.5 or face the potential for breakage.

If you would like a merge right now one could add a python version check to keep the sort code for py3.5 maybe along a depreciation warning to let people know the date of removal.

Thanks for sharing your thoughts.

@bertwesarg
Copy link
Contributor Author

I don't think, shifting the date further back will have any effect. Most of us (the users) will drop py3.5, ony if we notice, that its not supported by the package we are using. But in the end, this is your call.

I also do not have a problem, to make this conditionally on the python version in use, so stay tuned for an update, without the py3.5 drop.

@bertwesarg bertwesarg force-pushed the revert-sorted-kwargs branch from b0422eb to 52862a6 Compare March 12, 2021 14:23
@bertwesarg bertwesarg changed the title Revert "Fix order of operators before executing the git command" Restore order of operators before executing the git command only for < py3.6 Mar 12, 2021
@bertwesarg bertwesarg force-pushed the revert-sorted-kwargs branch from 52862a6 to a53bb10 Compare March 12, 2021 14:25
# only since 3.6 Python preserves the order of kwargs and thus has a stable
# order. For older versions sort the kwargs by the key to get a stable
# order.
if sys.version_info[:2] < (3, 6):
Copy link
Member

Choose a reason for hiding this comment

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

In order to make people aware, could you add a deprecation warning mentioning the date until this will work?

…< py3.6

Since Python 3.6 kwargs order will be preserved and thus provide a stable
order, therefore we can make 89ade7b
conditional based on the Python. Thus make it able to pass ordered options
to Git commands.

See: https://www.python.org/dev/peps/pep-0468/
@bertwesarg bertwesarg force-pushed the revert-sorted-kwargs branch from a53bb10 to 5df76d4 Compare March 13, 2021 12:41
@Byron
Copy link
Member

Byron commented Mar 13, 2021

Thanks a lot for your help!

I will set a reminder for myself to remove python 3.5 support on September 5th. It would be super helpful to have a PR waiting which does that - the code was present here but seems to have been overwritten.

@Byron Byron merged commit 48c1e9b into gitpython-developers:master Mar 13, 2021
@Byron Byron added this to the v3.1.15 - Bugfixes milestone Mar 13, 2021
@bertwesarg bertwesarg deleted the revert-sorted-kwargs branch March 13, 2021 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants