microsoft / pyright

Static Type Checker for Python
Other
12.45k stars 1.34k forks source link

Unbound variable despite exhausted possibilities #7396

Closed spineki closed 4 months ago

spineki commented 4 months ago

Environment data

Code Snippet

class Fails_0:
    def __init__(self, a: int) -> None:
        self.a: int = a

    def dummy(self):
        if self.a in (0, 1):
            # Hovering self.a in vscode here shows "(variable) a: Literal[0, 1]""
            if self.a == 0:
                b = 0
            elif self.a == 1:
                b = 1
            """
            The following line shows
            "b" is possibly unboundPylance(reportPossiblyUnboundVariable)
            (variable) b: Unbound | Literal[0, 1]
            """
            return b

class Fails_1:
    def __init__(self, a: int) -> None:
        self.a: int = a

    def dummy(self):
        # storing self.a in my_variable. Hovering it in vscode shows (variable) my_variable: int
        my_variable = self.a
        if my_variable in (0, 1):
            # Hovering my_variable in vscode here shows "(variable) my_variable: Literal[0, 1]"
            if my_variable == 0:
                b = 0
            elif my_variable == 1:
                b = 1
            """
            The following line shows
            "b" is possibly unboundPylance(reportPossiblyUnboundVariable)
            (variable) b: Unbound | Literal[0, 1]
            """
            return b

class Works_0:
    def __init__(self, a: int) -> None:
        self.a: int = a

    def dummy(self, my_param: int):
        if my_param in (0, 1):
            # Hovering my_param in vscode here shows "(parameter) my_param: Literal[0, 1]"
            if my_param == 0:
                b = 0
            elif my_param == 1:
                b = 1
            """
            No issue, show "(variable) b: Literal[0, 1]"
            """
            return b

class Works_1:
    def __init__(self, a: int) -> None:
        self.a: int = a

    def dummy(self):
        # here, adding :int on my_variable. Without this annotation, it was already displaying 'myvariable: int" while hovering it.
        # So I would expect this type annotation not to change anything...
        my_variable: int = self.a

        if my_variable in (0, 1):
            if my_variable == 0:
                b = 0
            elif my_variable == 1:
                b = 1
            """
            However, it works !
            the following line shows
            "(variable) b: Literal[0, 1]"
            """
            return b

Repro Steps

  1. Create a class with a method that checks if an attribute is amongst some literals;
  2. Exhaust all the possibilities in an if/elif and gives to a variable a value depending on the case;
  3. Eventually returns this value. Despite having exhausted all the possible cases, the tool reports the returned variable as potentially Unbound.

Expected behavior

The returned variable should not be highlighted as possibly unbound because all the cases are covered.

Actual behavior

The variable is shown as Unbound. It is still the case if the attribute is copied into a local variable, but is solved by adding an extra type indication to the copied variable.

Logs

2024-03-04 13:41:25.082 [info] [Info  - 1:41:25 PM] (41907) Pylance language server 2024.2.2 (pyright version 1.1.348, commit cfb1de0c) starting
2024-03-04 13:41:25.082 [info] [Info  - 1:41:25 PM] (41907) Server root directory: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist
2024-03-04 13:41:25.082 [info] [Info  - 1:41:25 PM] (41907) Starting service instance "report"
2024-03-04 13:41:25.098 [info] (41907) No configuration file found.
2024-03-04 13:41:25.098 [info] (41907) No pyproject.toml file found.
2024-03-04 13:41:25.098 [info] [Info  - 1:41:25 PM] (41907) Setting pythonPath for service "report": "/bin/python"
2024-03-04 13:41:25.098 [info] [Info  - 1:41:25 PM] (41907) Setting environmentName for service "report": "3.10.12 (global)"
2024-03-04 13:41:25.116 [info] [Info  - 1:41:25 PM] (41907) Assuming Python version 3.10
2024-03-04 13:41:25.116 [info] (41907) Assuming Python platform Linux
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907) Search paths for file:///home/spineki/Desktop/report
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907)   /home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907)   /home/spineki/Desktop/report
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907)   /home/spineki/Desktop/report/typings
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907)   /home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stubs/...
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907)   /home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/bundled/stubs
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907)   /usr/lib/python3.10
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907)   /usr/lib/python3.10/lib-dynload
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907)   /home/spineki/.local/lib/python3.10/site-packages
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907)   /usr/local/lib/python3.10/dist-packages
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907)   /usr/lib/python3/dist-packages
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907) Adding fs watcher for library directories:
 file:///usr/lib/python3.10
