You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug Report: NameError when running litestar run on Windows systems
Description
When running the command litestar run on Windows systems (the bug is reproducible on both Windows 11 and Windows 2022), in a project with two files importing from Litestar (for example, main.py with from litestar import Litestar and controllers.py with from litestar.controller import Controller), the following exception occurs NameError: name 'AfterRequestHookHandler' is not defined.
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\hostedtoolcache\windows\Python\3.13.1\x64\Scripts\litestar.exe\__main__.py", line 7, in<module>sys.exit(run_cli())
~~~~~~~^^
File "C:\hostedtoolcache\windows\Python\3.13.1\x64\Lib\site-packages\litestar\__main__.py", line 6, in run_cli
litestar_group()
~~~~~~~~~~~~~~^^
File "C:\hostedtoolcache\windows\Python\3.13.1\x64\Lib\site-packages\rich_click\rich_command.py", line 367, in __call__
returnsuper().__call__(*args, **kwargs)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "C:\hostedtoolcache\windows\Python\3.13.1\x64\Lib\site-packages\click\core.py", line 1161, in __call__
return self.main(*args, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^
File "C:\hostedtoolcache\windows\Python\3.13.1\x64\Lib\site-packages\rich_click\rich_command.py", line 151, in main
with self.make_context(prog_name, args, **extra) as ctx:
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\hostedtoolcache\windows\Python\3.13.1\x64\Lib\site-packages\litestar\cli\_utils.py", line 224, in make_context
self._prepare(ctx)
~~~~~~~~~~~~~^^^^^
File "C:\hostedtoolcache\windows\Python\3.13.1\x64\Lib\site-packages\litestar\cli\_utils.py", line 206, in _prepare
env = ctx.obj = LitestarEnv.from_env(ctx.params.get("app_path"), ctx.params.get("app_dir"))
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\hostedtoolcache\windows\Python\3.13.1\x64\Lib\site-packages\litestar\cli\_utils.py", line 114, in from_env
loaded_app = _autodiscover_app(cwd)
File "C:\hostedtoolcache\windows\Python\3.13.1\x64\Lib\site-packages\litestar\cli\_utils.py", line 340, in _autodiscover_app
get_type_hints(value, include_extras=True).get("return") if hasattr(value, "__annotations__") else None
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\hostedtoolcache\windows\Python\3.13.1\x64\Lib\typing.py", line 2457, in get_type_hints
value = _eval_type(value, base_globals, base_locals, base.__type_params__)
File "C:\hostedtoolcache\windows\Python\3.13.1\x64\Lib\typing.py", line 474, in _eval_type
return t._evaluate(globalns, localns, type_params, recursive_guard=recursive_guard)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\hostedtoolcache\windows\Python\3.13.1\x64\Lib\typing.py", line 1081, in _evaluate
eval(self.__forward_code__, globalns, localns),
~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 1, in<module>
NameError: name 'AfterRequestHookHandler' is not defined
Litestar Version
2.13, 2.14
Platform
Linux
Mac
Windows
Other (Please specify in the description above)
The text was updated successfully, but these errors were encountered:
Description
Bug Report:
NameError
when runninglitestar run
on Windows systemsDescription
When running the command
litestar run
on Windows systems (the bug is reproducible on both Windows 11 and Windows 2022), in a project with two files importing from Litestar (for example,main.py
withfrom litestar import Litestar
andcontrollers.py
withfrom litestar.controller import Controller
), the following exception occurs NameError: name 'AfterRequestHookHandler' is not defined.Reproduction repository:
https://github.com/EliseyGodX/litestar_win_bug
URL to code causing the issue
https://github.com/EliseyGodX/litestar_win_bug/actions
MCVE
Steps to reproduce
Screenshots
Logs
Litestar Version
2.13, 2.14
Platform
The text was updated successfully, but these errors were encountered: