#Codegen issue? (NameError: name 'UUID' is not defined)
1 messages · Page 1 of 1 (latest)
@teal zenith
If no response in a reasonable time, ping @Member.
To close, type !solve or byte solve.
Please include an MCVE so that we can reproduce your issue locally.
File "/functionapi/app/main.py", line 122, in <module>
app = create_app()
^^^^^^^^^^^^
File "/functionapi/app/main.py", line 108, in create_app
return Litestar(
^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/litestar/app.py", line 486, in __init__
self.register(route_handler)
File "/usr/local/lib/python3.12/site-packages/litestar/app.py", line 687, in register
route_handler.on_registration(self)
File "/usr/local/lib/python3.12/site-packages/litestar/handlers/http_handlers/base.py", line 561, in on_registration
super().on_registration(app)
File "/usr/local/lib/python3.12/site-packages/litestar/handlers/base.py", line 538, in on_registration
self._validate_handler_function()
File "/usr/local/lib/python3.12/site-packages/litestar/handlers/http_handlers/base.py", line 572, in _validate_handler_function
super()._validate_handler_function()
File "/usr/local/lib/python3.12/site-packages/litestar/handlers/base.py", line 549, in _validate_handler_function
self.parsed_data_field is not None
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/litestar/handlers/base.py",
line 241, in parsed_data_field
self._parsed_data_field = self.parsed_fn_signature.parameters.get("data")
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/litestar/handlers/base.py", line 226, in parsed_fn_signature
self._parsed_fn_signature = ParsedSignature.from_fn(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/litestar/utils/signature.py", line 215, in from_fn
fn_type_hints = get_fn_type_hints(fn, namespace=signature_namespace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/litestar/utils/signature.py", line 168, in get_fn_type_hints
hints = get_type_hints(fn_to_inspect, globalns=namespace, include_extras=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/typing_extensions.py", line 1230, in get_type_hints
hint = typing.get_type_hints(
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/typing.py", line 2310, in get_type_hints
hints[name] = _eval_type(value, globalns, localns, type_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/typing.py", line 415, in _eval_type
return t._evaluate(globalns, localns, type_params, recursive_guard=recursive_guard)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/typing.py", line 947, in _evaluate
eval(self.__forward_code__, globalns, localns),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 1, in <module>
NameError: name 'UUID' is not defined
Can you share your code as well?
Add UUID to your signature namespace
it was removed from the default signatures in Advanced Alchemy
@storm isle that fixed it! Amazing I could have never troubleshoot it. Thanks!
!solve
Marked as solved and closed the help forum!
Hi everyone - I think I am facing a similar problem after setting up a new environment with uv - I have NameError: name 'EmptyType' is not defined even though I never explicitly use it.
@teal zenith could you give me a hint where you added the import?
I added a full example here:
https://discord.com/channels/919193495116337154/1306543121458266192