Comments (5)
I don't think there's a "correct" answer here. I can point to cases where either choice is correct. The current behavior is at least internally consistent. If a callable object has a __call__
method with a docstring, that docstring takes precedence over any docstring that is captured by a ParamSpec used within that __call__
method's signature.
You can omit the docstring for the __call__
method if you don't want it to take precedence. Pyright/pylance will then use the docstring captured by the ParamSpec.
from pylance-release.
For reference, I've updated the description to note that Jedi appears to implement the behavior I'd like given the example I provided.
You can omit the docstring for the
__call__
method if you don't want it to take precedence.
Perhaps I'm not on the latest version, but in my example, the docstring is not displayed even though RequiresOptions.__call__
lacks a docstring. Removing the docstring from RequiresOptions
itself doesn't change that either.
I'd definitely be satisfied with this behavior though. For whatever reason I'm just not seeing it in my example.
from pylance-release.
I see what you mean. The docstring does appear in the signature help (when typing the arguments for the foo
call), but it doesn't appear when hovering over foo
. That's a current limitation of the hover provider βΒ the language server module that provides the hover text. I agree that it would make sense for the hover provider to include the "adopted" decorator in this case in the same way that the signature help provider does.
Here's the signature help for foo
. You can see that the "adopted" docstring does appear here.
In summary, I think the pyright type analyzer is doing the right thing here and preserving the docstring, but the hover provider (which is owned by the pylance team) is not using this information when the identifier is an instance of a callable object (i.e. an instance of a class that has a __call__
method). So I think this is a feature request for the Pylance team to add such support.
from pylance-release.
Great. Thanks for digging into the issue. I Look forward to having it fixed!
from pylance-release.
when we rework how we do doc string this sprint, we should make sure all features that use doc string use same code to make sure we have consistent behavior regardless where it is shown to users.
currently, we have slightly different code depends on each features.
from pylance-release.
Related Issues (20)
- Add semantic token modifiers to callable variables. HOT 3
- Save file lag HOT 2
- searchImport not finding modules HOT 4
- Pylance hangs after using "Go to Definition" on PySide6 objects HOT 2
- pylance JavaScript heap out of memory I set NODE_OPTIONS and exlude HOT 7
- IntelliSense/Pylance Semantic Highlighting and auto-code-completion is not working HOT 9
- Python intellisense not working HOT 2
- VS code "Find All References" does not find all references of a Python identifier HOT 2
- Not ignoring 'DELETE' keyword even it is enclosed with single or double quotes HOT 3
- Ability to force pylance to treat wrapped functions as functions as opposed to variables HOT 2
- Incorrect logic in unreachable code involving None and break HOT 2
- Show Type Hierarchy in notebook fails to find subtypes of type imported from .py file
- "requests" is not accessed Pylance. I am getting this problem when trying to import requests,it is already installed in the system but the word get coloured to green instead of white and when l click on it that is the info it shows HOT 2
- v2024.5.1: Resolving the import of non-"third party" modules HOT 8
- Remote extension host terminates unexpectedly HOT 15
- no module error if module was properly imported HOT 1
- Pylance doesn't stop analyzing files HOT 34
- Debug Failure. False expression: Check called before parsing HOT 2
- Function is not accessed (although it IS accessed) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pylance-release.