-
-
Notifications
You must be signed in to change notification settings - Fork 161
Improve config and files module #303
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
I made most of these changes in the 1.21 files branch and the rewrite as well too.
As that branch is going to be shelved, I'm happy about your PR for fixing some of the hint and check issues of the current version.
|
Adds 2 commit: 1. fix(files): use generic type in EndianBinaryWriterApplies generic type to 2. feat(config): unset default fallback versionSets the Raises Refactors the warning mechanism using the Optimizes the documents string of the constants in the config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot 👍
Summary
This PR makes code quality improvements to the files module, such as type hints and typo corrections.
Commit Details
1. fix: better type hint in EndianBinaryReader/Writer
In
EndianBinaryReader, use-> Tuple[xxx, ...]instead of-> Tuple[xxx], where the latter one is a common mistake.In
EndianBinaryWriter, usevalue: Sequenceinstead ofvalue: listbecause some invocations pass a tuple argument instead of list.2. refactor(files): use assertion for version-specific assignment
Use
assert xxx is not Nonebefore value assignment.This is also the practice adopted by
MeshHelperand other classes, which can correctly satisfy the NoneType checking.3. chore(files): fix typo and remove legacy code
In
Fileclass:class File(object)can be simplified toclass File(Python 3).self.environment = self.environment = ...causes a duplicated self-assignment.In
ContainerHelper, method__or__cannot be used anymore since 5ac0a62 changed the constructor of this class.4. fix(files): overall type hint corrections
Correct the type hints in the files module.
Refactors
BundleFile.get_version_tuple:(next(...), next(...), next(...))instead oftuple(map(...))to respect the returned type-> Tuple[int, int, int].AttributeErrorby validating the regex match before accessinggroups.