skip to Main Content

Koda Ulaşılamıyor -> Code is unreachable

Koda Ulaşılamıyor -> Code is unreachable

Visual Studio code is graying out my code and saying it is unreachable after I used pd.concat(). The IDE seems to run smoothly but it’s disturbing and I want my colorful editor back.

How do I disable the editor graying out my code without changing the current language?

2

Answers


  1. This is a bug currently existing in pandas-stubs.

    The matching overload of concat in pandas-stubs currently returns Never.

    According to this suggestion in Pylance github, you could work around the pandas-stubs issue by commenting out the Never overload in ....vscodeextensionsms-python.vscode-pylance-2024.3.1distbundledstubspandascorereshapeconcat.pyi.

    @overload
    def concat(
        objs: Iterable[None] | Mapping[HashableT1, None],
        *,
        axis: Axis = ...,
        join: Literal["inner", "outer"] = ...,
        ignore_index: bool = ...,
        keys: Iterable[HashableT2] = ...,
        levels: Sequence[list[HashableT3] | tuple[HashableT3, ...]] = ...,
        names: list[HashableT4] = ...,
        verify_integrity: bool = ...,
        sort: bool = ...,
        copy: bool = ...,
    ) -> Never: ...
    
    Login or Signup to reply.
  2. This is not a bug in pandas-stubs. This is a bug in pylance. If type checking mode is off, it should NOT be doing the "unreachable" analysis.

    Here’s an example that shows the same problem, using a standard library call:

    from random import SystemRandom
    
    sr = SystemRandom()
    
    foo = sr.getstate()
    
    print("hey")
    

    In this case, the line print("hey") will be shown as unreachable.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search