-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Python 3.12: Reimplement distutils.util.strtobool
#67
Comments
From def strtobool (val):
"""Convert a string representation of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
"""
val = val.lower()
if val in ('y', 'yes', 't', 'true', 'on', '1'):
return 1
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
return 0
else:
raise ValueError("invalid truth value %r" % (val,)) |
asullivan-blze
added a commit
that referenced
this issue
Apr 3, 2024
`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
1 task
asullivan-blze
added a commit
that referenced
this issue
Apr 3, 2024
* Reimplement strtobool for Python 3.12 compatibility `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 * Correct the checklist item relating to version string updates. The VERSION file is no longer used.
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Per PEP-632,
distutils
was deprecated, and as of Python 3.12 has been removed.Guidance in the PEP for projects using
distutils.util.strtobool
was to reimplement it.Per the docs for
distutils.util.strtobool
:The text was updated successfully, but these errors were encountered: