Types of properties of classes are not recognized #18474
-
Hello, I have a problem with code completion for properties of classes.
When I put the cursor at the end of the last line it doesn't display any field of Sample class because it cannot read the returned type of array from the ratings.samples property and displays it as any. How to make it work? I checked the documentation but I haven't found any setting about it. Also please let me know if I missed something or it is unsupported. Configuration:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Are you using Pylance or Jedi? If it's the former then please open an issue at https://github.com/microsoft/pylance-release. If you're using Jedi then please open an issue at https://github.com/davidhalter/jedi . Can I also suggest you look at dataclasses for what you're trying to accomplish with the above code? You can make them immutable like you seem to be after and cut down on the amount of work you're doing. I would also change your And I wouldn't use |
Beta Was this translation helpful? Give feedback.
-
Hello @brettcannon , thank you for the quick answer - I'll open the ticket for the Pylance. |
Beta Was this translation helpful? Give feedback.
Are you using Pylance or Jedi? If it's the former then please open an issue at https://github.com/microsoft/pylance-release. If you're using Jedi then please open an issue at https://github.com/davidhalter/jedi .
Can I also suggest you look at dataclasses for what you're trying to accomplish with the above code? You can make them immutable like you seem to be after and cut down on the amount of work you're doing. I would also change your
__str__
to be the__repr__
and you don't need to define__del__
; Python takes care of all of that for you.And I wouldn't use
__
prefixes; that's meant to prevent name clashes with subclasses and not to hide attributes as you can still get at them withge…