Declare Command: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
| PedroLacerda (talk | contribs) | PedroLacerda (talk | contribs)  No edit summary | ||
| (One intermediate revision by the same user not shown) | |||
| Line 9: | Line 9: | ||
| ==What works right now?== | ==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. | |||
| <source lang="python"> | |||
| @cmd.declare_command | @cmd.declare_command | ||
| def new_command( | def new_command( | ||
|     my_var: int | float, | |||
|      dirname: Path = '.', |      dirname: Path = '.', | ||
|      #nullable_point: Optional[Tuple[int, int, int]] = None, |      # Optional values aren't currently supported. | ||
|     # Tuples are. | |||
|     nullable_point: Optional[Tuple[int, int, int]] = None, | |||
|      extended_calculation: bool = True, |      extended_calculation: bool = True, | ||
|      old_style: Any = "Support anything currently not supported", |      old_style: Any = "Support anything currently not supported", | ||
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