Repository navigation
Fix: some type hints (tools/extractor, legacy patch stubs) - #285
Merged
Merged
Conversation
K0lb3
requested changes
Nov 14, 2024
This is better than putting all patched classes into __init__.pyi, and may be worth it given the backwards-compatible immutability of the legacy patch.
K0lb3
reviewed
Nov 16, 2024
K0lb3
left a comment
Owner
There was a problem hiding this comment.
Looks pretty good now, and thanks for figuring this out.
I still have something to complain about 😛
... / pass isn't necessary if the class has declared fields,
so all of them can be removed from the classes.
The .py files use all to restrict the export to the class itself,
so the _ helper function can't be imported.
Instead of defining them as separate entities, you can directly put them into the class stubs themselves.
e.g. for AudioClip
from typing import Dict, List, Optional
from UnityPy.classes.generated import SampleClip, StreamedResource
class AudioClip(SampleClip):
m_Name: str
m_3D: Optional[bool] = None
m_Ambisonic: Optional[bool] = None
m_AudioData: Optional[List[int]] = None
m_BitsPerSample: Optional[int] = None
m_Channels: Optional[int] = None
m_CompressionFormat: Optional[int] = None
m_Format: Optional[int] = None
m_Frequency: Optional[int] = None
m_IsTrackerFormat: Optional[bool] = None
m_Legacy3D: Optional[bool] = None
m_Length: Optional[float] = None
m_LoadInBackground: Optional[bool] = None
m_LoadType: Optional[int] = None
m_PreloadAudioData: Optional[bool] = None
m_Resource: Optional[StreamedResource] = None
m_Stream: Optional[int] = None
m_SubsoundIndex: Optional[int] = None
m_Type: Optional[int] = None
m_UseHardware: Optional[bool] = None
@property
def extension(self) -> str: ...
@property
def samples(self) -> Dict[str, bytes]: ...
extension = property(_AudioClip_extension)
samples = property(_AudioClip_samples)
Contributor
Author
|
I think I need to click Re-request-review. |
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.
Not sure if there is a better way to implement type hints for legacy patches...