file:///usr/lib/python3.10/lib-dynload
file:///home/spineki/.local/lib/python3.10/site-packages
file:///usr/local/lib/python3.10/dist-packages
file:///usr/lib/python3/dist-packages
2024-03-04 13:41:25.150 [info] [Info  - 1:41:25 PM] (41907) Adding fs watcher for directories:
 file:///home/spineki/Desktop/report
2024-03-04 13:41:25.150 [info] (41907) Searching for source files
2024-03-04 13:41:25.152 [info] [Info  - 1:41:25 PM] (41907) Found 1 source file
2024-03-04 13:41:25.153 [info] (41907) pytest configurations: {"message":"request cancelled","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-03-04 13:41:25.153 [info] (41907) pytest configurations: {"message":"script","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-03-04 13:41:25.363 [info] [Info  - 1:41:25 PM] (41907) Background analysis(1) root directory: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist
2024-03-04 13:41:25.364 [info] [Info  - 1:41:25 PM] (41907) Background analysis(1) started
2024-03-04 13:41:25.436 [info] (41907) [FG] parsing: file:///home/spineki/Desktop/report/main.py (44ms)
2024-03-04 13:41:25.493 [info] (41907) [FG] parsing: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 2ms] (55ms)
2024-03-04 13:41:25.527 [info] (41907) [FG] binding: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/builtins.pyi (32ms)
2024-03-04 13:41:25.541 [info] (41907) [FG] binding: file:///home/spineki/Desktop/report/main.py (13ms)
2024-03-04 13:41:25.545 [info] (41907) pytest configurations: {"message":"request cancelled","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-03-04 13:41:25.545 [info] (41907) Background inlayHint message
2024-03-04 13:41:25.545 [info] (41907) [BG(1)] getInlayHints range 0:0 - 77:0 at file:///home/spineki/Desktop/report/main.py ...
2024-03-04 13:41:25.545 [info] (41907) [BG(1)]   parsing: file:///home/spineki/Desktop/report/main.py (61ms)
2024-03-04 13:41:25.545 [info] (41907) [BG(1)]   parsing: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 2ms] (65ms)
2024-03-04 13:41:25.545 [info] [Info  - 1:41:25 PM] (41907) Indexer background runner(2) root directory: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist (index)
2024-03-04 13:41:25.545 [info] [Info  - 1:41:25 PM] (41907) Indexing(2) started
2024-03-04 13:41:25.545 [info] (41907) [IDX(2)] scan packages file:///home/spineki/Desktop/report ...
2024-03-04 13:41:25.545 [info] (41907) [IDX(2)]   read stdlib indices (17ms)
2024-03-04 13:41:25.565 [info] (41907) [BG(1)]   binding: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/builtins.pyi (31ms)
2024-03-04 13:41:25.567 [info] (41907) [BG(1)]   binding: file:///home/spineki/Desktop/report/main.py (1ms)
2024-03-04 13:41:25.599 [info] (41907) [BG(1)]   parsing: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/typing.pyi [fs read 0ms] (26ms)
2024-03-04 13:41:25.608 [info] (41907) [BG(1)]   binding: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/typing.pyi (10ms)
2024-03-04 13:41:25.626 [info] (41907) [BG(1)]   parsing: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/types.pyi [fs read 0ms] (6ms)
2024-03-04 13:41:25.630 [info] (41907) [BG(1)]   binding: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/types.pyi (4ms)
2024-03-04 13:41:25.641 [info] (41907) [BG(1)]   parsing: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi [fs read 0ms] (5ms)
2024-03-04 13:41:25.643 [info] (41907) [BG(1)]   binding: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi (2ms)
2024-03-04 13:41:25.649 [info] (41907) [BG(1)]   parsing: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/abc.pyi [fs read 0ms] (1ms)
2024-03-04 13:41:25.650 [info] (41907) [BG(1)]   binding: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/abc.pyi (1ms)
2024-03-04 13:41:25.665 [info] (41907) [BG(1)] getInlayHints range 0:0 - 77:0 at file:///home/spineki/Desktop/report/main.py (262ms)
2024-03-04 13:41:25.666 [info] (41907) Background analysis message: getSemanticTokens range
2024-03-04 13:41:25.691 [info] (41907) [BG(1)] getSemanticTokens range 0:0 - 77:0 at file:///home/spineki/Desktop/report/main.py (25ms)
2024-03-04 13:41:25.712 [info] (41907) [BG(1)] analyzing: file:///home/spineki/Desktop/report/main.py ...
2024-03-04 13:41:25.712 [info] (41907) [BG(1)]   checking: file:///home/spineki/Desktop/report/main.py (19ms)
2024-03-04 13:41:25.712 [info] (41907) [BG(1)] analyzing: file:///home/spineki/Desktop/report/main.py (20ms)
2024-03-04 13:41:25.716 [info] (41907) Background analysis message: getSemanticTokens full
2024-03-04 13:41:25.718 [info] (41907) [BG(1)] getSemanticTokens full at file:///home/spineki/Desktop/report/main.py (4ms)
2024-03-04 13:41:25.720 [info] (41907) [BG(1)] indexing: file:///home/spineki/Desktop/report/main.py [found 4] (1ms)
2024-03-04 13:41:25.721 [info] (41907) Indexing Done: file:///home/spineki/Desktop/report/main.py
2024-03-04 13:41:25.723 [info] (41907) pytest configurations: {"message":"script","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-03-04 13:41:25.758 [info] (41907) Background inlayHint message
2024-03-04 13:41:25.760 [info] (41907) [BG(1)] getInlayHints range 0:0 - 77:0 at file:///home/spineki/Desktop/report/main.py (1ms)
2024-03-04 13:41:25.835 [info] (41907) [IDX(2)] scan packages file:///home/spineki/Desktop/report (331ms)
2024-03-04 13:41:25.836 [info] [Info  - 1:41:25 PM] (41907) scanned(2) 312 files over 1 exec env
2024-03-04 13:41:26.183 [info] (41907) Background analysis message: getSemanticTokens delta
2024-03-04 13:41:26.184 [info] (41907) [BG(1)] getSemanticTokens delta previousResultId:1709556085713 at file:///home/spineki/Desktop/report/main.py (0ms)
2024-03-04 13:41:26.314 [info] (41907) [IDX(2)] index packages file:///home/spineki/Desktop/report ...
2024-03-04 13:41:26.314 [info] (41907) [IDX(2)]   index execution environment file:///home/spineki/Desktop/report ...
2024-03-04 13:41:26.314 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_afm.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.315 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_c_internal_utils.pyi [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.315 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_cm.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.315 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_color_data.pyi [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.315 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_constrained_layout.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.315 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_docstring.pyi [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_enums.pyi [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_fontconfig_pattern.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_layoutgrid.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_mathtext.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_mathtext_data.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_pylab_helpers.pyi [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_text_helpers.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_tight_bbox.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_tight_layout.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_version.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3.10/concurrent/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3.10/distutils/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3.10/lib2to3/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.316 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3.10/pydoc_data/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3.10/test/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3.10/urllib/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3.10/wsgiref/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3.10/xmlrpc/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/backgroundremover/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/coloredlogs/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/commandlines/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/dill/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/filetype/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/flatbuffers/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/functorch/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/hsh/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/imageio_ffmpeg/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/jedi/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/linkify_it/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/llvmlite/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_animation_data.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_blocking_input.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_cm_listed.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_image.pyi [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_internal_utils.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_path.pyi [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_qhull.pyi [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_tri.pyi [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_ttconv.pyi [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib/_type1font.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/matplotlib_inline/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/moviepy/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.317 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/mpmath/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/mypyc/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/nvidia/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/objsize/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/onnxruntime/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/pooch/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/pyflame/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/pymatting/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/pympler/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/pynvml/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/pyvis/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/rembg/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/scalene/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/scipy/_distributor_init.py [skipped: private or protected file] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/scipy/conftest.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/scipy/version.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/snakeviz/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/torchgen/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/torchvision/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/tzdata/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///home/spineki/.local/lib/python3.10/site-packages/uc_micro/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/AptUrl/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/CommandNotFound/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/DistUpgrade/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/HweSupportStatus/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/LanguageSelector/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/NvidiaDetector/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/Quirks/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/SCons/__init__.py [skipped: no '__all__' defined] (1ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/SSSDConfig/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/UbuntuDrivers/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.318 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/UpdateManager/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/apport/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/aptsources/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/babel/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/cloudinit/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/debian_bundle/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/distlib/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/duplicity/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/fasteners/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/firewall/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/future/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/gi/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/gtweak/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/janitor/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/jeepney/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/landscape/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/launchpadlib/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/libfuturize/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/libpasteurize/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/louis/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/macaroonbakery/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/mako/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/nftables/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/orca/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/past/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/ptyprocess/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/pyasn1_modules/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/pyatspi/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/reportlab/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/softwareproperties/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/sos/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/speechd/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/speechd_config/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/ssh_import_id/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/sssd/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/systemd/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/uaclient/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.319 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/ufw/__init__.py [skipped: no '__all__' defined] (1ms)
2024-03-04 13:41:26.320 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/usbcreator/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.320 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/wadllib/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.320 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/wheel/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.320 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/xkit/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.320 [info] (41907) [IDX(2)]     indexing: file:///usr/lib/python3/dist-packages/zope/__init__.py [skipped: no '__all__' defined] (0ms)
2024-03-04 13:41:26.330 [info] (41907) [IDX(2)]   index execution environment file:///home/spineki/Desktop/report [found 9094 in 190 files] (27ms)
2024-03-04 13:41:26.330 [info] (41907) [IDX(2)] index packages file:///home/spineki/Desktop/report [found 9094 in 1 exec envs] (51ms)
2024-03-04 13:41:26.330 [info] [Info  - 1:41:26 PM] (41907) indexed(2) 190 files over 1 exec env
2024-03-04 13:41:26.445 [info] [Info  - 1:41:26 PM] (41907) Indexing finished(2).
2024-03-04 13:41:33.341 [info] (41907) [FG] parsing: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/typing.pyi [fs read 0ms] (15ms)
2024-03-04 13:41:33.347 [info] (41907) [FG] binding: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/typing.pyi (6ms)
2024-03-04 13:41:33.357 [info] (41907) [FG] parsing: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/types.pyi [fs read 0ms] (3ms)
2024-03-04 13:41:33.358 [info] (41907) [FG] binding: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/types.pyi (2ms)
2024-03-04 13:41:33.363 [info] (41907) [FG] parsing: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi [fs read 0ms] (2ms)
2024-03-04 13:41:33.365 [info] (41907) [FG] binding: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi (1ms)
2024-03-04 13:41:33.368 [info] (41907) [FG] parsing: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/abc.pyi [fs read 0ms] (1ms)
2024-03-04 13:41:33.368 [info] (41907) [FG] binding: file:///home/spineki/.vscode/extensions/ms-python.vscode-pylance-2024.2.2/dist/typeshed-fallback/stdlib/abc.pyi (0ms)
2024-03-04 13:41:41.215 [info] (41907) Background inlayHint message
2024-03-04 13:41:41.216 [info] (41907) [BG(1)] getInlayHints range 0:0 - 77:0 at file:///home/spineki/Desktop/report/main.py (2ms)
erictraut commented 4 months ago

Pyright is working as designed here, so I don't consider this a bug.

You're relying on an advanced inference technique in pyright called narrowing for implied else. This technique has some documented limitation for performance reasons. You're hitting these limitations in two of your three code snippets above.