Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut now missing has_key method #425

Closed
alexander-myronov opened this issue Jan 28, 2025 · 1 comment
Closed

Shortcut now missing has_key method #425

alexander-myronov opened this issue Jan 28, 2025 · 1 comment

Comments

@alexander-myronov
Copy link

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
@ye11owSub
Copy link
Contributor

@alexander-myronov
Thank you for bringing this to attention. I didn't notice this during the refactoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants