Skip to content

fix: added support for autocompletion on the low ui approach for pycharm#313

Merged
ramedina86 merged 1 commit intowriter:devfrom
FabienArcellier:40-added-support-for-autocompletion-on-the-low-ui-approach-for-pycharm
Mar 18, 2024
Merged

fix: added support for autocompletion on the low ui approach for pycharm#313
ramedina86 merged 1 commit intowriter:devfrom
FabienArcellier:40-added-support-for-autocompletion-on-the-low-ui-approach-for-pycharm

Conversation

@FabienArcellier
Copy link
Contributor

@FabienArcellier FabienArcellier commented Mar 16, 2024

Pycharm does not currently support autocompletion on TypedDict passed as an argument to a method. This problem does not seem to be really addressed in their roadmap.

https://youtrack.jetbrains.com/issue/PY-54151/TypedDict-completion-at-callee-does-not-work-for-methods
On the other hand, Pycharm supports autocompletion on static methods of a class.

I propose a draft to manage the component tree as a context variable. This pattern offer 2 advantages :

  • all the methods of ui manager can be static
  • a developper than build an extension can manipulate the component tree easily inside its extension

FabienArcellier#40


Peek 2024-03-16 05-27


I test this implementation on event handler and async event handler

@FabienArcellier FabienArcellier marked this pull request as draft March 16, 2024 05:41
@FabienArcellier FabienArcellier changed the title fix: added support for autocompletion on the low ui approach for pycharm fix: added support for autocompletion on the low ui approach for pycharm [proposal] Mar 16, 2024
@FabienArcellier FabienArcellier force-pushed the 40-added-support-for-autocompletion-on-the-low-ui-approach-for-pycharm branch from 0ab33d4 to ab70857 Compare March 16, 2024 06:52
raise UIError("A component can only be created inside a container")

@property
def component_tree(self) -> ComponentTree:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that this property is not used, and other methods still access current_component_tree() directly. I believe we could replace all calls to it with this property, or is there something I am missing?

Copy link
Contributor Author

@FabienArcellier FabienArcellier Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep it for debug purpose on the IDE. It help people that read the code to understand how to access component tree.

Yes we can

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally we can't because the method are static and component tree is a property. It's not accessible

@FabienArcellier FabienArcellier force-pushed the 40-added-support-for-autocompletion-on-the-low-ui-approach-for-pycharm branch 2 times, most recently from 97e3a5a to 4e1a6fd Compare March 18, 2024 15:27
@FabienArcellier FabienArcellier marked this pull request as ready for review March 18, 2024 15:33
@FabienArcellier FabienArcellier changed the title fix: added support for autocompletion on the low ui approach for pycharm [proposal] fix: added support for autocompletion on the low ui approach for pycharm Mar 18, 2024
@FabienArcellier FabienArcellier force-pushed the 40-added-support-for-autocompletion-on-the-low-ui-approach-for-pycharm branch from 4e1a6fd to 6baa79f Compare March 18, 2024 17:29
@ramedina86 ramedina86 merged commit b87b964 into writer:dev Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants