-
Notifications
You must be signed in to change notification settings - Fork 767
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
Pylance intellisense does not highlight object methods in case of its creation with different arg types #1869
Comments
First, there's a type error in the sample above. The expression Second, I'm not able to repro the behavior you're seeing @jakebailey. I can't see all of your code, so perhaps there are differences? Where is the value of 1234 coming from? Here's what I see: from typing import Optional
class DBClient:
def __init__(self, param: str):
self.param = param
async def setup(self):
pass
class DecisionEngine:
def __init__(self):
self.db: Optional[DBClient] = None
async def setup(self):
self.db = DBClient("1")
reveal_type(await self.db.setup()) |
The code I have is this:
Revealing the type produces the right result, but try hovering on Similarly on |
I did a bit of debugging, and our hover code sees that it's a name node (it being |
I didn't see any type error at VS Code, why? |
@wvolkov Type checking isn't enabled by default in Pylance; you need to set |
Yes, good catch. There is a bug here that causes the hover type for |
This issue has been fixed in version 2021.9.4, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202194-29-september-2021 |
Environment data
Code Snippet / Additional information
Assume class
DecisionEngine
, which creates an instance ofDBClient
, passing aninteger
instead ofstring
as specified below:Expected behaviour
at setup method of
![image](https://user-images.githubusercontent.com/49549154/134643410-29ee0664-e722-4c34-8210-3d7559a45f58.png)
DecisionEngine
class it is possible to drill down intosetup
method ofdb
object:Actual behaviour
it interprets
![image](https://user-images.githubusercontent.com/49549154/134643501-2eefa573-ef8a-468c-9faf-b236773082a6.png)
![image](https://user-images.githubusercontent.com/49549154/134643592-1f5f69fa-e156-4e14-a8ea-5d49d4b83651.png)
db
object asAny
typedespite the fact that it is correctly recognize the type of
db
object at upper line of codeThe text was updated successfully, but these errors were encountered: