Skip to content

Shortcut now missing has_key method #425

@alexander-myronov

Description

@alexander-myronov

Describe the bug

After the refactoring of the Shortcut class in this PR (https://github.com/schrodinger/pymol-open-source/pull/391/files), it is now missing a has_key method, which is still expected in setting.py (https://github.com/schrodinger/pymol-open-source/blob/master/modules/pymol/setting.py#L91).

To Reproduce

pymol -c -d "set pdb_use_ter_records, 0"

causes

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pymol/setting.py", line 263, in set
    v = (type, _validate_value(type, value))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pymol/setting.py", line 91, in _validate_value
    if is_string(value) and boolean_sc.has_key(value):
                            ^^^^^^^^^^^^^^^^^^
AttributeError: 'Shortcut' object has no attribute 'has_key'

Possible fix

As the new Shortcut implementation has a __contains__ method, you can just do

if is_string(value) and value in boolean_sc:

Environment

  • PyMOL Version: PyMOL 3.1.0 Open-Source (7852010), 2025-01-27

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions