-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Fix: some type hints (tools/extractor, legacy patch stubs) #285
Conversation
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.
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.
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)
I think I need to click Re-request-review. |
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 👍
Not sure if there is a better way to implement type hints for legacy patches...