feat(chapter_01): Upgrade to Python 3.12, refactor, and enhance security #271
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.
This commit brings several improvements to your code in Chapter 1:
Python 3.12 Upgrade & Modernization:
chapter_01
to be compatible with Python 3.12.list
instead oftyping.List
).Refactoring for Clarity & Pythonic Practices:
p06_string_compression.py
to useitertools.groupby
for a more Pythonic and concise solution.Security Enhancements:
p01_is_unique.py
andp02_check_permutation.py
: Added checks for characterord()
values to preventIndexError
with non-ASCII/extended ASCII characters in array-based solutions.p03_urlify.py
: Added validation for thelength
parameter to prevent errors and clarify behavior with invalid lengths.p07_rotate_matrix.py
andp08_zero_matrix.py
: Implemented robust checks to ensure matrices are not jagged, preventingIndexError
.Test Updates:
All changes have been tested, and existing functionality is preserved or correctly modified as per the enhancements.