Remove Python 2 compatibility code for Python 3.8+ #255
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR removes all Python 2 backward compatibility code from the Beaker codebase, making it Python 3.8+ only. This resolves the issue where
pyupgrade --py38-pluswould break the code.Changes Made
Core Compatibility Module (
beaker/_compat.py)PY2,JYTHON,PYVER,xrange_,add_metaclass,exec_,reraiseNoneType,string_type,unicode_text,byte_string) - use native types directlyu_()function - usestrdirectlyFiles Updated to Use Native Types
beaker/util.py: Usestr,type(None)instead of aliasesbeaker/cache.py: Usestrinstead ofunicode_text,str()instead ofu_()beaker/session.py: Usestrinstead ofstring_typebeaker/container.py: Removed unusedunicode_textimportbeaker/converters.py: Usestrinstead ofstring_typebeaker/ext/{mongodb,redisnm,redisclusternm}.py: Usestrinstead ofstring_typeu_('...')with'...'Other Changes
setup.py: Addedpython_requires='>=3.8'cookie.py: Removed old Python version workaroundscrypto/pbkdf2.py: Removed fallback PBKDF2 implementationcontainer.py: Nativemetaclass=syntaxTest Results
u_()usages intests/test_managers/base.pyandtests/test_unicode_cache_keys.pythat were causing CI failuresOriginal prompt
This section details on the original issue you should resolve
<issue_title>1.13.0: not ready for
pyupgrade --py38-plus</issue_title><issue_description>Python 3.7 has been EOSed 27 Jun 2023 so I've been trying to update
beakercode to python 3.8 usingpyupgrade --py38-plus.After apply patch generated by tis filter I found that pytest is failing
Here is pytest output: