Skip to content
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

Improve type annotations for the public API #16292

Open
desertaxle opened this issue Dec 9, 2024 · 4 comments
Open

Improve type annotations for the public API #16292

desertaxle opened this issue Dec 9, 2024 · 4 comments
Labels
development Tech debt, refactors, CI, tests, and other related work.

Comments

@desertaxle
Copy link
Member

desertaxle commented Dec 9, 2024

Describe the current behavior

As of 3.1.5, the type completeness of prefect.main sits at ~ 23.5%. This makes it difficult for users to get accurate information about how to use prefect from their IDE's autocomplete.

Describe the proposed behavior

We want to improve the type completeness of prefect's public API so to improve users' developer experience when working with prefect.. For now, we are considering classes available via from prefect import ...` the public API.

This issue tracks type annotation errors detected by pyright for classes and functions available from prefect.main. As of 3.1.5, the following items need to be addressed:

prefect.client.schemas.objects

  • prefect.client.schemas.objects.StateType: Type of base class "prefect.utilities.collections.AutoEnum" is partially unknown
  • prefect.client.schemas.objects.State.to_state_create: Return type is partially unknown (Return type is "StateCreate")

prefect.utilities.collections

  • prefect.utilities.collections.AutoEnum.auto: Return type annotation is missing

prefect.results

  • prefect.results.BaseResult.model_config: Ambiguous base class override (Type declared in base class is "ConfigDict", Type inferred in child class is "ConfigDict")
  • prefect.results.BaseResult.__new__: Type annotation for parameter "kwargs" is missing
  • prefect.results.BaseResult.__dispatch_key__: Type annotation for parameter "kwargs" is missing
  • prefect.results.BaseResult.__dispatch_key__: Return type annotation is missing
  • prefect.results.ResultRecordMetadata.__eq__: Type annotation for parameter "other" is missing
  • prefect.results.ResultRecordMetadata.__eq__: Return type annotation is missing
  • prefect.results.ResultStore.model_config: Ambiguous base class override (ConfigDict)
  • prefect.results.ResultStore.cache: Type argument 1 and 2 for class "LRUCache" has unknown type
  • prefect.results.ResultStore.read: Return type is partially unknown (Return type is "ResultRecord[Unknown]")
  • prefect.results.ResultRecord.serializer: Return type is partially unknown (Return type is "Serializer[Any]")
  • prefect.results.ResultRecord.deserialize: Type of parameter "backup_serializer" is partially unknown (Serializer[Any] | None)
  • prefect.results.ResultRecord.__eq__: Type annotation for parameter "other" is missing
  • prefect.results.ResultRecord.__eq__: Return type annotation is missing
  • prefect.results.ResultStore.aread: Return type is partially unknown ("Coroutine[Any, Any, ResultRecord[Unknown]]")
  • prefect.results.ResultStore.create_result_record: Return type is partially unknown ("ResultRecord[Unknown]")
  • prefect.results.ResultStore.write: Return type annotation is missing
  • prefect.results.ResultStore.awrite: Return type annotation is missing
  • prefect.results.ResultStore.persist_result_record: Parameter "result_record" partially unknown ("ResultRecord[Unknown]")
  • prefect.results.ResultStore.persist_result_record: Return type annotation is missing
  • prefect.results.ResultStore.apersist_result_record: Parameter "result_record" partially unknown ("ResultRecord[Unknown]")
  • prefect.results.ResultStore.apersist_result_record: Return type annotation is missing
  • prefect.results.ResultStore.supports_isolation_level: Parameter "level" partially unknown ("IsolationLevel")
  • prefect.results.ResultStore.release_lock: Return type annotation is missing

prefect.serializers

  • prefect.serializers.Serializer.__new__: Type annotation for parameter "kwargs" is missing
  • prefect.serializers.Serializer.model_config: Ambiguous base class override (ConfigDict)

prefect.main

  • prefect.main.get_run_logger: Type of parameter "context" partially unknown ("RunContext | None")
  • prefect.main.get_run_logger: Return type partially unknown ("Logger | LoggerAdapter[Unknown]")
  • prefect.main.flow: Return type partially unknown ("Flow[P@flow, R@flow]")
  • prefect.main.flow: Parameter "task_runner" partially unknown ("TaskRunner[PrefectFuture[R@flow]] | None")
  • prefect.main.flow: Parameter "result_storage" partially unknown ("ResultStorage | None")
  • prefect.main.flow: Parameter "result_serializer" partially unknown ("ResultSerializer | None")
  • prefect.main.serve: Parameter "args" partially unknown ("RunnerDeployment")
  • prefect.main.serve: Type annotation for parameter "kwargs" is missing
  • prefect.main.serve: Return type annotation is missing
  • prefect.main.aserve: Parameter "args" partially unknown ("RunnerDeployment")
  • prefect.main.aserve: Type annotation for parameter "kwargs" is missing
  • prefect.main.aserve: Return type annotation is missing
  • prefect.main.suspend_flow_run: Parameter "client" partially unknown ("PrefectClient")
  • prefect.main.get_client: Return type partially unknown ("PrefectClient", "SyncPrefectClient")

prefect.context

  • prefect.context.RunContext: Type of base class "prefect.context.ContextModel" is partially unknown
  • prefect.context.TaskRunContext.__var__: Ambiguous base class override (ContextVar)
  • prefect.context.ContextModel.model_config: Ambiguous base class override (ConfigDict)
  • prefect.context.ContextModel.__exit__: Type annotation for parameter "_" is missing
  • prefect.context.ContextModel.__exit__: Return type annotation is missing
  • prefect.context.ContextModel.model_copy: Return type annotation is missing

prefect.client.orchestration

  • prefect.client.orchestration.PrefectClient.__init__: Parameter "server_type" partially unknown ("ServerType | None")
  • prefect.client.orchestration.PrefectClient.create_flow: Parameter "flow" partially unknown ("Flow[Any, Any]")
  • prefect.client.orchestration.PrefectClient.create_flow_run_from_deployment: Parameter "state" partially unknown ("State[Any] | None")
  • prefect.client.orchestration.PrefectClient.create_flow_run: Parameter "flow" partially unknown ("Flow[Any, R@create_flow_run]")
  • prefect.client.orchestration.PrefectClient.create_flow_run: Parameter "state" partially unknown ("State[R@create_flow_run] | None")
  • prefect.client.orchestration.PrefectClient.create_deployment: Parameter "concurrency_options" partially unknown ("ConcurrencyOptions | None")
  • prefect.client.orchestration.PrefectClient.update_deployment: Parameter "deployment" partially unknown ("DeploymentUpdate")
  • prefect.client.orchestration.PrefectClient.read_flows: Multiple parameters partially unknown (FlowFilter, FlowRunFilter, TaskRunFilter, DeploymentFilter, WorkPoolFilter, WorkQueueFilter, FlowSort)
  • prefect.client.orchestration.PrefectClient.read_deployments: Multiple parameters partially unknown (FlowFilter, FlowRunFilter, TaskRunFilter, DeploymentFilter, WorkPoolFilter, WorkQueueFilter, DeploymentSort)
  • prefect.client.orchestration.PrefectClient.read_flow_runs: Multiple parameters partially unknown (FlowFilter, FlowRunFilter, TaskRunFilter, DeploymentFilter, WorkPoolFilter, WorkQueueFilter, FlowRunSort)
  • prefect.client.orchestration.PrefectClient.set_flow_run_state: Parameter "state" partially unknown ("State[T@set_flow_run_state]")
  • prefect.client.orchestration.PrefectClient.create_task_run: Parameter "task" partially unknown ("Task[P@create_task_run, R@create_task_run]")
  • prefect.client.orchestration.PrefectClient.create_task_run: Parameter "state" partially unknown ("State[R@create_task_run] | None")
  • prefect.client.orchestration.PrefectClient.read_task_runs: Multiple parameters partially unknown (FlowFilter, FlowRunFilter, TaskRunFilter, DeploymentFilter, TaskRunSort)
  • prefect.client.orchestration.PrefectClient.set_task_run_state: Parameter "state" partially unknown ("State[T@set_task_run_state]")
  • prefect.client.orchestration.PrefectClient.read_logs: Parameter "log_filter" partially unknown ("LogFilter | None"), "sort" partially unknown ("LogSort")
  • prefect.client.orchestration.PrefectClient.read_workers_for_work_pool: Parameter "worker_filter" partially unknown ("WorkerFilter | None")
  • prefect.client.orchestration.PrefectClient.read_work_pools: Parameter "work_pool_filter" partially unknown ("WorkPoolFilter | None")
  • prefect.client.orchestration.PrefectClient.read_work_queues: Parameter "work_queue_filter" partially unknown ("WorkQueueFilter | None")
  • prefect.client.orchestration.PrefectClient.read_artifacts: Multiple parameters partially unknown (ArtifactFilter, FlowRunFilter, TaskRunFilter, ArtifactSort)
  • prefect.client.orchestration.PrefectClient.read_latest_artifacts: Multiple parameters partially unknown (ArtifactCollectionFilter, FlowRunFilter, TaskRunFilter, ArtifactCollectionSort)
  • prefect.client.orchestration.PrefectClient.create_automation: Parameter "automation" partially unknown ("AutomationCore")
  • prefect.client.orchestration.PrefectClient.update_automation: Parameter "automation" partially unknown ("AutomationCore")
  • prefect.client.orchestration.SyncPrefectClient.__init__: Parameter "server_type" partially unknown ("ServerType | None")
  • prefect.client.orchestration.SyncPrefectClient.create_flow: Parameter "flow" partially unknown ("Flow[Any, Any]")
  • prefect.client.orchestration.SyncPrefectClient.create_flow_run: Parameter "flow" partially unknown ("Flow[Any, R@create_flow_run]")
  • prefect.client.orchestration.SyncPrefectClient.create_flow_run: Parameter "state" partially unknown ("State[R@create_flow_run] | None")
  • prefect.client.orchestration.SyncPrefectClient.create_flow_run: Return type partially unknown ("FlowRun")
  • prefect.client.orchestration.SyncPrefectClient.read_flow_run: Return type partially unknown ("FlowRun")
  • prefect.client.orchestration.SyncPrefectClient.read_flow_runs: Multiple parameters partially unknown (FlowFilter, FlowRunFilter, TaskRunFilter, DeploymentFilter, WorkPoolFilter, WorkQueueFilter, FlowRunSort)
  • prefect.client.orchestration.SyncPrefectClient.set_flow_run_state: Parameter "state" partially unknown ("State[T@set_flow_run_state]")
  • prefect.client.orchestration.SyncPrefectClient.set_flow_run_state: Return type partially unknown ("OrchestrationResult[T@set_flow_run_state]")
  • prefect.client.orchestration.SyncPrefectClient.create_task_run: Parameter "task" partially unknown ("Task[P@create_task_run, R@create_task_run]")
  • prefect.client.orchestration.SyncPrefectClient.create_task_run: Parameter "state" partially unknown ("State[R@create_task_run] | None")
  • prefect.client.orchestration.SyncPrefectClient.create_task_run: Return type partially unknown ("TaskRun")
  • prefect.client.orchestration.SyncPrefectClient.read_task_run: Return type partially unknown ("TaskRun")
  • prefect.client.orchestration.SyncPrefectClient.read_task_runs: Multiple parameters partially unknown (FlowFilter, FlowRunFilter, TaskRunFilter, DeploymentFilter, TaskRunSort)
  • prefect.client.orchestration.SyncPrefectClient.set_task_run_state: Parameter "state" partially unknown ("State[Any]")
  • prefect.client.orchestration.SyncPrefectClient.set_task_run_state: Return type partially unknown ("OrchestrationResult[Any]")
  • prefect.client.orchestration.SyncPrefectClient.read_deployment: Return type partially unknown ("DeploymentResponse")
  • prefect.client.orchestration.SyncPrefectClient.read_deployment_by_name: Return type partially unknown ("DeploymentResponse")

prefect.client.schemas.filters

  • prefect.client.schemas.filters.FlowFilter: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.FlowFilterTags: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.Operator: Type of base class "AutoEnum" unknown
  • prefect.client.schemas.filters.FlowRunFilter: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.FlowRunFilterTags: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.FlowRunFilterDeploymentId: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.FlowRunFilterWorkQueueName: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.FlowRunFilterState: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.FlowRunFilterParentFlowRunId: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.FlowRunFilterParentTaskRunId: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.TaskRunFilter: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.TaskRunFilterTags: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.TaskRunFilterState: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.DeploymentFilter: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.DeploymentFilterTags: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.WorkPoolFilter: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.WorkQueueFilter: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.LogFilter: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.ArtifactFilter: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.ArtifactCollectionFilter: Type of base class "OperatorMixin" unknown
  • prefect.client.schemas.filters.WorkerFilter: Type of base class "OperatorMixin" unknown

prefect.client.schemas.sorting

  • prefect.client.schemas.sorting.FlowSort: Type of base class "AutoEnum" unknown
  • prefect.client.schemas.sorting.DeploymentSort: Type of base class "AutoEnum" unknown
  • prefect.client.schemas.sorting.FlowRunSort: Type of base class "AutoEnum" unknown
  • prefect.client.schemas.sorting.TaskRunSort: Type of base class "AutoEnum" unknown
  • prefect.client.schemas.sorting.LogSort: Type of base class "AutoEnum" unknown
  • prefect.client.schemas.sorting.ArtifactSort: Type of base class "AutoEnum" unknown
  • prefect.client.schemas.sorting.ArtifactCollectionSort: Type of base class "AutoEnum" unknown

prefect.filesystems

  • prefect.filesystems.WritableFileSystem: Type of base class "prefect.blocks.core.Block" is partially unknown

prefect.blocks.core

  • prefect.blocks.core.Block.model_config: Ambiguous base class override (ConfigDict)
  • prefect.blocks.core.Block.__init__: Type annotation for parameter "args" is missing
  • prefect.blocks.core.Block.__init__: Type annotation for parameter "kwargs" is missing
  • prefect.blocks.core.Block.__repr_args__: Return type annotation is missing
  • prefect.blocks.core.Block.__dispatch_key__: Return type annotation is missing
  • prefect.blocks.core.Block.get_block_type_name: Return type annotation is missing
  • prefect.blocks.core.Block.get_block_type_slug: Return type annotation is missing
  • prefect.blocks.core.Block.is_block_class: Type annotation for parameter "block" is missing
  • prefect.blocks.core.Block.__new__: Type annotation for parameter "kwargs" is missing

prefect.transactions

  • prefect.transactions.IsolationLevel: Type of base class "AutoEnum" unknown
  • prefect.transactions.CommitMode: Type of base class "AutoEnum" unknown
  • prefect.transactions.TransactionState: Type of base class "AutoEnum" unknown
  • prefect.transactions.Transaction: Type of base class "prefect.context.ContextModel" partially unknown
  • prefect.transactions.Transaction.logger: Type argument 1 for class "LoggerAdapter" unknown
  • prefect.transactions.Transaction.__var__: Type argument 1 for "ContextVar" unknown
  • prefect.transactions.Transaction.__enter__: Return type annotation is missing
  • prefect.transactions.Transaction.__exit__: Type annotation for parameter "exc_info" is missing
  • prefect.transactions.Transaction.__exit__: Return type annotation is missing
  • prefect.transactions.Transaction.begin: Return type annotation is missing
  • prefect.transactions.Transaction.read: Return type partially unknown ("BaseResult[Unknown] | ResultRecord[Unknown] | None")
  • prefect.transactions.Transaction.run_hook: Type annotation for parameter "hook" is missing
  • prefect.transactions.Transaction.stage: Parameter "on_rollback_hooks" partially unknown ("List[Unknown] | None")
  • prefect.transactions.Transaction.stage: Parameter "on_commit_hooks" partially unknown ("List[Unknown] | None")

prefect.locking.protocol

  • prefect.locking.protocol.LockManager.release_lock: Return type annotation is missing

prefect.cache_policies

  • prefect.cache_policies.CachePolicy.from_cache_key_fn: Return type partially unknown ("CacheKeyFnPolicy")
  • prefect.cache_policies.CacheKeyFnPolicy.compute_key: Parameter "task_ctx" partially unknown ("TaskRunContext")
  • prefect.cache_policies.CachePolicy.configure: Parameters partially unknown ("key_storage", "lock_manager", "isolation_level")
  • prefect.cache_policies.CachePolicy.compute_key: Parameter "task_ctx" partially unknown ("TaskRunContext")
  • prefect.cache_policies._None: Type of base class "CachePolicy" partially unknown
  • prefect.cache_policies._None.compute_key: Parameter "task_ctx" partially unknown ("TaskRunContext")
  • prefect.cache_policies._None.__add__: Parameter "other" partially unknown ("CachePolicy")
  • prefect.cache_policies._None.__add__: Return type partially unknown ("CachePolicy")

prefect.locking

  • prefect.locking.protocol.LockManager.release_lock: Return type annotation is missing

prefect.flows

  • prefect.flows.Flow.__init__: Parameters partially unknown ("task_runner", "result_storage", "result_serializer")
  • prefect.flows.Flow.__get__: Type annotations for parameters "instance" and "owner" missing; Return type annotation missing
  • prefect.flows.Flow.with_options: Parameters partially unknown ("task_runner", "result_storage", "result_serializer")
  • prefect.flows.Flow.serve: Parameter "global_limit" partially unknown ("int | ConcurrencyLimitConfig | None"), Return type annotation missing
  • prefect.flows.Flow.__call__: Return type partially unknown ("State[T@call]")
  • prefect.flows.Flow.name: Type missing annotation (inferred "str")
  • prefect.flows.Flow.task_runner: Type missing annotation (inferred "TaskRunner[PrefectFuture[R@Flow]] | None")
  • prefect.flows.Flow.description: Type missing annotation (inferred "str | None")
  • prefect.flows.Flow.isasync: Type missing annotation (TypeGuard)
  • prefect.flows.Flow.isgenerator: Type missing annotation (TypeGuard)
  • prefect.flows.Flow.timeout_seconds: Type missing annotation (inferred "float | None")
  • prefect.flows.Flow.retries: Type missing annotation (inferred "int | Any")
  • prefect.flows.Flow.retry_delay_seconds: Type missing annotation (inferred "int | float | Any")
  • prefect.flows.Flow.parameters: Type missing annotation (inferred "ParameterSchema")
  • prefect.flows.Flow.on_completion_hooks: Type missing annotation (inferred "list[(Flow, FlowRun, State[Any]) -> None]")
  • prefect.flows.Flow.on_failure_hooks: Type missing annotation (inferred "list[(Flow, FlowRun, State[Any]) -> None]")
  • prefect.flows.Flow.on_cancellation_hooks: Type missing annotation (inferred "list[(Flow, FlowRun, State[Any]) -> None]")
  • prefect.flows.Flow.on_crashed_hooks: Type missing annotation (inferred "list[(Flow, FlowRun, State[Any]) -> None]")
  • prefect.flows.Flow.on_running_hooks: Type missing annotation (inferred "list[(Flow, FlowRun, State[Any]) -> None]")

prefect.task_runners

  • prefect.task_runners.TaskRunner.name: Return type annotation is missing
  • prefect.task_runners.TaskRunner.submit: Parameter "task" partially unknown ("Task[..., Unknown]")
  • prefect.task_runners.TaskRunner.submit: Parameter "wait_for" partially unknown ("Iterable[PrefectFuture[Unknown]] | None")
  • prefect.task_runners.TaskRunner.map: Parameter "task" partially unknown ("Task[P@map, R@map]")
  • prefect.task_runners.TaskRunner.map: Return type partially unknown ("PrefectFutureList[F@TaskRunner]")
  • prefect.task_runners.TaskRunner.__enter__: Return type annotation is missing
  • prefect.task_runners.TaskRunner.__exit__: Type annotations for "exc_type", "exc_value", "traceback" missing; Return type annotation missing
  • prefect.task_runners.TaskRunner.logger: Type missing annotation (inferred "Logger")

prefect.tasks

  • prefect.tasks.Task.__init__: Parameters partially unknown ("cache_policy", "result_storage", "result_serializer", "on_completion", "on_failure")
  • prefect.tasks.Task.__init__: Type arguments partially unknown in hooks lists
  • prefect.tasks.Task.__get__: Type annotations for parameters "instance" and "owner" missing; Return type annotation missing
  • prefect.tasks.Task.with_options: Parameters partially unknown ("cache_policy", "result_storage", "result_serializer", "on_completion", "on_failure"); Return type annotation missing
  • prefect.tasks.Task.create_run: Parameters partially unknown ("flow_run_context", "parent_task_run_context", "wait_for")
  • prefect.tasks.Task.create_local_run: Parameters partially unknown ("flow_run_context", "parent_task_run_context", "wait_for")
  • prefect.tasks.Task.__call__: Return type partially unknown ("State[T@call]")
  • prefect.tasks.Task.submit: Return type partially unknown ("PrefectFuture[NoReturn]", "PrefectFuture[T@submit]", "State[T@submit]")
  • prefect.tasks.Task.map: Return type partially unknown ("PrefectFutureList[R@Task]")
  • prefect.tasks.Task.apply_async: Return type partially unknown ("PrefectDistributedFuture[R@Task]")
  • prefect.tasks.Task.delay: Return type partially unknown ("PrefectDistributedFuture[Unknown]")
  • prefect.tasks.Task.description: Type missing annotation ("str | None")
  • prefect.tasks.Task.isasync: Type missing annotation (TypeGuard)
  • prefect.tasks.Task.isgenerator: Type missing annotation (TypeGuard)
  • prefect.tasks.Task.name: Type missing annotation ("str")
  • prefect.tasks.Task.tags: Type missing annotation ("set[str]")
  • prefect.tasks.Task.task_key: Type missing annotation ("str")
  • prefect.tasks.Task.cache_policy: Type missing annotation ("CachePolicy")
  • prefect.tasks.Task.retries: Type missing annotation ("int | Any")
  • prefect.tasks.Task.retry_delay_seconds: Type missing annotation ("List[float]")
  • prefect.tasks.Task.timeout_seconds: Type missing annotation ("float | None")
  • prefect.tasks.Task.on_rollback_hooks: Type missing annotation ("List[(Transaction) -> None]")
  • prefect.tasks.Task.on_commit_hooks: Type missing annotation ("List[(Transaction) -> None]")
  • prefect.tasks.Task.on_completion_hooks: Type missing annotation ("List[(Task[..., Unknown], TaskRun, State[Any]) -> None]")
  • prefect.tasks.Task.on_failure_hooks: Type missing annotation ("List[(Task[..., Unknown], TaskRun, State[Any]) -> None]")

prefect.futures

  • prefect.futures.PrefectFuture.state: Return type partially unknown ("State[Any]")
  • prefect.futures.PrefectFuture.add_done_callback: Type annotation for parameter "fn" is missing; Return type annotation is missing
  • prefect.futures.PrefectFutureList: Type of base classes "list" and "Iterator" partially unknown
  • prefect.futures.PrefectDistributedFuture: Type of base class "PrefectFuture" partially unknown
  • prefect.futures.PrefectDistributedFuture.wait_async: Return type annotation is missing
  • prefect.futures.PrefectDistributedFuture.add_done_callback: Return type annotation is missing
  • prefect.futures.PrefectDistributedFuture.__eq__: Type annotation for parameter "other" is missing; Return type annotation is missing
  • prefect.futures.PrefectDistributedFuture.__hash__: Return type annotation is missing

prefect.events

  • prefect.events.worker.EventsWorker: Type of base class "QueueService" partially unknown
  • prefect.events.worker.EventsWorker.__init__: Parameter "client_type" partially unknown ("type[EventsClient]")
  • prefect.events.clients.EventsClient.emit: Parameter "event" partially unknown ("Event")
  • prefect.events.schemas.events.Event.model_config: Ambiguous base class override (ConfigDict)
  • prefect.events.worker.EventsWorker.attach_related_resources_from_context: Parameter "event" partially unknown ("Event"), Return type annotation missing
  • prefect.events.worker.EventsWorker.instance: Parameter "client_type" partially unknown ("type[EventsClient] | None")

prefect._internal.concurrency.services

  • prefect._internal.concurrency.services.QueueService.__init__: Type annotation for parameter "args" is missing
  • prefect._internal.concurrency.services.QueueService.start: Return type annotation is missing
  • prefect._internal.concurrency.services.QueueService.send: Return type annotation is missing
  • prefect._internal.concurrency.services.QueueService.drain_all: Return type partially unknown ("Awaitable[Unknown] | None")
  • prefect._internal.concurrency.services.QueueService.wait_until_empty: Return type annotation is missing
  • prefect._internal.concurrency.services.QueueService.instance: Type annotation for parameter "args" is missing

prefect.runner.storage

  • prefect.runner.storage.RunnerStorage.set_base_path: Return type annotation is missing
  • prefect.runner.storage.RunnerStorage.pull_code: Return type annotation is missing
  • prefect.runner.storage.RunnerStorage.to_pull_step: Return type partially unknown ("dict[Unknown, Unknown]")
  • prefect.runner.storage.RunnerStorage.__eq__: Type annotation for parameter "__value" is missing

prefect.deployments.runner

  • prefect.deployments.runner.RunnerDeployment.model_config: Ambiguous base class override (ConfigDict)
  • prefect.deployments.runner.RunnerDeployment.from_flow: Parameter "flow" partially unknown ("Flow[..., Unknown]"), "concurrency_limit" partially unknown, "parameters" partially unknown ("dict[Unknown, Unknown]")
  • prefect.deployments.runner.RunnerDeployment.from_entrypoint: Parameters "concurrency_limit" and "parameters" partially unknown

prefect.records.base

  • prefect.records.base.RecordStore.read: Return type partially unknown ("TransactionRecord | None")
  • prefect.records.base.TransactionRecord.result: Type argument for "BaseResult" unknown
  • prefect.records.base.RecordStore.write: Parameter "result" partially unknown ("BaseResult[Unknown]"), Return type annotation missing
  • prefect.records.base.RecordStore.supports_isolation_level: Parameter "isolation_level" partially unknown ("IsolationLevel")
  • prefect.records.base.RecordStore.release_lock: Return type annotation is missing

prefect.client.schemas.objects

  • prefect.client.schemas.objects.ConcurrencyLimitStrategy: Type of base class "AutoEnum" unknown

prefect.locking

  • prefect.locking.protocol.LockManager.release_lock: Return type annotation is missing

prefect.client.schemas.responses

  • prefect.client.schemas.responses.SetStateStatus: Type of base class "AutoEnum" unknown

prefect.client.schemas.objects

  • prefect.client.schemas.objects.DeploymentStatus: Type of base class "AutoEnum" unknown

prefect.events.schemas.automations

  • prefect.events.schemas.automations.EventTrigger: Type of base class "ResourceTrigger" unknown
  • prefect.events.schemas.automations.Posture: Type of base class "AutoEnum" unknown
  • prefect.events.schemas.automations.ResourceTrigger: Type of base class "Trigger" unknown
  • prefect.events.schemas.automations.Trigger.set_deployment_id: Return type annotation is missing
  • prefect.events.schemas.automations.MetricTrigger: Type of base class "ResourceTrigger" unknown
  • prefect.events.schemas.automations.MetricTriggerQuery.enforce_minimum_range: Return type annotation is missing
  • prefect.events.schemas.automations.CompoundTrigger: Type of base class "CompositeTrigger" unknown
  • prefect.events.schemas.automations.CompositeTrigger: Type of base class "Trigger" unknown
  • prefect.events.schemas.automations.SequenceTrigger: Type of base class "CompositeTrigger" unknown

prefect.utilities.annotations

  • prefect.utilities.annotations.unmapped: Type of base class "BaseAnnotation" unknown
  • prefect.utilities.annotations.unmapped.__getitem__: Type annotation for parameter "_" is missing
  • prefect.utilities.annotations.BaseAnnotation: Type of base class "prefect.utilities.annotations.BaseAnnotation.BaseAnnotation" unknown
  • prefect.utilities.annotations.BaseAnnotation.BaseAnnotation.value: Type unknown
  • prefect.utilities.annotations.allow_failure: Type of base class "BaseAnnotation" unknown

Some of these fixes may require coordination across multiple files due to interdependencies. The goal should be to achieve a higher type completeness score while maintaining code functionality.

If you would like to help with resolving some of these errors, please comment below so others know what area you're working in!

@desertaxle desertaxle added the enhancement An improvement of an existing feature label Dec 9, 2024
@zzstoatzz zzstoatzz added the development Tech debt, refactors, CI, tests, and other related work. label Dec 9, 2024
@desertaxle desertaxle removed the enhancement An improvement of an existing feature label Dec 9, 2024
@desertaxle desertaxle changed the title Improve type annotations for public API Improve type annotations for the public API Dec 9, 2024
@desertaxle desertaxle pinned this issue Dec 9, 2024
@mjpieters
Copy link
Contributor

mjpieters commented Dec 10, 2024

prefect.utilities.annotations
prefect.utilities.collections

These have been dealt with in #16298.

The same PR took care of AutoEnum; all items in the list referencing that class can be checked as completed.

prefect.client.orchestration
prefect.client.schemas.filters
prefect.client.schemas.objects
prefect.client.schemas.responses
prefect.client.schemas.sorting

Any issues left here are due to types outside of prefect.client being incomplete. #16265 otherwise has taken care of all of the prefect.client namespace.

@mjpieters
Copy link
Contributor

I'm currently tackling the remaining prefect.server.database modules.

@mjpieters
Copy link
Contributor

mjpieters commented Dec 18, 2024

I'm now tackling prefect.concurrency and a few related dependencies (so far prefect.context and prefect._internal.concurrency.services but that'll likely expand a bit).

@mjpieters
Copy link
Contributor

mjpieters commented Dec 19, 2024

Current status: 79.49% type complete (𝚫 11.75%)

  • The delta is calculated from when Prefect started tracking type completeness on every PR (in 5746a98). The completeness percentage for all of Prefect was 67.73% at that point.

  • You can view the current type completeness percentage locally by running uv tool run --with-editable . pyright --verifytypes prefect --ignoreexternal --level error --outputjson | jq .typeCompleteness.completenessScore * 100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Tech debt, refactors, CI, tests, and other related work.
Projects
None yet
Development

No branches or pull requests

3 participants