mypy typing errors for batch enum's
Les mainteneurs répondent en général sous 5 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 35/100
Piste de recherche
Commencez par copier l’exemple officiel de Batch dans batch_example.py et par exécuter mypy 1.11.2. Inspectez l’affectation à logs_policy.destination à la ligne signalée ; le travail est terminé lorsque l’exemple ne produit aucune erreur mypy tout en préservant le comportement documenté de Batch.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Determine this is the right repository
- I determined this is the correct repository in which to report this bug.
Summary of the issue
Context
Running mypy on this official code sample (copy and paste into a file batch_example.py and running mypy batch_example.py)
Expected Behavior:
No mypy errors
Actual Behavior:
mypy errors:
batch_example.py:66: error: Incompatible types in assignment (expression has type "int", variable has type "Destination") [assignment]
Found 1 error in 1 file (checked 1 source file)
API client name and version
google-cloud-batch v0.17.28
Reproduction steps: code
from google.cloud import batch_v1
def create_container_job(project_id: str, region: str, job_name: str) -> batch_v1.Job:
"""
This method shows how to create a sample Batch Job that will run
a simple command inside a container on Cloud Compute instances.
Args:
project_id: project ID or project number of the Cloud project you want to use.
region: name of the region you want to use to run the job. Regions that are
available for Batch are listed on: https://cloud.google.com/batch/docs/get-started#locations
job_name: the name of the job that will be created.
It needs to be unique for each project and region pair.
Returns:
A job object representing the job created.
"""
client = batch_v1.BatchServiceClient()
# Define what will be done as part of the job.
runnable = batch_v1.Runnable()
runnable.container = batch_v1.Runnable.Container()
runnable.container.image_uri = "gcr.io/google-containers/busybox"
runnable.container.entrypoint = "/bin/sh"
runnable.container.commands = [
"-c",
"echo Hello world! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks.",
]
# Jobs can be divided into tasks. In this case, we have only one task.
task = batch_v1.TaskSpec()
task.runnables = [runnable]
# We can specify what resources are requested by each task.
resources = batch_v1.ComputeResource()
resources.cpu_milli = 2000 # in milliseconds per cpu-second. This means the task requires 2 whole CPUs.
resources.memory_mib = 16 # in MiB
task.compute_resource = resources
task.max_retry_count = 2
task.max_run_duration = "3600s"
# Tasks are grouped inside a job using TaskGroups.
# Currently, it's possible to have only one task group.
group = batch_v1.TaskGroup()
group.task_count = 4
group.task_spec = task
# Policies are used to define on what kind of virtual machines the tasks will run on.
# In this case, we tell the system to use "e2-standard-4" machine type.
# Read more about machine types here: https://cloud.google.com/compute/docs/machine-types
policy = batch_v1.AllocationPolicy.InstancePolicy()
policy.machine_type = "e2-standard-4"
instances = batch_v1.AllocationPolicy.InstancePolicyOrTemplate()
instances.policy = policy
allocation_policy = batch_v1.AllocationPolicy()
allocation_policy.instances = [instances]
job = batch_v1.Job()
job.task_groups = [group]
job.allocation_policy = allocation_policy
job.labels = {"env": "testing", "type": "container"}
# We use Cloud Logging as it's an out of the box available option
job.logs_policy = batch_v1.LogsPolicy()
job.logs_policy.destination = batch_v1.LogsPolicy.Destination.CLOUD_LOGGING
create_request = batch_v1.CreateJobRequest()
create_request.job = job
create_request.job_id = job_name
# The job's parent is the region in which the job will run
create_request.parent = f"projects/{project_id}/locations/{region}"
return client.create_job(create_request)
Reproduction steps: supporting files
No response
Reproduction steps: actual results
batch_example.py:66: error: Incompatible types in assignment (expression has type "int", variable has type "Destination") [assignment]
Found 1 error in 1 file (checked 1 source file)
Reproduction steps: expected results
Success: no issues found in 1 source file
OS & version + platform
macOS 15.0.1
Python environment
Python 3.11.10
Python dependencies
Package Version
------------------------ ---------
cachetools 5.5.0
certifi 2024.8.30
charset-normalizer 3.3.2
google-api-core 2.20.0
google-auth 2.35.0
google-cloud-batch 0.17.28
googleapis-common-protos 1.65.0
grpcio 1.66.2
grpcio-status 1.66.2
idna 3.10
mypy 1.11.2
mypy-extensions 1.0.0
pip 24.2
proto-plus 1.24.0
protobuf 5.28.2
pyasn1 0.6.1
pyasn1_modules 0.4.1
requests 2.32.3
rsa 4.9
setuptools 75.1.0
typing_extensions 4.12.2
urllib3 2.2.3
- Langage dominant
- Jupyter Notebook
- Étoiles
- 8.1k
- Forks
- 6.7k
- Merge moyen
- 4 j 12 h
- PR mergées (30 j)
- 9
Préparer son environnement
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de GoogleCloudPlatform/python-docs-samples
-
samples
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
GoogleCloudPlatform/python-docs-samples#14609 ·
Les mainteneurs répondent en général sous 5 jours
-
samples
Difficulté 1/5 Moins d'une heure Accessibilité débutants 92/100
GoogleCloudPlatform/python-docs-samples#14610 ·
Les mainteneurs répondent en général sous 5 jours
-
samples
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
GoogleCloudPlatform/python-docs-samples#14611 ·
Les mainteneurs répondent en général sous 5 jours
-
chore(generative_ai) Update model references for generative_ai samplesPeut-être à nouveau libre @XrossFox l’a pris il y a 154 jours, et aucune pull request n’est ouverte. Ouvertesamples
GoogleCloudPlatform/python-docs-samples#14117 · 1 personne assignée ·
Les mainteneurs répondent en général sous 5 jours
-
Fix Pipeline dependency issues for geospatial-classification/serving_appPeut-être à nouveau libre @XrossFox l’a pris il y a 166 jours, et aucune pull request n’est ouverte. Ouvertesamples
GoogleCloudPlatform/python-docs-samples#14091 · 1 personne assignée ·
Les mainteneurs répondent en général sous 5 jours
Toutes les issues de GoogleCloudPlatform/python-docs-samples
Issues similaires
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
pydantic/pydantic-ai#8935 ·
Les mainteneurs répondent en général sous 1 jour
-
Language: Terraform :globe_with_meridians: Needs: Triage :mag: Type: Bug :bug:
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
Azure/terraform-azurerm-avm-res-web-site#408 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: avm-ptn-alz-connectivity-hub-and-spoke-vnet not setting location within security_policyOuverteNeeds: Triage :mag: Product: Terraform (AVM) Topic: Networking (HS) :globe_with_meridians:
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Azure/Azure-Landing-Zones#4291 · 1 commentaire ·
Les mainteneurs répondent en général sous 4 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
cloudtools/troposphere#2367 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
googleapis/google-cloud-dart#366 ·
Les mainteneurs répondent en général sous 1 jour