Skip to content

Variable cannot be parametrized #20634

@johannesloibl

Description

@johannesloibl

Bug summary

The documentation of prefect.variables.Variable:aget says:

@flow
async def my_flow():
    var = await Variable[str].aget("my_var")

But when i parameterize it, it gives the following error:

Encountered exception during execution: TypeError("<class 'prefect.variables.Variable'> cannot be parametrized because it does not inherit from typing.Generic")
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/prefect/flow_engine.py", line 1371, in run_context
    yield self
  File "/usr/local/lib/python3.12/site-packages/prefect/flow_engine.py", line 1433, in run_flow_async
    await engine.call_flow_fn()
  File "/usr/local/lib/python3.12/site-packages/prefect/flow_engine.py", line 1385, in call_flow_fn
    result = await call_with_parameters(self.flow.fn, self.parameters)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/prefect/prefect-workflows-main/prefect_wa/flows/monocle/monocle_export.py", line 138, in monocle_export
    projects_variable = await Variable[str].aget("monocle-snapshot-projects")
                              ~~~~~~~~^^^^^
  File "/usr/local/lib/python3.12/site-packages/pydantic/main.py", line 898, in __class_getitem__
    raise TypeError(f'{cls} cannot be parametrized because it does not inherit from typing.Generic')
TypeError: <class 'prefect.variables.Variable'> cannot be parametrized because it does not inherit from typing.Generic

Version info

Version:              3.6.16
API version:          0.8.4
Python version:       3.13.3
Git commit:           e7d587cd
Built:                Thu, Feb 05, 2026 07:37 PM
OS/Arch:              win32/AMD64
Profile:              prefect-wa-prod
Server type:          server
Pydantic version:     2.12.3
Server:
  Database:           sqlite
  SQLite version:     3.47.1
Integrations:
  prefect-aws:        0.5.13
  prefect-docker:     0.6.6
  prefect-gitlab:     0.3.2
  prefect-kubernetes: 0.7.0
  prefect-redis:      0.2.6
  prefect-shell:      0.3.1

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds:mreNeeds minimal reproduction

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions