SQL Problems running HA in dev container

Hi everyone,

I’m trying to develop my first own component. Therefore I set up the dev environment (on Windows) as in Set up Development Environment | Home Assistant Developer Docs. Everything works fine until I try to run it with F5. I get the following error message:

Exception has occurred: ArgumentError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
Type annotation for "Statistics.metadata_id" can't be correctly interpreted for Annotated Declarative Table form.  ORM annotations should normally make use of the ``Mapped[]`` generic type, or other ORM-compatible generic type, as a container for the actual type, which indicates the intent that the attribute is mapped. Class variables that are not intended to be mapped by the ORM should use ClassVar[].  To allow Annotated Declarative to disregard legacy annotations which don't use Mapped[] to pass, set "__allow_unmapped__ = True" on the class or a superclass this class. (Background on this error at: https://sqlalche.me/e/20/zlpr)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/util.py", line 2365, in _extract_mapped_subtype
    raise sa_exc.ArgumentError(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/decl_base.py", line 1285, in _collect_annotation
    extracted = _extract_mapped_subtype(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/decl_base.py", line 965, in _scan_attributes
    self._collect_annotation(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/decl_base.py", line 566, in __init__
    self._scan_attributes()
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/decl_base.py", line 329, in setup_mapping
    return _ClassScanMapperConfig(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/decl_base.py", line 248, in _as_declarative
    return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/decl_api.py", line 193, in __init__
    _as_declarative(reg, cls, dict_)
  File "/workspaces/core/homeassistant/components/recorder/db_schema.py", line 458, in <module>
    class Statistics(Base, StatisticsBase):  # type: ignore[misc,valid-type]
  File "/workspaces/core/homeassistant/components/recorder/statistics.py", line 45, in <module>
    from .db_schema import Statistics, StatisticsMeta, StatisticsRuns, StatisticsShortTerm
  File "/workspaces/core/homeassistant/components/recorder/__init__.py", line 23, in <module>
    from . import statistics, websocket_api
  File "/workspaces/core/homeassistant/helpers/recorder.py", line 22, in async_initialize_recorder
    from homeassistant.components.recorder import const, models
  File "/workspaces/core/homeassistant/bootstrap.py", line 532, in _async_set_up_integrations
    recorder.async_initialize_recorder(hass)
  File "/workspaces/core/homeassistant/bootstrap.py", line 256, in async_from_config_dict
    await _async_set_up_integrations(hass, config)
  File "/workspaces/core/homeassistant/bootstrap.py", line 143, in async_setup_hass
    await async_from_config_dict(config_dict, hass) is not None
  File "/workspaces/core/homeassistant/runner.py", line 101, in setup_and_run_hass
    hass = await bootstrap.async_setup_hass(runtime_config)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/workspaces/core/homeassistant/runner.py", line 119, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/workspaces/core/homeassistant/__main__.py", line 191, in main
    exit_code = runner.run(runtime_conf)
  File "/workspaces/core/homeassistant/__main__.py", line 203, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,
sqlalchemy.exc.ArgumentError: Type annotation for "Statistics.metadata_id" can't be correctly interpreted for Annotated Declarative Table form.  ORM annotations should normally make use of the ``Mapped[]`` generic type, or other ORM-compatible generic type, as a container for the actual type, which indicates the intent that the attribute is mapped. Class variables that are not intended to be mapped by the ORM should use ClassVar[].  To allow Annotated Declarative to disregard legacy annotations which don't use Mapped[] to pass, set "__allow_unmapped__ = True" on the class or a superclass this class. (Background on this error at: https://sqlalche.me/e/20/zlpr)

I have absolutely no idea what I need to change. I also needed to pip install sqlalchemy and another one which name I forgot.

Any help would be appreciable.

Found out the problem is the sqlalchemy version. after downgrading to 1.4 it works fine now.