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

Reimplement strtobool for Python 3.12 compatibility (SVRENG-267) #68

Merged
merged 2 commits into from
Apr 3, 2024

Conversation

asullivan-blze
Copy link
Contributor

What and why?

distutils was removed in Python 3.12, which means distutils.util.strtobool got removed along with it. The guidance from PEP-632--which laid the foundation to deprecate distutils--was to reimplement the strtobool (or other functions not directly addressed by the text of the PEP.

This PR does just that, using CPython 3.11's distutils as a reference, and uses the implementation of strtobool along with its test to form the basis for the function within a utility module.

Additionally, this PR:

Finally, the version is bumped to 0.8.16, so we can have a clear marker of which version supports Python 3.12. That said, 0.8.15 is still compatible on CLI workers with boardwalkd running 0.8.16.

Resolves #67.

Backblaze internal tracking: SVRENG-267

How was this tested?

make test; using the ShouldSucceedTestWorkspace and ShouldFailTestWorkspace against the local development server and both test workspaces functioned as they are intended.

Checklist

  • Have you updated the VERSION file (if applicable)?

`distutils` was removed in Python 3.12, which means `distutils.util.strtobool` got
removed along with it. The guidance from PEP-632--which laid the foundation to
deprecate `distutils`--was to reimplement the `strtobool` (or other functions not
directly addressed by the text of the PEP.

This PR does just that, using CPython 3.11's `distutils` as a reference, and uses
the implementation of `strtobool` along with its test to form the basis for the
function within a utility module.

Additionally, this PR:
- Adds Ruff import ordering. This was missed from #66, since the isort-like behavior
is only enabled if the `I` set of rules is enabled; here, we simply extend the
default set via `lint.extend-select`.
- Adds `pytest` as a dev dependency, and adds pytest into the Makefile and GitHub
Actions workflows as appropriate.

Finally, the version is bumped to 0.8.16, so we can have a clear marker of which
version supports Python 3.12. That said, 0.8.15 is still compatible on CLI workers
with boardwalkd running 0.8.16.

Resolves #67.

Backblaze internal tracking: SVRENG-267
@asullivan-blze asullivan-blze added bug Something isn't working enhancement New feature or request CI/CD Items affecting GitHub Actions CI/CD labels Apr 3, 2024
@asullivan-blze asullivan-blze requested a review from SpartanBB April 3, 2024 19:51
Copy link

@SpartanBB SpartanBB left a comment

Choose a reason for hiding this comment

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

Changes to upgrade to python3.12 are ok. Thanks Alex!

@asullivan-blze asullivan-blze merged commit e8054f5 into main Apr 3, 2024
2 checks passed
@asullivan-blze asullivan-blze deleted the asullivan-svreng-267-python-312-compat branch April 3, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CI/CD Items affecting GitHub Actions CI/CD enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python 3.12: Reimplement distutils.util.strtobool
2 participants