GoogleCloudPlatform / GoogleCloudPlatform/PerfKitBenchmarker
Add more type annotations in PKB
- Dominant language
- Python
- Stars
- 2k
- Forks
- 562
- Avg merge
- 4h 55m
- Merged PRs (30d)
- 69
Description
Add more type annotations to almost any file in PKB. Python is by default untyped, but optional type annotations add clarity & help detect errors.
Some files like https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py already have type annotations. Many have some annotations but are also missing some.
See https://docs.python.org/3/library/typing.html for more information & examples of type annotations.
After adding type annotations, use pytype to check if annotations are correct or break anything. See here for install instructions:
https://github.com/google/pytype
But the short version is
pip install pytype
pytype _file.py
# will output if the file has any errors after adding the type annotations
Some classes could also use attribute lists like:
class VertexAiModelSpec(managed_ai_model_spec.BaseManagedAiModelSpec):
"""Spec for a Vertex AI model.
Attributes:
env_vars: Environment variables set on the node.
serving_container_command: Command run on container to start the model.
serving_container_args: The arguments passed to container create.
"""
def __init__():
self.container_image_uri: str
self.model_bucket_suffix: str
self.serving_container_command: list[str]
Contributor guide
Assessment
This issue has not been assessed yet.