Declare Command: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
(Created page with "==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. ==Examples <source lang="python"> @declare_command def new_command( dirname: Path = '.', nullable_point: Optional[Tuple[int, int,...")
 
No edit summary
Line 1: Line 1:
==The problem
==The problem==


Curent PyMOL approach to new plugin commands are outdated.
Curent PyMOL approach to new plugin commands are outdated.
Line 7: Line 7:
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.


==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.
On PyMOL open-source, but not on Incentive, there's a cmd.declare_command but isn't very much working for all possible cases.




==Examples
==Example==
 


  <source lang="python">
  <source lang="python">

Revision as of 07:30, 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

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


I'm also propose to better support docstrings.