Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properties overridden by members incorrectly report type errors #3519

Closed
koterpillar opened this issue Oct 23, 2022 · 1 comment
Closed

Properties overridden by members incorrectly report type errors #3519

koterpillar opened this issue Oct 23, 2022 · 1 comment

Comments

@koterpillar
Copy link

Environment data

  • Language Server version: 2022.10.30
  • OS and version: linux x64
  • Python version (and distribution if applicable, e.g. Anaconda): 3.10.7
  • python.analysis.indexing: false
  • python.analysis.typeCheckingMode: basic

Code Snippet

class A:
    @property
    def mynumber(self) -> int:
        return 1

class B(A):
    mynumber = 2

Expected behavior

No type errors.

Actual behavior

Expression of type "Literal[2]" cannot be assigned to declared type "property"
"Literal[2]" is incompatible with "property" Pylance (reportGeneralTypeIssues)

Logs

Logs
[Info  - 20:27:27] (19154) Pylance language server 2022.10.30 (pyright 50e12b4b) starting
[Info  - 20:27:27] (19154) Server root directory: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist
[Info  - 20:27:27] (19154) Starting service instance "mybox"
[Info  - 20:27:27] (19154) Notebook support: LSP
[Info  - 20:27:27] (19154) Interactive window support: LSP
[Info  - 20:27:27] (19154) No configuration file found.
[Info  - 20:27:27] (19154) pyproject.toml file found at /home/alex/projects/mybox.
[Info  - 20:27:27] (19154) Setting pythonPath for service "mybox": "/home/alex/.cache/pypoetry/virtualenvs/mybox-YUnsYrZx-py3.10/bin/python"
[Info  - 20:27:27] (19154) Loading pyproject.toml file at /home/alex/projects/mybox/pyproject.toml
[Error - 20:27:27] (19154) Pyproject file "/home/alex/projects/mybox/pyproject.toml" is missing "[tool.pyright]" section.
[Warn  - 20:27:27] (19154) stubPath /home/alex/projects/mybox/typings is not a valid directory.
[Info  - 20:27:27] (19154) Assuming Python version 3.10
[Info  - 20:27:27] (19154) Assuming Python platform Linux
[Info  - 20:27:27] (19154) Search paths for /home/alex/projects/mybox
[Info  - 20:27:27] (19154)   /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib
[Info  - 20:27:27] (19154)   /home/alex/projects/mybox
[Info  - 20:27:27] (19154)   /home/alex/projects/mybox/typings
[Info  - 20:27:27] (19154)   /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stubs/...
[Info  - 20:27:27] (19154)   /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/bundled/stubs
[Info  - 20:27:27] (19154)   /usr/lib64/python3.10
[Info  - 20:27:27] (19154)   /usr/lib64/python3.10/lib-dynload
[Info  - 20:27:27] (19154)   /home/alex/.cache/pypoetry/virtualenvs/mybox-YUnsYrZx-py3.10/lib64/python3.10/site-packages
[Info  - 20:27:27] (19154)   /home/alex/.cache/pypoetry/virtualenvs/mybox-YUnsYrZx-py3.10/lib/python3.10/site-packages
[Info  - 20:27:27] (19154)   /home/alex/projects/mybox
[Info  - 20:27:27] (19154) Adding fs watcher for library directories:
 /usr/lib64/python3.10
/usr/lib64/python3.10/lib-dynload
/home/alex/.cache/pypoetry/virtualenvs/mybox-YUnsYrZx-py3.10/lib64/python3.10/site-packages
/home/alex/.cache/pypoetry/virtualenvs/mybox-YUnsYrZx-py3.10/lib/python3.10/site-packages
[Info  - 20:27:27] (19154) Adding fs watcher for directories:
 /home/alex/projects/mybox
