Declare Command: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
==The problem==
==The problem==


Curent PyMOL approach to new plugin commands are outdated.
Current PyMOL approach to new plugin commands is 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 type coercion.


==What works right now?==
==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.
There's some support on PyMOL open-source, but not on Incentive. However it isn't working for all possible cases.




==Example of how it can be==
<source lang="python">
 
@cmd.declare_command
<source lang="python">
@declare_command
def new_command(
def new_command(
    my_var: int | float,
     dirname: Path = '.',
     dirname: Path = '.',
    # Optional values aren't currently supported.
    # Tuples are.
     nullable_point: Optional[Tuple[int, int, int]] = None,
     nullable_point: Optional[Tuple[int, int, int]] = None,
    my_var: int | float
     extended_calculation: bool = True,
     extended_calculation: bool = True,
     old_style: Any = "Support anything currently not supported"
     old_style: Any = "Support anything currently not supported",
) -> IgnoredType:
):
     """
     """
     A cool docstring.
     A cool docstring.
     """
     """
     pass
     pass
 
</source>
 
  </source>
 
 
I'm also propose to better support docstrings.
 
==Difficulties==

Latest revision as of 08:09, 21 June 2025

The problem

Current PyMOL approach to new plugin commands is outdated.

The proposal

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

What works right now?

There's some support on PyMOL open-source, but not on Incentive. However it isn't working for all possible cases.


@cmd.declare_command
def new_command(
    my_var: int | float,
    dirname: Path = '.',
    # Optional values aren't currently supported.
    # Tuples are.
    nullable_point: Optional[Tuple[int, int, int]] = None,
    extended_calculation: bool = True,
    old_style: Any = "Support anything currently not supported",
):
    """
    A cool docstring.
    """
    pass