opensearch-project / opensearch-py

Python Client for OpenSearch
https://opensearch.org/docs/latest/clients/python/
Apache License 2.0
338 stars 170 forks source link

Remove redundant six dependency #781

Closed hugovk closed 2 months ago

hugovk commented 2 months ago

Description

Describe what this change achieves.

This package only supports Python 3, however it still uses the six compatibility library to support Python 2 and 3.

This PR removes the dependency, and replaces the six calls with direct Python 3 code.

This makes the install a bit quicker, smaller, and the code a bit faster by using the standard library instead of a package.

Issues Resolved

List any issues this PR will resolve, e.g. Closes [...].

None known.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.


I did this using the https://github.com/asottile/pyupgrade tool that upgrades Python syntax.

We could run it on all the files, and upgrade to Python 3.8+ syntax (--py38-plus), but I wanted to keep the diff small, so I only ran it on files using six, and did the lowest syntax upgrade (--py3-plus):

rg six -l | xargs pyupgrade --py3-plus

(I do recommend running it on the whole codebase and for 3.8+, perhaps in another PR. For example pyupgrade **/*.py --py38-plus upgrades 84 further files.)


This PR also removes creation of universal wheels, that's only needed when supporting Python 2, and corrects the Black target version.