Unable to construct project-level symbol table for file: xxx

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube: latest docker version
    SonarQube CLI: 6.2
    Python: 3.12.6
  • how is SonarQube deployed: zip, Docker, Helm
    Docker

The Sonar scanner detected a Parse error in one of the python files within my project, and reported it as such in the log messages:

20:32:45.006 DEBUG 'homeassistant/components/tellduslive/sensor.py' generated metadata with charset 'UTF-8'
20:32:45.010 DEBUG 'homeassistant/components/dlna_dmr/media_player.py' generated metadata with charset 'UTF-8'
20:32:45.014 DEBUG Unable to construct project-level symbol table for file: homeassistant/components/dlna_dmr/media_player.py
20:32:45.014 DEBUG Parse error at line 66 column 63:

   59: PAUSED_RECORDING: MediaPlayerState.PAUSED,
   60: 
   61:     TransportState.VENDOR_DEFINED: None,
   62:     None: MediaPlayerState.ON,
   63: }
   64: 
   65: 
  -->  def catch_request_errors[_DlnaDmrEntityT: DlnaDmrEntity, **_P, _R](
   67:     func: Callable[Concatenate[_DlnaDmrEntityT, _P], Awaitable[_R]],
   68: ) -> Callable[Concatenate[_DlnaDmrEntityT, _P

20:32:45.014 DEBUG 'homeassistant/components/fully_kiosk/notify.py' generated metadata with charset 'UTF-8'

Can someone tell me how to fix it, Thx a lot.

Hello @wonderingkaho,

Could you provide the actual snippet of code (or at least a simplified reproducer) of what the code looks like?

This error is thrown either due to invalid syntax or a limitation in our parser, but we can’t investigate it if we don’t have an actual snippet of code (what’s in the log is truncated and, therefore, not valid syntax).

Cheers,
Guillaume

Hello Guillaume_Dequenne,

Thanks for your quick reply, the actual snippet of code below:

def catch_request_errors[_DlnaDmrEntityT: DlnaDmrEntity, **_P, _R](
    func: Callable[Concatenate[_DlnaDmrEntityT, _P], Awaitable[_R]],
) -> Callable[Concatenate[_DlnaDmrEntityT, _P], Coroutine[Any, Any, _R | None]]:
    """Catch UpnpError errors."""

    @functools.wraps(func)
    async def wrapper(
        self: _DlnaDmrEntityT, *args: _P.args, **kwargs: _P.kwargs
    ) -> _R | None:
        """Catch UpnpError errors and check availability before and after request."""
        if not self.available:
            _LOGGER.warning(
                "Device disappeared when trying to call service %s", func.__name__
            )
            return None
        try:
            return await func(self, *args, **kwargs)
        except UpnpError as err:
            self.check_available = True
            _LOGGER.error("Error during call %s: %r", func.__name__, err)
        return None

    return wrapper

Another Error:

15:09:16.788 INFO  3511/12734 files analyzed, current file: homeassistant/components/bryant_evolution/const.py
15:09:26.793 INFO  3902/12734 files analyzed, current file: homeassistant/components/google_assistant/__init__.py
15:09:34.123 ERROR Unable to parse file: homeassistant/components/http/decorators.py
15:09:34.124 ERROR Parse error at line 17 column 25:

   11: User
   12: from homeassistant.exceptions import Unauthorized
   13: 
   14: from .view import HomeAssistantView
   15: 
   16: type _ResponseType = Response | StreamResponse
  -->  type _FuncType[_T, **_P, _R] = Callable[
   18:     Concatenate[_T, Request, _P], Coroutine[Any, Any, _R]
   19: ]
   20: 
   21: 
   22: @overload
   23: def require_admin[

15:09:35.480 ERROR Unable to parse file: homeassistant/components/dlna_dmr/media_player.py
15:09:35.480 ERROR Parse error at line 66 column 63:

The actual snippet of code below:

type _ResponseType = Response | StreamResponse
type _FuncType[_T, **_P, _R] = Callable[
    Concatenate[_T, Request, _P], Coroutine[Any, Any, _R]
]

Thank you so much!

Cheers,
Wondering