PyCharm autocompletion for properties
See original GitHub issueDue to the fact that the classes have dynamically generated fields for the AWS resource properties, IDEs like PyCharm doesn’t suggest those fields during autocompletion.
For example:
from troposphere import Template, apigateway
t = Template()
apiResource = apigateway.Resource("contactcloud")
apiResource.ParentId #<-- won't be suggested by autocompletion!
This could be remedied in two ways:
1. Add type hints to the beginning of classes, e.g.:
class Resource(AWSObject):
ParentId: basestring # Python 3 type hints for fields
PathPart: basestring
RestApiId: basestring
resource_type = "AWS::ApiGateway::Resource"
props = {
"ParentId": (basestring, True),
"PathPart": (basestring, True),
"RestApiId": (basestring, True)
}
2. Generate stub files
This is outlined by PEP 484#stub-files
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:33 (21 by maintainers)
Top Results From Across the Web
Code completion | PyCharm Documentation - JetBrains
PyCharm automatically completes the construct and adds the required punctuation. The caret is placed at the next editing position.
Read more >Turn off auto completion of methods in PyCharm unless and ...
The checkbox in PyCharm's Settings->Editor->General->Code Completion insert selected suggestion by pressing space, dot, or some other context- ...
Read more >Some useful PyCharm features — IPKISS 3.9 documentation
While typing, PyCharm will try to autocomplete your code. This happens automatically as you type your class, function or method.
Read more >Boost your YAML with autocompletion and validation - Medium
It allows to add description to properties, declare a property type, ... I'm using PyCharm by Intellij but you can do the same...
Read more >Basic code assistance in PyCharm | Getting started - YouTube
This is the Getting Started Series, with Paul Everitt.In this episode, you will learn how to create install and manage Python packages in ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve been busy but keeping an eye on this thread. Here’s some comments:
Anyway, wanted to provide a quick update from my viewpoint. The key for me is to rely more on the generator to keep the library up to date with the resource spec, ensure reproducible results (due to renames that are required), and to generate the corresponding stubs accurately.
@MacHu-GWU - Just want to echo the feedback that everyone else has provided. Changing the names of the properties kills its usability for me and my teams. I get that you are trying to differentiate required vs optional parameters but the appropriate way to do that would be by making the type annotation of the property
Optional[type]
not by changing the documented names of the properties. This is something that all modern IDEs display and provide feedback for before runtime (type checkers like pyright can also be used). I my opinion and that of other I work with, changing the names of the properties adds more complexity especially for the “low experience engineers” you are targeting.That’s not to say cottonformation isn’t a nice library. It’s just not a replacement for Troposphere for a company with hundreds of Troposphere templates (which would take a significant amount of time to update EVERY property) and is not a solution to this problem.