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.
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: Make asset classes fields dataclass fields #863
Fix: Make asset classes fields dataclass fields #863
Changes from all commits
81e8cfb
47e3e49
7533078
74ef100
73b887c
3ecdc50
4e3f442
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Add a docstring to describe the purpose of the key field. This will improve code readability and maintainability. For example: 'key: str # Agent key.' Also, apply the same principle to the 'name', 'version', 'docker_image', and 'description' fields by adding specific docstrings to each.
Check warning on line 18 in src/ostorlab/assets/agent.py
src/ostorlab/assets/agent.py#L14-L18
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.
Add a docstring to explain the purpose of the
content
field. Consider using an empty bytes object (b"") as the default value instead ofNone
, which might simplify handling cases where AAB content is expected. IfNone
is retained, ensure all code accessingcontent
includes a check forNone
to prevent potential errors. Provide clear guidance on how theNone
value will be handled, versus an empty bytes object, in different parts of the system using this asset. For example, if an empty AAB is a valid case, thenb''
is more appropriate thanNone
.Check warning on line 16 in src/ostorlab/assets/android_aab.py
src/ostorlab/assets/android_aab.py#L14-L16
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.
Consider adding a docstring to explain the purpose of the
content
field. Suggestion: """The APK file content as bytes.""" Also, for better flexibility with large files, consider using a file-like object (e.g., io.BytesIO) instead of bytes. This would allow reading the APK content in chunks, reducing memory usage. Example:content: typing.BinaryIO
and update the constructor accordingly to accept and handle file-like objects. If you switch to file-like object, make sure to update any code that reads this content, to read from the stream instead of assuming it's all in memory. Update the docstring accordingly if a file-like object is used. Suggestion: """The APK file content as a binary stream."""Check warning on line 16 in src/ostorlab/assets/android_apk.py
src/ostorlab/assets/android_apk.py#L14-L16
Check warning on line 13 in src/ostorlab/assets/android_store.py
src/ostorlab/assets/android_store.py#L13
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.
Add a docstring to describe the purpose of 'package_name' and its usage to improve code readability and maintainability. For example:
package_name: str = dataclasses.field(metadata={'description': 'The package name of the Android application.'})
. Place this docstring within theAndroidStore
dataclass definition, ideally directly above thepackage_name
field declaration.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.
Add a docstring to the
name
field to describe its purpose. This will improve code clarity and maintainability. For example:name: str = Field(description='The name of the API schema.')
Check warning on line 20 in src/ostorlab/assets/api_schema.py
src/ostorlab/assets/api_schema.py#L17-L20
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.
Consider adding a default value for the
name
field or usingtyping.Optional[str]
if the field can be None. This enhances code clarity and prevents potential errors if the value is not provided during object instantiation. For example:name: str = ""
orname: typing.Optional[str] = None
depending on your specific use case. Only apply this fix if the field is intended to be optional. If the field is required, do not apply the suggested fix. Also, this applies to other dataclasses in the project if they lack default values and might be None during runtime.Check warning on line 16 in src/ostorlab/assets/domain_name.py
src/ostorlab/assets/domain_name.py#L13-L16
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.
For consistency, either add default values for
path
andcontent_url
as well, or remove the default value fromcontent
to ensure uniform class initialization.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.
Add a docstring to explain the purpose of the content field. This improves readability and maintainability. For example: """The content of the IPA file, if available."""
Check warning on line 16 in src/ostorlab/assets/ios_ipa.py
src/ostorlab/assets/ios_ipa.py#L14-L16
Check warning on line 13 in src/ostorlab/assets/ios_store.py
src/ostorlab/assets/ios_store.py#L13
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.
Remove the comment. It's redundant since the code change itself should be clear enough. If the fix is complex, a more detailed explanation of the fix or a link to the issue it resolves would be more helpful than a simple confirmation that it's correct.
Check warning on line 13 in src/ostorlab/assets/ios_testflight.py
src/ostorlab/assets/ios_testflight.py#L13
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.
Add a comment to describe the purpose of the application_url field. This improves code readability and maintainability by providing context. For example:
application_url: str # The URL of the iOS Testflight application.
Check warning on line 17 in src/ostorlab/assets/ip.py
src/ostorlab/assets/ip.py#L15-L17
Check warning on line 19 in src/ostorlab/assets/ip.py
src/ostorlab/assets/ip.py#L19
Check warning on line 16 in src/ostorlab/assets/ipv4.py
src/ostorlab/assets/ipv4.py#L14-L16
Check warning on line 16 in src/ostorlab/assets/ipv6.py
src/ostorlab/assets/ipv6.py#L14-L16
Check warning on line 14 in src/ostorlab/assets/link.py
src/ostorlab/assets/link.py#L13-L14