[Info  - 20:27:27] (19154) Searching for source files
[Info  - 20:27:27] (19154) Found 35 source files
(19154) [IDX(FG)] index libraries /home/alex/projects/mybox (index) ...
(19154) [IDX(FG)]   read stdlib indices (29ms)
(19154) [IDX(FG)] index libraries /home/alex/projects/mybox (index) [succeed] (30ms)
(19154) [FG] parsing: Untitled-1 (23ms)
(19154) [FG] parsing: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 3ms] (116ms)
(19154) [FG] binding: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/builtins.pyi (32ms)
(19154) [FG] binding: Untitled-1 (1ms)
[Info  - 20:27:28] (19154) Background analysis(1) root directory: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist
[Info  - 20:27:28] (19154) Background analysis(1) started
(19154) Background analysis message: setConfigOptions
(19154) Background analysis message: setImportResolver
(19154) Background analysis message: ensurePartialStubPackages
(19154) Background analysis message: setTrackedFiles
(19154) Background analysis message: markAllFilesDirty
(19154) Background analysis message: setFileOpened
(19154) Background analysis message: analyze
(19154) [BG(1)] analyzing: Untitled-1 ...
(19154) [BG(1)]   parsing: Untitled-1 (23ms)
(19154) [BG(1)]   parsing: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 2ms] (84ms)
(19154) [BG(1)]   binding: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/builtins.pyi (33ms)
(19154) [BG(1)]   binding: Untitled-1 (0ms)
(19154) [BG(1)]   checking: Untitled-1 ...
(19154) [BG(1)]     parsing: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/typing.pyi [fs read 2ms] (23ms)
(19154) [BG(1)]     binding: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/typing.pyi (7ms)
(19154) [BG(1)]     parsing: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/typing_extensions.pyi [fs read 0ms] (3ms)
(19154) [BG(1)]     binding: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/typing_extensions.pyi (2ms)
(19154) [BG(1)]     parsing: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi [fs read 0ms] (9ms)
(19154) [BG(1)]     binding: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi (12ms)
(19154) [BG(1)]     parsing: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/types.pyi [fs read 1ms] (8ms)
(19154) [BG(1)]     binding: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/types.pyi (4ms)
(19154) [BG(1)]     parsing: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/abc.pyi [fs read 1ms] (2ms)
(19154) [BG(1)]     binding: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/abc.pyi (0ms)
(19154) [BG(1)]     parsing: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/collections/abc.pyi [fs read 0ms] (1ms)
(19154) [BG(1)]     binding: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/collections/abc.pyi ...
(19154) [BG(1)]       parsing: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/_collections_abc.pyi [fs read 0ms] (2ms)
(19154) [BG(1)]       binding: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/_collections_abc.pyi (1ms)
(19154) [BG(1)]     binding: /home/alex/.vscode/extensions/ms-python.vscode-pylance-2022.10.30/dist/typeshed-fallback/stdlib/collections/abc.pyi (4ms)
(19154) [BG(1)]   checking: Untitled-1 (125ms)
(19154) [BG(1)] analyzing: Untitled-1 (269ms)
(19154) Background analysis message: getSemanticTokens full
(19154) [BG(1)] getSemanticTokens full at Untitled-1 (3ms)
(19154) Background analysis message: getDiagnosticsForRange
(19154) Background analysis message: getSemanticTokens range
(19154) [BG(1)] getSemanticTokens range 0:0 - 6:11 at Untitled-1 (0ms)
(19154) Background analysis message: resumeAnalysis
(19154) Background analysis message: getDiagnosticsForRange
(19154) Background analysis message: getDiagnosticsForRange
(19154) Background analysis message: getDiagnosticsForRange
[Info  - 20:27:28] (19154) SourceFile: Received fs event 'change' for path '/home/alex/projects/mybox/.git/FETCH_HEAD'```
</details>
@koterpillar
Copy link
Author

I am convinced by the justification in microsoft/pyright#2601 (comment). Apologies for not searching thoroughly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant