Merged
Conversation
K0lb3
reviewed
Feb 25, 2025
K0lb3
reviewed
Feb 25, 2025
K0lb3
reviewed
Feb 25, 2025
K0lb3
reviewed
Feb 25, 2025
Owner
K0lb3
left a comment
There was a problem hiding this comment.
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.
Contributor
Author
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 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.