Improve Python Code Formatting and Quality #94
Merged
+287
−229
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 pull request focuses on enhancing the formatting and quality of the Python code in this project.
The key changes include:
Ruff
formatter to ensure consistent and clean code styletyping.List
with list and addedfrom __future__ import annotations
for better type annotationsRuff
setup.cfg
file using asottile/setup-cfg-fmt for better readability and structurenumpy
dependency fromsetup.cfg
setup.cfg
to correctly reference theLICENSE
fileFor Python Codes
Formatting Python Files
The
Ruff
formatter was applied to all Python files in the project.Ruff
automatically formats the code to adhere to best practices and style guidelines.Type Annotation Improvements
Previously, we had replaced
list
withtyping.List
for type annotations (#90). However, it was discovered that usinglist
withfrom __future__ import annotations
provides a more concise and compatible approach. Therefore, in this pull request, we have reverted back to usinglist
for type annotations. This change resolves the 'type' object is not subscriptable error that was previously encountered (#75).Manual Linter Error Fixes
After applying the
Ruff
formatter, any remaining linter errors were manually addressed. This involved making necessary code changes to resolve issues related to naming conventions, eliminating magic numbers by defining them as constants, creating GitHub issues forTODO
comments and linking them in the code, rewording comments and other quality aspects.For
setup.cfg
setup.cfg
FormattingThe
setup.cfg
file was formatted using thesetup-cfg-fmt
tool.Dependency Removal
The
numpy
dependency was removed from thesetup.cfg
file. It was determined that this dependency was not actively used in the project, and removing it helps streamline the project's dependencies, reducing unnecessary overhead.License File Path Update
The license_files configuration in
setup.cfg
was updated to accurately point to theLICENSE
file.These changes aim to improve the overall code quality, readability, and maintainability of the Python codebase. By adhering to consistent formatting, resolving linter errors, optimizing the project's configuration, and enhancing type annotations, we can ensure a cleaner and more robust project structure. These changes are compatible with future linter and formatter standards in this repo. (#95)
Please review the changes and provide any feedback or suggestions.
Thank you for your consideration!