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

IntelliSense gives unknown type for field with type hint #3674

Closed
huguesv opened this issue Jan 31, 2018 · 2 comments
Closed

IntelliSense gives unknown type for field with type hint #3674

huguesv opened this issue Jan 31, 2018 · 2 comments

Comments

@huguesv
Copy link
Contributor

huguesv commented Jan 31, 2018

Here's one from Dan's email listing several issues with type hints.

class Employee:
    name: str
    id: int

def isValidEmployee(employee: Employee):
    s = employee.name

It doesn't know the type of name is str. It doesn't know about name or id at all, they don't appear in completions.

image

FYI I checked both 15.6rel and master, no difference between the two.

@zooba
Copy link
Member

zooba commented Mar 20, 2018

We generally don't display undefined variables as if they are defined, so if we're going to start doing that, we'll have to come up with a way to make clear that they aren't really there:

>>> class Employee:
...     name: str
...     id: int
...
>>> def isValidEmployee(employee: Employee):
...     s = employee.name
...
>>> isValidEmployee(Employee())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in isValidEmployee
AttributeError: 'Employee' object has no attribute 'name'
>>>

@huguesv
Copy link
Contributor Author

huguesv commented Mar 30, 2018

Tooltip is now okay. Not sure where the sample code originated from, but I'll close as by design.

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

No branches or pull requests

2 participants