-
Notifications
You must be signed in to change notification settings - Fork 28
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
Investigate strong typing for REST API payloads and responses #89
Comments
Hello @t1m0thyj This would certainly improve the codebase's readability and working with the packages easier. I'm interested in working on this and adding type hints wherever applicable. Before I proceed, I wanted to check if there are any specific guidelines or conventions for adding type hints in the project. Additionally, I would appreciate any guidance or considerations you might have regarding the use of type hints and dataclasses. Please let me know your thoughts on this, and if there's anything specific I should keep in mind while working on this issue. Thank you! |
For return types, we want simple dataclasses that support both dot notation (e.g. Here is an example from ChatGPT: from dataclasses import dataclass, field
from typing import Any
@dataclass
class ExtendedDataClass:
attribute1: str = field(default="")
attribute2: int = field(default=0)
def __getitem__(self, key: str) -> Any:
return self.__dict__[key]
def __setitem__(self, key: str, value: Any) -> None:
self.__dict__[key] = value
# Example usage
obj = ExtendedDataClass(attribute1="value1", attribute2=42)
# Accessing attributes
print(obj.attribute1) # Using dot notation
print(obj["attribute1"]) # Using bracket notation
# Setting attributes
obj.attribute1 = "new_value1" # Using dot notation
obj["attribute2"] = 84 # Using bracket notation
print(obj.attribute1)
print(obj.attribute2) |
Perhaps we can use some new Python features like type hints (in 3.5) and dataclasses (in 3.7).
Some examples of where this would be nice:
options
dictionary forcreate_data_set
in the zos-files SDKsubmit_job
in the zos-jobs SDKThe text was updated successfully, but these errors were encountered: