Declare Command: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
Curent PyMOL approach to new plugin commands are outdated.
Curent PyMOL approach to new plugin commands are outdated.


==The proposal
==The proposal==


Introduce a new system based on modern Python with type checking and implicit conversion.
Introduce a new system based on modern Python with type checking and implicit conversion.
Line 12: Line 12:




==Example==
==Example of how it can be==


  <source lang="python">
  <source lang="python">
Line 20: Line 20:
     nullable_point: Optional[Tuple[int, int, int]] = None,
     nullable_point: Optional[Tuple[int, int, int]] = None,
     my_var: int | float
     my_var: int | float
     extended_calculation: bool = True
     extended_calculation: bool = True,
    old_style: Any = "Support anything currently not supported"
) -> IgnoredType:
) -> IgnoredType:
     """
     """
Line 32: Line 33:


I'm also propose to better support docstrings.
I'm also propose to better support docstrings.
==Difficulties==

Latest revision as of 07:34, 11 April 2025

The problem

Curent PyMOL approach to new plugin commands are outdated.

The proposal

Introduce a new system based on modern Python with type checking and implicit conversion.

What works right now?

On PyMOL open-source, but not on Incentive, there's a cmd.declare_command but isn't very much working for all possible cases.


Example of how it can be

@declare_command
def new_command(
    dirname: Path = '.',
    nullable_point: Optional[Tuple[int, int, int]] = None,
    my_var: int | float
    extended_calculation: bool = True,
    old_style: Any = "Support anything currently not supported"
) -> IgnoredType:
    """
    A cool docstring.
    """
    pass


I'm also propose to better support docstrings.

Difficulties