prefect-client 3.1.11__py3-none-any.whl → 3.1.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. prefect/_experimental/sla/__init__.py +0 -0
  2. prefect/_experimental/sla/client.py +92 -0
  3. prefect/_experimental/sla/objects.py +61 -0
  4. prefect/_internal/concurrency/services.py +2 -2
  5. prefect/_internal/concurrency/threads.py +6 -0
  6. prefect/_internal/retries.py +6 -3
  7. prefect/_internal/schemas/validators.py +6 -4
  8. prefect/_version.py +3 -3
  9. prefect/artifacts.py +4 -1
  10. prefect/automations.py +236 -30
  11. prefect/blocks/__init__.py +3 -3
  12. prefect/blocks/abstract.py +57 -31
  13. prefect/blocks/core.py +181 -82
  14. prefect/blocks/notifications.py +134 -73
  15. prefect/blocks/redis.py +13 -9
  16. prefect/blocks/system.py +24 -11
  17. prefect/blocks/webhook.py +7 -5
  18. prefect/cache_policies.py +23 -22
  19. prefect/client/orchestration/__init__.py +103 -2006
  20. prefect/client/orchestration/_automations/__init__.py +0 -0
  21. prefect/client/orchestration/_automations/client.py +329 -0
  22. prefect/client/orchestration/_blocks_documents/__init__.py +0 -0
  23. prefect/client/orchestration/_blocks_documents/client.py +334 -0
  24. prefect/client/orchestration/_blocks_schemas/__init__.py +0 -0
  25. prefect/client/orchestration/_blocks_schemas/client.py +200 -0
  26. prefect/client/orchestration/_blocks_types/__init__.py +0 -0
  27. prefect/client/orchestration/_blocks_types/client.py +380 -0
  28. prefect/client/orchestration/_deployments/__init__.py +0 -0
  29. prefect/client/orchestration/_deployments/client.py +1128 -0
  30. prefect/client/orchestration/_flow_runs/__init__.py +0 -0
  31. prefect/client/orchestration/_flow_runs/client.py +903 -0
  32. prefect/client/orchestration/_flows/__init__.py +0 -0
  33. prefect/client/orchestration/_flows/client.py +343 -0
  34. prefect/client/orchestration/_logs/client.py +16 -14
  35. prefect/client/schemas/__init__.py +68 -28
  36. prefect/client/schemas/objects.py +5 -5
  37. prefect/client/utilities.py +3 -3
  38. prefect/context.py +15 -1
  39. prefect/deployments/base.py +13 -4
  40. prefect/deployments/flow_runs.py +5 -1
  41. prefect/deployments/runner.py +37 -1
  42. prefect/deployments/steps/core.py +1 -1
  43. prefect/deployments/steps/pull.py +8 -3
  44. prefect/deployments/steps/utility.py +2 -2
  45. prefect/docker/docker_image.py +13 -9
  46. prefect/engine.py +33 -11
  47. prefect/events/cli/automations.py +4 -4
  48. prefect/events/clients.py +17 -14
  49. prefect/events/schemas/automations.py +12 -8
  50. prefect/events/schemas/events.py +5 -1
  51. prefect/events/worker.py +1 -1
  52. prefect/filesystems.py +7 -3
  53. prefect/flow_engine.py +64 -47
  54. prefect/flows.py +128 -74
  55. prefect/futures.py +14 -7
  56. prefect/infrastructure/provisioners/__init__.py +2 -0
  57. prefect/infrastructure/provisioners/cloud_run.py +4 -4
  58. prefect/infrastructure/provisioners/coiled.py +249 -0
  59. prefect/infrastructure/provisioners/container_instance.py +4 -3
  60. prefect/infrastructure/provisioners/ecs.py +55 -43
  61. prefect/infrastructure/provisioners/modal.py +5 -4
  62. prefect/input/actions.py +5 -1
  63. prefect/input/run_input.py +157 -43
  64. prefect/logging/configuration.py +3 -3
  65. prefect/logging/filters.py +2 -2
  66. prefect/logging/formatters.py +15 -11
  67. prefect/logging/handlers.py +24 -14
  68. prefect/logging/highlighters.py +5 -5
  69. prefect/logging/loggers.py +28 -18
  70. prefect/logging/logging.yml +1 -1
  71. prefect/main.py +3 -1
  72. prefect/results.py +166 -86
  73. prefect/runner/runner.py +38 -29
  74. prefect/runner/server.py +3 -1
  75. prefect/runner/storage.py +18 -18
  76. prefect/runner/submit.py +19 -12
  77. prefect/runtime/deployment.py +15 -8
  78. prefect/runtime/flow_run.py +19 -6
  79. prefect/runtime/task_run.py +7 -3
  80. prefect/settings/base.py +17 -7
  81. prefect/settings/legacy.py +4 -4
  82. prefect/settings/models/api.py +4 -3
  83. prefect/settings/models/cli.py +4 -3
  84. prefect/settings/models/client.py +7 -4
  85. prefect/settings/models/cloud.py +9 -3
  86. prefect/settings/models/deployments.py +4 -3
  87. prefect/settings/models/experiments.py +4 -8
  88. prefect/settings/models/flows.py +4 -3
  89. prefect/settings/models/internal.py +4 -3
  90. prefect/settings/models/logging.py +8 -6
  91. prefect/settings/models/results.py +4 -3
  92. prefect/settings/models/root.py +11 -16
  93. prefect/settings/models/runner.py +8 -5
  94. prefect/settings/models/server/api.py +6 -3
  95. prefect/settings/models/server/database.py +120 -25
  96. prefect/settings/models/server/deployments.py +4 -3
  97. prefect/settings/models/server/ephemeral.py +7 -4
  98. prefect/settings/models/server/events.py +6 -3
  99. prefect/settings/models/server/flow_run_graph.py +4 -3
  100. prefect/settings/models/server/root.py +4 -3
  101. prefect/settings/models/server/services.py +15 -12
  102. prefect/settings/models/server/tasks.py +7 -4
  103. prefect/settings/models/server/ui.py +4 -3
  104. prefect/settings/models/tasks.py +10 -5
  105. prefect/settings/models/testing.py +4 -3
  106. prefect/settings/models/worker.py +7 -4
  107. prefect/settings/profiles.py +13 -12
  108. prefect/settings/sources.py +20 -19
  109. prefect/states.py +74 -51
  110. prefect/task_engine.py +43 -33
  111. prefect/task_runners.py +85 -72
  112. prefect/task_runs.py +20 -11
  113. prefect/task_worker.py +14 -9
  114. prefect/tasks.py +36 -28
  115. prefect/telemetry/bootstrap.py +13 -9
  116. prefect/telemetry/run_telemetry.py +15 -13
  117. prefect/telemetry/services.py +4 -0
  118. prefect/transactions.py +3 -3
  119. prefect/types/__init__.py +3 -1
  120. prefect/utilities/_deprecated.py +38 -0
  121. prefect/utilities/engine.py +11 -4
  122. prefect/utilities/filesystem.py +2 -2
  123. prefect/utilities/generics.py +1 -1
  124. prefect/utilities/pydantic.py +21 -36
  125. prefect/utilities/templating.py +25 -1
  126. prefect/workers/base.py +58 -33
  127. prefect/workers/process.py +20 -15
  128. prefect/workers/server.py +4 -5
  129. {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/METADATA +3 -3
  130. {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/RECORD +133 -114
  131. {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/LICENSE +0 -0
  132. {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/WHEEL +0 -0
  133. {prefect_client-3.1.11.dist-info → prefect_client-3.1.13.dist-info}/top_level.txt +0 -0
@@ -1,12 +1,13 @@
1
1
  from typing import ClassVar
2
2
 
3
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
3
+ from pydantic import AliasChoices, AliasPath, Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
6
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
6
7
 
7
8
 
8
9
  class ServerDeploymentsSettings(PrefectBaseSettings):
9
- model_config: ClassVar[ConfigDict] = _build_settings_config(
10
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
10
11
  ("server", "deployments")
11
12
  )
12
13
 
@@ -1,8 +1,9 @@
1
1
  from typing import ClassVar
2
2
 
3
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
3
+ from pydantic import AliasChoices, AliasPath, Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
6
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
6
7
 
7
8
 
8
9
  class ServerEphemeralSettings(PrefectBaseSettings):
@@ -10,7 +11,9 @@ class ServerEphemeralSettings(PrefectBaseSettings):
10
11
  Settings for controlling ephemeral server behavior
11
12
  """
12
13
 
13
- model_config: ClassVar[ConfigDict] = _build_settings_config(("server", "ephemeral"))
14
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
15
+ ("server", "ephemeral")
16
+ )
14
17
 
15
18
  enabled: bool = Field(
16
19
  default=False,
@@ -28,6 +31,6 @@ class ServerEphemeralSettings(PrefectBaseSettings):
28
31
  default=20,
29
32
  description="""
30
33
  The number of seconds to wait for the server to start when ephemeral mode is enabled.
31
- Defaults to `10`.
34
+ Defaults to `20`.
32
35
  """,
33
36
  )
@@ -1,9 +1,10 @@
1
1
  from datetime import timedelta
2
2
  from typing import ClassVar
3
3
 
4
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
4
+ from pydantic import AliasChoices, AliasPath, Field
5
+ from pydantic_settings import SettingsConfigDict
5
6
 
6
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
7
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
7
8
 
8
9
 
9
10
  class ServerEventsSettings(PrefectBaseSettings):
@@ -11,7 +12,9 @@ class ServerEventsSettings(PrefectBaseSettings):
11
12
  Settings for controlling behavior of the events subsystem
12
13
  """
13
14
 
14
- model_config: ClassVar[ConfigDict] = _build_settings_config(("server", "events"))
15
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
16
+ ("server", "events")
17
+ )
15
18
 
16
19
  ###########################################################################
17
20
  # Events settings
@@ -1,8 +1,9 @@
1
1
  from typing import ClassVar
2
2
 
3
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
3
+ from pydantic import AliasChoices, AliasPath, Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
6
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
6
7
 
7
8
 
8
9
  class ServerFlowRunGraphSettings(PrefectBaseSettings):
@@ -10,7 +11,7 @@ class ServerFlowRunGraphSettings(PrefectBaseSettings):
10
11
  Settings for controlling behavior of the flow run graph
11
12
  """
12
13
 
13
- model_config: ClassVar[ConfigDict] = _build_settings_config(
14
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
14
15
  ("server", "flow_run_graph")
15
16
  )
16
17
 
@@ -1,9 +1,10 @@
1
1
  from pathlib import Path
2
2
  from typing import ClassVar, Optional
3
3
 
4
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
4
+ from pydantic import AliasChoices, AliasPath, Field
5
+ from pydantic_settings import SettingsConfigDict
5
6
 
6
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
7
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
7
8
  from prefect.types import LogLevel
8
9
 
9
10
  from .api import ServerAPISettings
@@ -22,7 +23,7 @@ class ServerSettings(PrefectBaseSettings):
22
23
  Settings for controlling server behavior
23
24
  """
24
25
 
25
- model_config: ClassVar[ConfigDict] = _build_settings_config(("server",))
26
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("server",))
26
27
 
27
28
  logging_level: LogLevel = Field(
28
29
  default="WARNING",
@@ -1,9 +1,10 @@
1
1
  from datetime import timedelta
2
2
  from typing import ClassVar
3
3
 
4
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
4
+ from pydantic import AliasChoices, AliasPath, Field
5
+ from pydantic_settings import SettingsConfigDict
5
6
 
6
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
7
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
7
8
 
8
9
 
9
10
  class ServerServicesCancellationCleanupSettings(PrefectBaseSettings):
@@ -11,7 +12,7 @@ class ServerServicesCancellationCleanupSettings(PrefectBaseSettings):
11
12
  Settings for controlling the cancellation cleanup service
12
13
  """
13
14
 
14
- model_config: ClassVar[ConfigDict] = _build_settings_config(
15
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
15
16
  ("server", "services", "cancellation_cleanup")
16
17
  )
17
18
 
@@ -41,7 +42,7 @@ class ServerServicesEventPersisterSettings(PrefectBaseSettings):
41
42
  Settings for controlling the event persister service
42
43
  """
43
44
 
44
- model_config: ClassVar[ConfigDict] = _build_settings_config(
45
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
45
46
  ("server", "services", "event_persister")
46
47
  )
47
48
 
@@ -83,7 +84,7 @@ class ServerServicesFlowRunNotificationsSettings(PrefectBaseSettings):
83
84
  Settings for controlling the flow run notifications service
84
85
  """
85
86
 
86
- model_config: ClassVar[ConfigDict] = _build_settings_config(
87
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
87
88
  ("server", "services", "flow_run_notifications")
88
89
  )
89
90
 
@@ -103,7 +104,7 @@ class ServerServicesForemanSettings(PrefectBaseSettings):
103
104
  Settings for controlling the foreman service
104
105
  """
105
106
 
106
- model_config: ClassVar[ConfigDict] = _build_settings_config(
107
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
107
108
  ("server", "services", "foreman")
108
109
  )
109
110
 
@@ -184,7 +185,7 @@ class ServerServicesLateRunsSettings(PrefectBaseSettings):
184
185
  Settings for controlling the late runs service
185
186
  """
186
187
 
187
- model_config: ClassVar[ConfigDict] = _build_settings_config(
188
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
188
189
  ("server", "services", "late_runs")
189
190
  )
190
191
 
@@ -228,7 +229,7 @@ class ServerServicesSchedulerSettings(PrefectBaseSettings):
228
229
  Settings for controlling the scheduler service
229
230
  """
230
231
 
231
- model_config: ClassVar[ConfigDict] = _build_settings_config(
232
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
232
233
  ("server", "services", "scheduler")
233
234
  )
234
235
 
@@ -353,7 +354,7 @@ class ServerServicesPauseExpirationsSettings(PrefectBaseSettings):
353
354
  Settings for controlling the pause expiration service
354
355
  """
355
356
 
356
- model_config: ClassVar[ConfigDict] = _build_settings_config(
357
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
357
358
  ("server", "services", "pause_expirations")
358
359
  )
359
360
 
@@ -389,7 +390,7 @@ class ServerServicesTaskRunRecorderSettings(PrefectBaseSettings):
389
390
  Settings for controlling the task run recorder service
390
391
  """
391
392
 
392
- model_config: ClassVar[ConfigDict] = _build_settings_config(
393
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
393
394
  ("server", "services", "task_run_recorder")
394
395
  )
395
396
 
@@ -409,7 +410,7 @@ class ServerServicesTriggersSettings(PrefectBaseSettings):
409
410
  Settings for controlling the triggers service
410
411
  """
411
412
 
412
- model_config: ClassVar[ConfigDict] = _build_settings_config(
413
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
413
414
  ("server", "services", "triggers")
414
415
  )
415
416
 
@@ -429,7 +430,9 @@ class ServerServicesSettings(PrefectBaseSettings):
429
430
  Settings for controlling server services
430
431
  """
431
432
 
432
- model_config: ClassVar[ConfigDict] = _build_settings_config(("server", "services"))
433
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
434
+ ("server", "services")
435
+ )
433
436
 
434
437
  cancellation_cleanup: ServerServicesCancellationCleanupSettings = Field(
435
438
  default_factory=ServerServicesCancellationCleanupSettings,
@@ -1,9 +1,10 @@
1
1
  from datetime import timedelta
2
2
  from typing import ClassVar
3
3
 
4
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
4
+ from pydantic import AliasChoices, AliasPath, Field
5
+ from pydantic_settings import SettingsConfigDict
5
6
 
6
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
7
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
7
8
 
8
9
 
9
10
  class ServerTasksSchedulingSettings(PrefectBaseSettings):
@@ -11,7 +12,7 @@ class ServerTasksSchedulingSettings(PrefectBaseSettings):
11
12
  Settings for controlling server-side behavior related to task scheduling
12
13
  """
13
14
 
14
- model_config: ClassVar[ConfigDict] = _build_settings_config(
15
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
15
16
  ("server", "tasks", "scheduling")
16
17
  )
17
18
 
@@ -51,7 +52,9 @@ class ServerTasksSettings(PrefectBaseSettings):
51
52
  Settings for controlling server-side behavior related to tasks
52
53
  """
53
54
 
54
- model_config: ClassVar[ConfigDict] = _build_settings_config(("server", "tasks"))
55
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
56
+ ("server", "tasks")
57
+ )
55
58
 
56
59
  tag_concurrency_slot_wait_seconds: float = Field(
57
60
  default=30,
@@ -1,12 +1,13 @@
1
1
  from typing import ClassVar, Optional
2
2
 
3
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
3
+ from pydantic import AliasChoices, AliasPath, Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
6
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
6
7
 
7
8
 
8
9
  class ServerUISettings(PrefectBaseSettings):
9
- model_config: ClassVar[ConfigDict] = _build_settings_config(("server", "ui"))
10
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("server", "ui"))
10
11
 
11
12
  enabled: bool = Field(
12
13
  default=True,
@@ -1,12 +1,15 @@
1
1
  from typing import ClassVar, Optional, Union
2
2
 
3
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
3
+ from pydantic import AliasChoices, AliasPath, Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
6
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
6
7
 
7
8
 
8
9
  class TasksRunnerSettings(PrefectBaseSettings):
9
- model_config: ClassVar[ConfigDict] = _build_settings_config(("tasks", "runner"))
10
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
11
+ ("tasks", "runner")
12
+ )
10
13
 
11
14
  thread_pool_max_workers: Optional[int] = Field(
12
15
  default=None,
@@ -21,7 +24,9 @@ class TasksRunnerSettings(PrefectBaseSettings):
21
24
 
22
25
 
23
26
  class TasksSchedulingSettings(PrefectBaseSettings):
24
- model_config: ClassVar[ConfigDict] = _build_settings_config(("tasks", "scheduling"))
27
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
28
+ ("tasks", "scheduling")
29
+ )
25
30
 
26
31
  default_storage_block: Optional[str] = Field(
27
32
  default=None,
@@ -45,7 +50,7 @@ class TasksSchedulingSettings(PrefectBaseSettings):
45
50
 
46
51
 
47
52
  class TasksSettings(PrefectBaseSettings):
48
- model_config: ClassVar[ConfigDict] = _build_settings_config(("tasks",))
53
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("tasks",))
49
54
 
50
55
  refresh_cache: bool = Field(
51
56
  default=False,
@@ -1,12 +1,13 @@
1
1
  from typing import Any, ClassVar, Optional
2
2
 
3
- from pydantic import AliasChoices, AliasPath, ConfigDict, Field
3
+ from pydantic import AliasChoices, AliasPath, Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
6
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
6
7
 
7
8
 
8
9
  class TestingSettings(PrefectBaseSettings):
9
- model_config: ClassVar[ConfigDict] = _build_settings_config(("testing",))
10
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("testing",))
10
11
 
11
12
  test_mode: bool = Field(
12
13
  default=False,
@@ -1,12 +1,15 @@
1
1
  from typing import ClassVar
2
2
 
3
- from pydantic import ConfigDict, Field
3
+ from pydantic import Field
4
+ from pydantic_settings import SettingsConfigDict
4
5
 
5
- from prefect.settings.base import PrefectBaseSettings, _build_settings_config
6
+ from prefect.settings.base import PrefectBaseSettings, build_settings_config
6
7
 
7
8
 
8
9
  class WorkerWebserverSettings(PrefectBaseSettings):
9
- model_config: ClassVar[ConfigDict] = _build_settings_config(("worker", "webserver"))
10
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(
11
+ ("worker", "webserver")
12
+ )
10
13
 
11
14
  host: str = Field(
12
15
  default="0.0.0.0",
@@ -20,7 +23,7 @@ class WorkerWebserverSettings(PrefectBaseSettings):
20
23
 
21
24
 
22
25
  class WorkerSettings(PrefectBaseSettings):
23
- model_config: ClassVar[ConfigDict] = _build_settings_config(("worker",))
26
+ model_config: ClassVar[SettingsConfigDict] = build_settings_config(("worker",))
24
27
 
25
28
  heartbeat_seconds: float = Field(
26
29
  default=30,
@@ -7,10 +7,9 @@ from typing import (
7
7
  ClassVar,
8
8
  Dict,
9
9
  Iterable,
10
- List,
10
+ Iterator,
11
11
  Optional,
12
12
  Set,
13
- Tuple,
14
13
  Union,
15
14
  )
16
15
 
@@ -77,8 +76,8 @@ class Profile(BaseModel):
77
76
  if value is not None
78
77
  }
79
78
 
80
- def validate_settings(self):
81
- errors: List[Tuple[Setting, ValidationError]] = []
79
+ def validate_settings(self) -> None:
80
+ errors: list[tuple[Setting, ValidationError]] = []
82
81
  for setting, value in self.settings.items():
83
82
  try:
84
83
  model_fields = Settings.model_fields
@@ -109,7 +108,9 @@ class ProfilesCollection:
109
108
  def __init__(
110
109
  self, profiles: Iterable[Profile], active: Optional[str] = None
111
110
  ) -> None:
112
- self.profiles_by_name = {profile.name: profile for profile in profiles}
111
+ self.profiles_by_name: dict[str, Profile] = {
112
+ profile.name: profile for profile in profiles
113
+ }
113
114
  self.active_name = active
114
115
 
115
116
  @property
@@ -128,7 +129,7 @@ class ProfilesCollection:
128
129
  return None
129
130
  return self[self.active_name]
130
131
 
131
- def set_active(self, name: Optional[str], check: bool = True):
132
+ def set_active(self, name: Optional[str], check: bool = True) -> None:
132
133
  """
133
134
  Set the active profile name in the collection.
134
135
 
@@ -142,7 +143,7 @@ class ProfilesCollection:
142
143
  def update_profile(
143
144
  self,
144
145
  name: str,
145
- settings: Dict[Setting, Any],
146
+ settings: dict[Setting, Any],
146
147
  source: Optional[Path] = None,
147
148
  ) -> Profile:
148
149
  """
@@ -214,7 +215,7 @@ class ProfilesCollection:
214
215
  active=self.active_name,
215
216
  )
216
217
 
217
- def to_dict(self):
218
+ def to_dict(self) -> dict[str, Any]:
218
219
  """
219
220
  Convert to a dictionary suitable for writing to disk.
220
221
  """
@@ -229,11 +230,11 @@ class ProfilesCollection:
229
230
  def __getitem__(self, name: str) -> Profile:
230
231
  return self.profiles_by_name[name]
231
232
 
232
- def __iter__(self):
233
+ def __iter__(self) -> Iterator[str]:
233
234
  return self.profiles_by_name.__iter__()
234
235
 
235
- def items(self):
236
- return self.profiles_by_name.items()
236
+ def items(self) -> list[tuple[str, Profile]]:
237
+ return list(self.profiles_by_name.items())
237
238
 
238
239
  def __eq__(self, __o: object) -> bool:
239
240
  if not isinstance(__o, ProfilesCollection):
@@ -325,7 +326,7 @@ def load_profiles(include_defaults: bool = True) -> ProfilesCollection:
325
326
  return profiles
326
327
 
327
328
 
328
- def load_current_profile():
329
+ def load_current_profile() -> Profile:
329
330
  """
330
331
  Load the current profile from the default and current profile paths.
331
332
 
@@ -2,7 +2,7 @@ import os
2
2
  import sys
3
3
  import warnings
4
4
  from pathlib import Path
5
- from typing import Any, Dict, List, Optional, Tuple, Type
5
+ from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Type
6
6
 
7
7
  import dotenv
8
8
  import toml
@@ -54,6 +54,7 @@ class EnvFilterSettingsSource(EnvSettingsSource):
54
54
  env_parse_none_str,
55
55
  env_parse_enums,
56
56
  )
57
+ self.env_vars: Mapping[str, str | None]
57
58
  if env_filter:
58
59
  if isinstance(self.env_vars, dict):
59
60
  for key in env_filter:
@@ -97,7 +98,7 @@ class FilteredDotEnvSettingsSource(DotEnvSettingsSource):
97
98
  for key in self.env_blacklist:
98
99
  self.env_vars.pop(key, None)
99
100
  else:
100
- self.env_vars = {
101
+ self.env_vars: dict[str, str | None] = {
101
102
  key: value
102
103
  for key, value in self.env_vars.items() # type: ignore
103
104
  if key.lower() not in env_blacklist
@@ -114,8 +115,8 @@ class ProfileSettingsTomlLoader(PydanticBaseSettingsSource):
114
115
  def __init__(self, settings_cls: Type[BaseSettings]):
115
116
  super().__init__(settings_cls)
116
117
  self.settings_cls = settings_cls
117
- self.profiles_path = _get_profiles_path()
118
- self.profile_settings = self._load_profile_settings()
118
+ self.profiles_path: Path = _get_profiles_path()
119
+ self.profile_settings: dict[str, Any] = self._load_profile_settings()
119
120
 
120
121
  def _load_profile_settings(self) -> Dict[str, Any]:
121
122
  """Helper method to load the profile settings from the profiles.toml file"""
@@ -213,14 +214,14 @@ class TomlConfigSettingsSourceBase(PydanticBaseSettingsSource, ConfigFileSourceM
213
214
  def __init__(self, settings_cls: Type[BaseSettings]):
214
215
  super().__init__(settings_cls)
215
216
  self.settings_cls = settings_cls
216
- self.toml_data = {}
217
+ self.toml_data: dict[str, Any] = {}
217
218
 
218
- def _read_file(self, path: Path) -> Dict[str, Any]:
219
+ def _read_file(self, path: Path) -> dict[str, Any]:
219
220
  return toml.load(path)
220
221
 
221
222
  def get_field_value(
222
223
  self, field: FieldInfo, field_name: str
223
- ) -> Tuple[Any, str, bool]:
224
+ ) -> tuple[Any, str, bool]:
224
225
  """Concrete implementation to get the field value from toml data"""
225
226
  value = self.toml_data.get(field_name)
226
227
  if isinstance(value, dict):
@@ -244,9 +245,9 @@ class TomlConfigSettingsSourceBase(PydanticBaseSettingsSource, ConfigFileSourceM
244
245
  break
245
246
  return value, name, self.field_is_complex(field)
246
247
 
247
- def __call__(self) -> Dict[str, Any]:
248
+ def __call__(self) -> dict[str, Any]:
248
249
  """Called by pydantic to get the settings from our custom source"""
249
- toml_setings: Dict[str, Any] = {}
250
+ toml_setings: dict[str, Any] = {}
250
251
  for field_name, field in self.settings_cls.model_fields.items():
251
252
  value, key, is_complex = self.get_field_value(field, field_name)
252
253
  if value is not None:
@@ -265,15 +266,15 @@ class PrefectTomlConfigSettingsSource(TomlConfigSettingsSourceBase):
265
266
  settings_cls: Type[BaseSettings],
266
267
  ):
267
268
  super().__init__(settings_cls)
268
- self.toml_file_path = settings_cls.model_config.get(
269
- "toml_file", DEFAULT_PREFECT_TOML_PATH
270
- )
271
- self.toml_data = self._read_files(self.toml_file_path)
272
- self.toml_table_header = settings_cls.model_config.get(
269
+ self.toml_file_path: Path | str | Sequence[
270
+ Path | str
271
+ ] | None = settings_cls.model_config.get("toml_file", DEFAULT_PREFECT_TOML_PATH)
272
+ self.toml_data: dict[str, Any] = self._read_files(self.toml_file_path)
273
+ self.toml_table_header: tuple[str, ...] = settings_cls.model_config.get(
273
274
  "prefect_toml_table_header", tuple()
274
275
  )
275
276
  for key in self.toml_table_header:
276
- self.toml_data = self.toml_data.get(key, {})
277
+ self.toml_data: dict[str, Any] = self.toml_data.get(key, {})
277
278
 
278
279
 
279
280
  class PyprojectTomlConfigSettingsSource(TomlConfigSettingsSourceBase):
@@ -284,13 +285,13 @@ class PyprojectTomlConfigSettingsSource(TomlConfigSettingsSourceBase):
284
285
  settings_cls: Type[BaseSettings],
285
286
  ):
286
287
  super().__init__(settings_cls)
287
- self.toml_file_path = Path("pyproject.toml")
288
- self.toml_data = self._read_files(self.toml_file_path)
289
- self.toml_table_header = settings_cls.model_config.get(
288
+ self.toml_file_path: Path = Path("pyproject.toml")
289
+ self.toml_data: dict[str, Any] = self._read_files(self.toml_file_path)
290
+ self.toml_table_header: tuple[str, ...] = settings_cls.model_config.get(
290
291
  "pyproject_toml_table_header", ("tool", "prefect")
291
292
  )
292
293
  for key in self.toml_table_header:
293
- self.toml_data = self.toml_data.get(key, {})
294
+ self.toml_data: dict[str, Any] = self.toml_data.get(key, {})
294
295
 
295
296
 
296
297
  def _is_test_mode() -> bool: